Update auto-generated bindings to 0.0.101
[ldk-java] / ts / bindings.c.body
1 #include "js-wasm.h"
2 #include <stdatomic.h>
3 #include <lightning.h>
4
5 // These should be provided...somehow...
6 void *memset(void *s, int c, size_t n);
7 void *memcpy(void *dest, const void *src, size_t n);
8 int memcmp(const void *s1, const void *s2, size_t n);
9
10 void __attribute__((noreturn)) abort(void);
11 static inline void assert(bool expression) {
12         if (!expression) { abort(); }
13 }
14
15 void *malloc(size_t size);
16 void free(void *ptr);
17
18 #define MALLOC(a, _) malloc(a)
19 #define FREE(p) if ((long)(p) > 1024) { free(p); }
20 #define DO_ASSERT(a) (void)(a)
21 #define CHECK(a)
22
23 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
24 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
25 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
26 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
27
28 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
29
30 typedef uint32_t int64_tArray;
31 typedef uint32_t int8_tArray;
32 typedef uint32_t uint32_tArray;
33 typedef uint32_t ptrArray;
34 typedef uint32_t jstring;
35
36 static inline uint32_t init_arr(size_t arr_len, size_t elem_size, const char *type_desc) {
37         uint32_t *elems = (uint32_t*)MALLOC(arr_len * elem_size + 4, type_desc);
38         elems[0] = arr_len;
39         return (uint32_t)elems;
40 }
41
42 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
43         char* err_buf = MALLOC(len + 4, "str conv buf");
44         *((uint32_t*)err_buf) = len;
45         memcpy(err_buf + 4, chars, len);
46         return (uint32_t) err_buf;
47 }
48 static inline LDKStr str_ref_to_owned_c(jstring str) {
49         uint32_t *str_len = (uint32_t*)str;
50         char* newchars = MALLOC(*str_len + 1, "String chars");
51         memcpy(newchars, (const char*)(str + 4), *str_len);
52         newchars[*str_len] = 0;
53         LDKStr res= {
54                 .chars = newchars,
55                 .len = *str_len,
56                 .chars_is_owned = true
57         };
58         return res;
59 }
60
61 typedef bool jboolean;
62
63 uint32_t __attribute__((visibility("default"))) TS_malloc(uint32_t size) {
64         return (uint32_t)MALLOC(size, "JS-Called malloc");
65 }
66 void __attribute__((visibility("default"))) TS_free(uint32_t ptr) {
67         FREE((void*)ptr);
68 }
69 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
70 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
71         switch (ord) {
72                 case 0: return LDKAccessError_UnknownChain;
73                 case 1: return LDKAccessError_UnknownTx;
74         }
75         abort();
76 }
77 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
78         switch (val) {
79                 case LDKAccessError_UnknownChain: return 0;
80                 case LDKAccessError_UnknownTx: return 1;
81                 default: abort();
82         }
83 }
84 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
85         switch (ord) {
86                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
87                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
88         }
89         abort();
90 }
91 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
92         switch (val) {
93                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
94                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
95                 default: abort();
96         }
97 }
98 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
99         switch (ord) {
100                 case 0: return LDKConfirmationTarget_Background;
101                 case 1: return LDKConfirmationTarget_Normal;
102                 case 2: return LDKConfirmationTarget_HighPriority;
103         }
104         abort();
105 }
106 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
107         switch (val) {
108                 case LDKConfirmationTarget_Background: return 0;
109                 case LDKConfirmationTarget_Normal: return 1;
110                 case LDKConfirmationTarget_HighPriority: return 2;
111                 default: abort();
112         }
113 }
114 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
115         switch (ord) {
116                 case 0: return LDKCreationError_DescriptionTooLong;
117                 case 1: return LDKCreationError_RouteTooLong;
118                 case 2: return LDKCreationError_TimestampOutOfBounds;
119                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
120         }
121         abort();
122 }
123 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
124         switch (val) {
125                 case LDKCreationError_DescriptionTooLong: return 0;
126                 case LDKCreationError_RouteTooLong: return 1;
127                 case LDKCreationError_TimestampOutOfBounds: return 2;
128                 case LDKCreationError_ExpiryTimeOutOfBounds: return 3;
129                 default: abort();
130         }
131 }
132 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
133         switch (ord) {
134                 case 0: return LDKCurrency_Bitcoin;
135                 case 1: return LDKCurrency_BitcoinTestnet;
136                 case 2: return LDKCurrency_Regtest;
137                 case 3: return LDKCurrency_Simnet;
138                 case 4: return LDKCurrency_Signet;
139         }
140         abort();
141 }
142 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
143         switch (val) {
144                 case LDKCurrency_Bitcoin: return 0;
145                 case LDKCurrency_BitcoinTestnet: return 1;
146                 case LDKCurrency_Regtest: return 2;
147                 case LDKCurrency_Simnet: return 3;
148                 case LDKCurrency_Signet: return 4;
149                 default: abort();
150         }
151 }
152 static inline LDKIOError LDKIOError_from_js(int32_t ord) {
153         switch (ord) {
154                 case 0: return LDKIOError_NotFound;
155                 case 1: return LDKIOError_PermissionDenied;
156                 case 2: return LDKIOError_ConnectionRefused;
157                 case 3: return LDKIOError_ConnectionReset;
158                 case 4: return LDKIOError_ConnectionAborted;
159                 case 5: return LDKIOError_NotConnected;
160                 case 6: return LDKIOError_AddrInUse;
161                 case 7: return LDKIOError_AddrNotAvailable;
162                 case 8: return LDKIOError_BrokenPipe;
163                 case 9: return LDKIOError_AlreadyExists;
164                 case 10: return LDKIOError_WouldBlock;
165                 case 11: return LDKIOError_InvalidInput;
166                 case 12: return LDKIOError_InvalidData;
167                 case 13: return LDKIOError_TimedOut;
168                 case 14: return LDKIOError_WriteZero;
169                 case 15: return LDKIOError_Interrupted;
170                 case 16: return LDKIOError_Other;
171                 case 17: return LDKIOError_UnexpectedEof;
172         }
173         abort();
174 }
175 static inline int32_t LDKIOError_to_js(LDKIOError val) {
176         switch (val) {
177                 case LDKIOError_NotFound: return 0;
178                 case LDKIOError_PermissionDenied: return 1;
179                 case LDKIOError_ConnectionRefused: return 2;
180                 case LDKIOError_ConnectionReset: return 3;
181                 case LDKIOError_ConnectionAborted: return 4;
182                 case LDKIOError_NotConnected: return 5;
183                 case LDKIOError_AddrInUse: return 6;
184                 case LDKIOError_AddrNotAvailable: return 7;
185                 case LDKIOError_BrokenPipe: return 8;
186                 case LDKIOError_AlreadyExists: return 9;
187                 case LDKIOError_WouldBlock: return 10;
188                 case LDKIOError_InvalidInput: return 11;
189                 case LDKIOError_InvalidData: return 12;
190                 case LDKIOError_TimedOut: return 13;
191                 case LDKIOError_WriteZero: return 14;
192                 case LDKIOError_Interrupted: return 15;
193                 case LDKIOError_Other: return 16;
194                 case LDKIOError_UnexpectedEof: return 17;
195                 default: abort();
196         }
197 }
198 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
199         switch (ord) {
200                 case 0: return LDKLevel_Trace;
201                 case 1: return LDKLevel_Debug;
202                 case 2: return LDKLevel_Info;
203                 case 3: return LDKLevel_Warn;
204                 case 4: return LDKLevel_Error;
205         }
206         abort();
207 }
208 static inline int32_t LDKLevel_to_js(LDKLevel val) {
209         switch (val) {
210                 case LDKLevel_Trace: return 0;
211                 case LDKLevel_Debug: return 1;
212                 case LDKLevel_Info: return 2;
213                 case LDKLevel_Warn: return 3;
214                 case LDKLevel_Error: return 4;
215                 default: abort();
216         }
217 }
218 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
219         switch (ord) {
220                 case 0: return LDKNetwork_Bitcoin;
221                 case 1: return LDKNetwork_Testnet;
222                 case 2: return LDKNetwork_Regtest;
223                 case 3: return LDKNetwork_Signet;
224         }
225         abort();
226 }
227 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
228         switch (val) {
229                 case LDKNetwork_Bitcoin: return 0;
230                 case LDKNetwork_Testnet: return 1;
231                 case LDKNetwork_Regtest: return 2;
232                 case LDKNetwork_Signet: return 3;
233                 default: abort();
234         }
235 }
236 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
237         switch (ord) {
238                 case 0: return LDKSecp256k1Error_IncorrectSignature;
239                 case 1: return LDKSecp256k1Error_InvalidMessage;
240                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
241                 case 3: return LDKSecp256k1Error_InvalidSignature;
242                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
243                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
244                 case 6: return LDKSecp256k1Error_InvalidTweak;
245                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
246                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
247         }
248         abort();
249 }
250 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
251         switch (val) {
252                 case LDKSecp256k1Error_IncorrectSignature: return 0;
253                 case LDKSecp256k1Error_InvalidMessage: return 1;
254                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
255                 case LDKSecp256k1Error_InvalidSignature: return 3;
256                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
257                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
258                 case LDKSecp256k1Error_InvalidTweak: return 6;
259                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
260                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
261                 default: abort();
262         }
263 }
264 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
265         switch (ord) {
266                 case 0: return LDKSemanticError_NoPaymentHash;
267                 case 1: return LDKSemanticError_MultiplePaymentHashes;
268                 case 2: return LDKSemanticError_NoDescription;
269                 case 3: return LDKSemanticError_MultipleDescriptions;
270                 case 4: return LDKSemanticError_NoPaymentSecret;
271                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
272                 case 6: return LDKSemanticError_InvalidFeatures;
273                 case 7: return LDKSemanticError_InvalidRecoveryId;
274                 case 8: return LDKSemanticError_InvalidSignature;
275                 case 9: return LDKSemanticError_ImpreciseAmount;
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_NoPaymentSecret: return 4;
286                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
287                 case LDKSemanticError_InvalidFeatures: return 6;
288                 case LDKSemanticError_InvalidRecoveryId: return 7;
289                 case LDKSemanticError_InvalidSignature: return 8;
290                 case LDKSemanticError_ImpreciseAmount: return 9;
291                 default: abort();
292         }
293 }
294 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
295         switch (ord) {
296                 case 0: return LDKSiPrefix_Milli;
297                 case 1: return LDKSiPrefix_Micro;
298                 case 2: return LDKSiPrefix_Nano;
299                 case 3: return LDKSiPrefix_Pico;
300         }
301         abort();
302 }
303 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
304         switch (val) {
305                 case LDKSiPrefix_Milli: return 0;
306                 case LDKSiPrefix_Micro: return 1;
307                 case LDKSiPrefix_Nano: return 2;
308                 case LDKSiPrefix_Pico: return 3;
309                 default: abort();
310         }
311 }
312 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
313         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
314         ret->datalen = *((uint32_t*)elems);
315         if (ret->datalen == 0) {
316                 ret->data = NULL;
317         } else {
318                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
319                 int8_t *java_elems = (int8_t*)(elems + 4);
320                 for (size_t i = 0; i < ret->datalen; i++) {
321                         ret->data[i] = java_elems[i];
322                 }
323         }
324         return (uint64_t)ret;
325 }
326 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
327         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
328         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
329         return ret;
330 }
331 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}int8_tArray  __attribute__((visibility("default"))) TS_TxOut_get_script_pubkey(uint32_t thing) {
332         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
333         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
334         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
335         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
336         CVec_u8Z_free(ret_var);
337         return ret_arr;
338 }
339
340 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}int64_t  __attribute__((visibility("default"))) TS_TxOut_get_value(uint32_t thing) {
341         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
342         int64_t ret_val = TxOut_get_value(thing_conv);
343         return ret_val;
344 }
345
346 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_result_ok(uint32_t arg) {
347         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
348 }
349 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
350         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
351         CHECK(val->result_ok);
352         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
353         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
354         return res_arr;
355 }
356 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
357         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
358         CHECK(!val->result_ok);
359         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
360         return err_conv;
361 }
362 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_result_ok(uint32_t arg) {
363         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
364 }
365 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
366         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
367         CHECK(val->result_ok);
368         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
369         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
370         return res_arr;
371 }
372 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
373         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
374         CHECK(!val->result_ok);
375         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
376         return err_conv;
377 }
378 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_result_ok(uint32_t arg) {
379         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
380 }
381 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
382         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
383         CHECK(val->result_ok);
384         LDKTxCreationKeys res_var = (*val->contents.result);
385         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
386         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
387         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
388         return res_ref;
389 }
390 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
391         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
392         CHECK(!val->result_ok);
393         LDKDecodeError err_var = (*val->contents.err);
394         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
395         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
396         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
397         return err_ref;
398 }
399 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
400         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
401 }
402 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
403         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
404         CHECK(val->result_ok);
405         LDKChannelPublicKeys res_var = (*val->contents.result);
406         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
407         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
408         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
409         return res_ref;
410 }
411 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
412         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
413         CHECK(!val->result_ok);
414         LDKDecodeError err_var = (*val->contents.err);
415         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
416         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
417         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
418         return err_ref;
419 }
420 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
421         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
422 }
423 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
424         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
425         CHECK(val->result_ok);
426         LDKTxCreationKeys res_var = (*val->contents.result);
427         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
428         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
429         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
430         return res_ref;
431 }
432 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
433         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
434         CHECK(!val->result_ok);
435         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
436         return err_conv;
437 }
438 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u32Z_ref_from_ptr(uint32_t ptr) {
439         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
440         switch(obj->tag) {
441                 case LDKCOption_u32Z_Some: {
442                         return 0 /* LDKCOption_u32Z - Some */; (void) obj->some;
443                 }
444                 case LDKCOption_u32Z_None: {
445                         return 0 /* LDKCOption_u32Z - None */;
446                 }
447                 default: abort();
448         }
449 }
450 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_result_ok(uint32_t arg) {
451         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
452 }
453 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
454         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
455         CHECK(val->result_ok);
456         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
457         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
458         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
459         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
460         return res_ref;
461 }
462 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
463         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
464         CHECK(!val->result_ok);
465         LDKDecodeError err_var = (*val->contents.err);
466         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
467         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
468         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
469         return err_ref;
470 }
471 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
472         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
473 }
474 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
475         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
476         CHECK(val->result_ok);
477         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
478         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
479         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
480         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
481         return res_ref;
482 }
483 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
484         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
485         CHECK(!val->result_ok);
486         LDKDecodeError err_var = (*val->contents.err);
487         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
488         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
489         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
490         return err_ref;
491 }
492 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
493         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
494 }
495 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
496         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
497         CHECK(val->result_ok);
498         LDKChannelTransactionParameters res_var = (*val->contents.result);
499         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
500         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
501         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
502         return res_ref;
503 }
504 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
505         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
506         CHECK(!val->result_ok);
507         LDKDecodeError err_var = (*val->contents.err);
508         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
509         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
510         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
511         return err_ref;
512 }
513 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
514         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
515 }
516 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
517         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
518         CHECK(val->result_ok);
519         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
520         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
521         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
522         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
523         return res_ref;
524 }
525 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
526         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
527         CHECK(!val->result_ok);
528         LDKDecodeError err_var = (*val->contents.err);
529         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
530         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
531         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
532         return err_ref;
533 }
534 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
535         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
536 }
537 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
538         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
539         CHECK(val->result_ok);
540         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
541         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
542         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
543         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
544         return res_ref;
545 }
546 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
547         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
548         CHECK(!val->result_ok);
549         LDKDecodeError err_var = (*val->contents.err);
550         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
551         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
552         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
553         return err_ref;
554 }
555 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_result_ok(uint32_t arg) {
556         return ((LDKCResult_TrustedClosingTransactionNoneZ*)arg)->result_ok;
557 }
558 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t arg) {
559         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
560         CHECK(val->result_ok);
561         LDKTrustedClosingTransaction res_var = (*val->contents.result);
562         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
563         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
564         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
565         return res_ref;
566 }
567 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_err(uint32_t arg) {
568         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
569         CHECK(!val->result_ok);
570         return *val->contents.err;
571 }
572 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
573         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
574 }
575 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
576         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
577         CHECK(val->result_ok);
578         LDKCommitmentTransaction res_var = (*val->contents.result);
579         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
580         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
581         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
582         return res_ref;
583 }
584 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
585         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
586         CHECK(!val->result_ok);
587         LDKDecodeError err_var = (*val->contents.err);
588         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
589         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
590         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
591         return err_ref;
592 }
593 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
594         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
595 }
596 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
597         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
598         CHECK(val->result_ok);
599         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
600         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
601         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
602         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
603         return res_ref;
604 }
605 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
606         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
607         CHECK(!val->result_ok);
608         return *val->contents.err;
609 }
610 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
611         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
612 }
613 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
614         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
615         CHECK(val->result_ok);
616         LDKCVec_SignatureZ res_var = (*val->contents.result);
617         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
618         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
619         for (size_t m = 0; m < res_var.datalen; m++) {
620                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
621                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
622                 res_arr_ptr[m] = res_conv_12_arr;
623         }
624         return res_arr;
625 }
626 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
627         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
628         CHECK(!val->result_ok);
629         return *val->contents.err;
630 }
631 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_result_ok(uint32_t arg) {
632         return ((LDKCResult_ShutdownScriptDecodeErrorZ*)arg)->result_ok;
633 }
634 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t arg) {
635         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
636         CHECK(val->result_ok);
637         LDKShutdownScript res_var = (*val->contents.result);
638         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
639         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
640         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
641         return res_ref;
642 }
643 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t arg) {
644         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
645         CHECK(!val->result_ok);
646         LDKDecodeError err_var = (*val->contents.err);
647         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
648         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
649         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
650         return err_ref;
651 }
652 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_result_ok(uint32_t arg) {
653         return ((LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)arg)->result_ok;
654 }
655 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t arg) {
656         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
657         CHECK(val->result_ok);
658         LDKShutdownScript res_var = (*val->contents.result);
659         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
660         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
661         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
662         return res_ref;
663 }
664 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t arg) {
665         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
666         CHECK(!val->result_ok);
667         LDKInvalidShutdownScript err_var = (*val->contents.err);
668         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
669         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
670         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
671         return err_ref;
672 }
673 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_result_ok(uint32_t arg) {
674         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
675 }
676 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_ok(uint32_t arg) {
677         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
678         CHECK(val->result_ok);
679         return *val->contents.result;
680 }
681 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_err(uint32_t arg) {
682         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
683         CHECK(!val->result_ok);
684         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
685         return err_conv;
686 }
687 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_result_ok(uint32_t arg) {
688         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
689 }
690 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_ok(uint32_t arg) {
691         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
692         CHECK(val->result_ok);
693         LDKRouteHop res_var = (*val->contents.result);
694         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
695         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
696         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
697         return res_ref;
698 }
699 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_err(uint32_t arg) {
700         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
701         CHECK(!val->result_ok);
702         LDKDecodeError err_var = (*val->contents.err);
703         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
704         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
705         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
706         return err_ref;
707 }
708 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
709         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
710         ret->datalen = *((uint32_t*)elems);
711         if (ret->datalen == 0) {
712                 ret->data = NULL;
713         } else {
714                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
715                 uint32_t *java_elems = (uint32_t*)(elems + 4);
716                 for (size_t i = 0; i < ret->datalen; i++) {
717                         uint32_t arr_elem = java_elems[i];
718                         LDKRouteHop arr_elem_conv;
719                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
720                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
721                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
722                         ret->data[i] = arr_elem_conv;
723                 }
724         }
725         return (uint64_t)ret;
726 }
727 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
728         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
729         for (size_t i = 0; i < ret.datalen; i++) {
730                 ret.data[i] = RouteHop_clone(&orig->data[i]);
731         }
732         return ret;
733 }
734 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
735         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
736         for (size_t i = 0; i < ret.datalen; i++) {
737                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
738         }
739         return ret;
740 }
741 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
742         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
743 }
744 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
745         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
746         CHECK(val->result_ok);
747         LDKRoute res_var = (*val->contents.result);
748         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
749         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
750         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
751         return res_ref;
752 }
753 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
754         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
755         CHECK(!val->result_ok);
756         LDKDecodeError err_var = (*val->contents.err);
757         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
758         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
759         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
760         return err_ref;
761 }
762 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
763         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
764         switch(obj->tag) {
765                 case LDKCOption_u64Z_Some: {
766                         return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
767                 }
768                 case LDKCOption_u64Z_None: {
769                         return 0 /* LDKCOption_u64Z - None */;
770                 }
771                 default: abort();
772         }
773 }
774 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
775         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
776         ret->datalen = *((uint32_t*)elems);
777         if (ret->datalen == 0) {
778                 ret->data = NULL;
779         } else {
780                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
781                 uint32_t *java_elems = (uint32_t*)(elems + 4);
782                 for (size_t i = 0; i < ret->datalen; i++) {
783                         uint32_t arr_elem = java_elems[i];
784                         LDKChannelDetails arr_elem_conv;
785                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
786                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
787                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
788                         ret->data[i] = arr_elem_conv;
789                 }
790         }
791         return (uint64_t)ret;
792 }
793 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
794         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
795         for (size_t i = 0; i < ret.datalen; i++) {
796                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
797         }
798         return ret;
799 }
800 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
801         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
802         ret->datalen = *((uint32_t*)elems);
803         if (ret->datalen == 0) {
804                 ret->data = NULL;
805         } else {
806                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
807                 uint32_t *java_elems = (uint32_t*)(elems + 4);
808                 for (size_t i = 0; i < ret->datalen; i++) {
809                         uint32_t arr_elem = java_elems[i];
810                         LDKRouteHint arr_elem_conv;
811                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
812                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
813                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
814                         ret->data[i] = arr_elem_conv;
815                 }
816         }
817         return (uint64_t)ret;
818 }
819 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
820         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
821         for (size_t i = 0; i < ret.datalen; i++) {
822                 ret.data[i] = RouteHint_clone(&orig->data[i]);
823         }
824         return ret;
825 }
826 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
827         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
828 }
829 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
830         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
831         CHECK(val->result_ok);
832         LDKRoute res_var = (*val->contents.result);
833         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
834         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
835         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
836         return res_ref;
837 }
838 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
839         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
840         CHECK(!val->result_ok);
841         LDKLightningError err_var = (*val->contents.err);
842         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
843         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
844         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
845         return err_ref;
846 }
847 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
848         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
849 }
850 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
851         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
852         CHECK(val->result_ok);
853         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
854         return (uint64_t)res_ref;
855 }
856 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
857         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
858         CHECK(!val->result_ok);
859         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
860         return err_conv;
861 }
862 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
863         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
864         ret->a = a;
865         LDKTransaction b_ref;
866         b_ref.datalen = *((uint32_t*)b);
867         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
868         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
869         b_ref.data_is_owned = false;
870         ret->b = b_ref;
871         return (uint64_t)ret;
872 }
873 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
874         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
875         return tuple->a;
876 }
877 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
878         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
879         LDKTransaction b_var = tuple->b;
880         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
881         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
882         return b_arr;
883 }
884 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
885         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
886         ret->datalen = *((uint32_t*)elems);
887         if (ret->datalen == 0) {
888                 ret->data = NULL;
889         } else {
890                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
891                 uint32_t *java_elems = (uint32_t*)(elems + 4);
892                 for (size_t i = 0; i < ret->datalen; i++) {
893                         uint32_t arr_elem = java_elems[i];
894                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
895                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
896                         ret->data[i] = arr_elem_conv;
897                 }
898         }
899         return (uint64_t)ret;
900 }
901 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
902         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
903         for (size_t i = 0; i < ret.datalen; i++) {
904                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
905         }
906         return ret;
907 }
908 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
909         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
910         for (size_t i = 0; i < ret.datalen; i++) {
911                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
912         }
913         return ret;
914 }
915 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
916         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
917 }
918 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
919         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
920         CHECK(val->result_ok);
921         return *val->contents.result;
922 }
923 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
924         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
925         CHECK(!val->result_ok);
926         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
927         return err_conv;
928 }
929 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
930         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
931         switch(obj->tag) {
932                 case LDKMonitorEvent_HTLCEvent: {
933                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
934                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
935                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
936                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
937                         return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
938                 }
939                 case LDKMonitorEvent_CommitmentTxConfirmed: {
940                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
941                         CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
942                         CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
943                         uint64_t commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
944                         return 0 /* LDKMonitorEvent - CommitmentTxConfirmed */; (void) commitment_tx_confirmed_ref;
945                 }
946                 default: abort();
947         }
948 }
949 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
950         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
951         ret->datalen = *((uint32_t*)elems);
952         if (ret->datalen == 0) {
953                 ret->data = NULL;
954         } else {
955                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
956                 uint32_t *java_elems = (uint32_t*)(elems + 4);
957                 for (size_t i = 0; i < ret->datalen; i++) {
958                         uint32_t arr_elem = java_elems[i];
959                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
960                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
961                         ret->data[i] = arr_elem_conv;
962                 }
963         }
964         return (uint64_t)ret;
965 }
966 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
967         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
968         for (size_t i = 0; i < ret.datalen; i++) {
969                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
970         }
971         return ret;
972 }
973 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(uint32_t ptr) {
974         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
975         switch(obj->tag) {
976                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
977                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
978                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - Some */; (void) some_ref;
979                 }
980                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
981                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - None */;
982                 }
983                 default: abort();
984         }
985 }
986 uint32_t __attribute__((visibility("default"))) TS_LDKNetworkUpdate_ref_from_ptr(uint32_t ptr) {
987         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
988         switch(obj->tag) {
989                 case LDKNetworkUpdate_ChannelUpdateMessage: {
990                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
991                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
992                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
993                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
994                         return 0 /* LDKNetworkUpdate - ChannelUpdateMessage */; (void) msg_ref;
995                 }
996                 case LDKNetworkUpdate_ChannelClosed: {
997                         return 0 /* LDKNetworkUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
998                 }
999                 case LDKNetworkUpdate_NodeFailure: {
1000                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1001                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
1002                         return 0 /* LDKNetworkUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
1003                 }
1004                 default: abort();
1005         }
1006 }
1007 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_NetworkUpdateZ_ref_from_ptr(uint32_t ptr) {
1008         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1009         switch(obj->tag) {
1010                 case LDKCOption_NetworkUpdateZ_Some: {
1011                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1012                         return 0 /* LDKCOption_NetworkUpdateZ - Some */; (void) some_ref;
1013                 }
1014                 case LDKCOption_NetworkUpdateZ_None: {
1015                         return 0 /* LDKCOption_NetworkUpdateZ - None */;
1016                 }
1017                 default: abort();
1018         }
1019 }
1020 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
1021         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1022         switch(obj->tag) {
1023                 case LDKSpendableOutputDescriptor_StaticOutput: {
1024                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1025                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1026                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1027                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1028                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1029                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
1030                 }
1031                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1032                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1033                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1034                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1035                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1036                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
1037                 }
1038                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1039                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1040                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1041                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1042                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1043                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
1044                 }
1045                 default: abort();
1046         }
1047 }
1048 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
1049         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1050         ret->datalen = *((uint32_t*)elems);
1051         if (ret->datalen == 0) {
1052                 ret->data = NULL;
1053         } else {
1054                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1055                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1056                 for (size_t i = 0; i < ret->datalen; i++) {
1057                         uint32_t arr_elem = java_elems[i];
1058                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1059                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1060                         ret->data[i] = arr_elem_conv;
1061                 }
1062         }
1063         return (uint64_t)ret;
1064 }
1065 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1066         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1067         for (size_t i = 0; i < ret.datalen; i++) {
1068                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1069         }
1070         return ret;
1071 }
1072 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
1073         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1074         switch(obj->tag) {
1075                 case LDKErrorAction_DisconnectPeer: {
1076                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1077                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1078                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1079                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1080                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
1081                 }
1082                 case LDKErrorAction_IgnoreError: {
1083                         return 0 /* LDKErrorAction - IgnoreError */;
1084                 }
1085                 case LDKErrorAction_IgnoreAndLog: {
1086                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1087                         return 0 /* LDKErrorAction - IgnoreAndLog */; (void) ignore_and_log_conv;
1088                 }
1089                 case LDKErrorAction_SendErrorMessage: {
1090                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1091                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1092                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1093                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1094                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
1095                 }
1096                 default: abort();
1097         }
1098 }
1099 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
1100         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1101         switch(obj->tag) {
1102                 case LDKMessageSendEvent_SendAcceptChannel: {
1103                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1104                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
1105                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1106                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1107                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1108                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1109                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
1110                 }
1111                 case LDKMessageSendEvent_SendOpenChannel: {
1112                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1113                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
1114                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1115                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1116                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1117                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1118                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
1119                 }
1120                 case LDKMessageSendEvent_SendFundingCreated: {
1121                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1122                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
1123                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1124                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1125                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1126                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1127                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
1128                 }
1129                 case LDKMessageSendEvent_SendFundingSigned: {
1130                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1131                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
1132                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1133                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1134                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1135                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1136                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
1137                 }
1138                 case LDKMessageSendEvent_SendFundingLocked: {
1139                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1140                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
1141                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1142                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1143                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1144                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1145                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
1146                 }
1147                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1148                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1149                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
1150                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1151                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1152                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1153                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1154                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
1155                 }
1156                 case LDKMessageSendEvent_UpdateHTLCs: {
1157                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1158                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
1159                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1160                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1161                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1162                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1163                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
1164                 }
1165                 case LDKMessageSendEvent_SendRevokeAndACK: {
1166                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1167                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
1168                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1169                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1170                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1171                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1172                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
1173                 }
1174                 case LDKMessageSendEvent_SendClosingSigned: {
1175                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1176                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
1177                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1178                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1179                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1180                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1181                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
1182                 }
1183                 case LDKMessageSendEvent_SendShutdown: {
1184                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1185                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
1186                         LDKShutdown msg_var = obj->send_shutdown.msg;
1187                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1188                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1189                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1190                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
1191                 }
1192                 case LDKMessageSendEvent_SendChannelReestablish: {
1193                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1194                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
1195                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1196                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1197                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1198                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1199                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
1200                 }
1201                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1202                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1203                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1204                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1205                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1206                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1207                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1208                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1209                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1210                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
1211                 }
1212                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1213                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1214                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1215                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1216                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1217                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
1218                 }
1219                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1220                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1221                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1222                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1223                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1224                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
1225                 }
1226                 case LDKMessageSendEvent_SendChannelUpdate: {
1227                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1228                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_update.node_id.compressed_form, 33);
1229                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1230                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1231                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1232                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1233                         return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref;
1234                 }
1235                 case LDKMessageSendEvent_HandleError: {
1236                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1237                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
1238                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1239                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
1240                 }
1241                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1242                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1243                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
1244                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1245                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1246                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1247                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1248                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
1249                 }
1250                 case LDKMessageSendEvent_SendShortIdsQuery: {
1251                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1252                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
1253                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1254                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1255                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1256                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1257                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
1258                 }
1259                 case LDKMessageSendEvent_SendReplyChannelRange: {
1260                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1261                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
1262                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1263                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1264                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1265                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1266                         return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
1267                 }
1268                 default: abort();
1269         }
1270 }
1271 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
1272         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1273         ret->datalen = *((uint32_t*)elems);
1274         if (ret->datalen == 0) {
1275                 ret->data = NULL;
1276         } else {
1277                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1278                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1279                 for (size_t i = 0; i < ret->datalen; i++) {
1280                         uint32_t arr_elem = java_elems[i];
1281                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1282                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1283                         ret->data[i] = arr_elem_conv;
1284                 }
1285         }
1286         return (uint64_t)ret;
1287 }
1288 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1289         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1290         for (size_t i = 0; i < ret.datalen; i++) {
1291                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1292         }
1293         return ret;
1294 }
1295 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1296         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1297 }
1298 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1299         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1300         CHECK(val->result_ok);
1301         LDKInitFeatures res_var = (*val->contents.result);
1302         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1303         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1304         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1305         return res_ref;
1306 }
1307 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1308         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1309         CHECK(!val->result_ok);
1310         LDKDecodeError err_var = (*val->contents.err);
1311         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1312         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1313         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1314         return err_ref;
1315 }
1316 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1317         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1318 }
1319 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1320         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1321         CHECK(val->result_ok);
1322         LDKNodeFeatures res_var = (*val->contents.result);
1323         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1324         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1325         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1326         return res_ref;
1327 }
1328 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1329         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1330         CHECK(!val->result_ok);
1331         LDKDecodeError err_var = (*val->contents.err);
1332         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1333         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1334         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1335         return err_ref;
1336 }
1337 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1338         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1339 }
1340 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1341         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1342         CHECK(val->result_ok);
1343         LDKChannelFeatures res_var = (*val->contents.result);
1344         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1345         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1346         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1347         return res_ref;
1348 }
1349 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1350         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1351         CHECK(!val->result_ok);
1352         LDKDecodeError err_var = (*val->contents.err);
1353         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1354         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1355         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1356         return err_ref;
1357 }
1358 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1359         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1360 }
1361 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1362         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1363         CHECK(val->result_ok);
1364         LDKInvoiceFeatures res_var = (*val->contents.result);
1365         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1366         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1367         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1368         return res_ref;
1369 }
1370 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1371         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1372         CHECK(!val->result_ok);
1373         LDKDecodeError err_var = (*val->contents.err);
1374         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1375         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1376         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1377         return err_ref;
1378 }
1379 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1380         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1381 }
1382 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1383         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1384         CHECK(val->result_ok);
1385         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1386         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1387         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1388         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1389         return res_ref;
1390 }
1391 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1392         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1393         CHECK(!val->result_ok);
1394         LDKDecodeError err_var = (*val->contents.err);
1395         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1396         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1397         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1398         return err_ref;
1399 }
1400 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1401         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1402 }
1403 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1404         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1405         CHECK(val->result_ok);
1406         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1407         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1408         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1409         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1410         return res_ref;
1411 }
1412 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1413         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1414         CHECK(!val->result_ok);
1415         LDKDecodeError err_var = (*val->contents.err);
1416         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1417         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1418         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1419         return err_ref;
1420 }
1421 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1422         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1423 }
1424 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1425         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1426         CHECK(val->result_ok);
1427         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1428         return res_ref;
1429 }
1430 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1431         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1432         CHECK(!val->result_ok);
1433         LDKDecodeError err_var = (*val->contents.err);
1434         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1435         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1436         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1437         return err_ref;
1438 }
1439 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_result_ok(uint32_t arg) {
1440         return ((LDKCResult_NoneNoneZ*)arg)->result_ok;
1441 }
1442 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_ok(uint32_t arg) {
1443         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
1444         CHECK(val->result_ok);
1445         return *val->contents.result;
1446 }
1447 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_err(uint32_t arg) {
1448         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
1449         CHECK(!val->result_ok);
1450         return *val->contents.err;
1451 }
1452 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
1453         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1454         LDKSignature a_ref;
1455         CHECK(*((uint32_t*)a) == 64);
1456         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
1457         ret->a = a_ref;
1458         LDKCVec_SignatureZ b_constr;
1459         b_constr.datalen = *((uint32_t*)b);
1460         if (b_constr.datalen > 0)
1461                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1462         else
1463                 b_constr.data = NULL;
1464         int8_tArray* b_vals = (int8_tArray*)(b + 4);
1465         for (size_t m = 0; m < b_constr.datalen; m++) {
1466                 int8_tArray b_conv_12 = b_vals[m];
1467                 LDKSignature b_conv_12_ref;
1468                 CHECK(*((uint32_t*)b_conv_12) == 64);
1469                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
1470                 b_constr.data[m] = b_conv_12_ref;
1471         }
1472         ret->b = b_constr;
1473         return (uint64_t)ret;
1474 }
1475 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
1476         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1477         int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1478         memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
1479         return a_arr;
1480 }
1481 ptrArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
1482         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1483         LDKCVec_SignatureZ b_var = tuple->b;
1484         ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1485         int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
1486         for (size_t m = 0; m < b_var.datalen; m++) {
1487                 int8_tArray b_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1488                 memcpy((uint8_t*)(b_conv_12_arr + 4), b_var.data[m].compact_form, 64);
1489                 b_arr_ptr[m] = b_conv_12_arr;
1490         }
1491         return b_arr;
1492 }
1493 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
1494         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1495 }
1496 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1497         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1498         CHECK(val->result_ok);
1499         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
1500         return res_ref;
1501 }
1502 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1503         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1504         CHECK(!val->result_ok);
1505         return *val->contents.err;
1506 }
1507 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
1508         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1509 }
1510 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1511         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1512         CHECK(val->result_ok);
1513         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1514         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1515         return res_arr;
1516 }
1517 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1518         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1519         CHECK(!val->result_ok);
1520         return *val->contents.err;
1521 }
1522 typedef struct LDKBaseSign_JCalls {
1523         atomic_size_t refcnt;
1524         uint32_t get_per_commitment_point_meth;
1525         uint32_t release_commitment_secret_meth;
1526         uint32_t validate_holder_commitment_meth;
1527         uint32_t channel_keys_id_meth;
1528         uint32_t sign_counterparty_commitment_meth;
1529         uint32_t validate_counterparty_revocation_meth;
1530         uint32_t sign_holder_commitment_and_htlcs_meth;
1531         uint32_t sign_justice_revoked_output_meth;
1532         uint32_t sign_justice_revoked_htlc_meth;
1533         uint32_t sign_counterparty_htlc_transaction_meth;
1534         uint32_t sign_closing_transaction_meth;
1535         uint32_t sign_channel_announcement_meth;
1536         uint32_t ready_channel_meth;
1537 } LDKBaseSign_JCalls;
1538 static void LDKBaseSign_JCalls_free(void* this_arg) {
1539         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1540         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1541                 js_free(j_calls->get_per_commitment_point_meth);
1542                 js_free(j_calls->release_commitment_secret_meth);
1543                 js_free(j_calls->validate_holder_commitment_meth);
1544                 js_free(j_calls->channel_keys_id_meth);
1545                 js_free(j_calls->sign_counterparty_commitment_meth);
1546                 js_free(j_calls->validate_counterparty_revocation_meth);
1547                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1548                 js_free(j_calls->sign_justice_revoked_output_meth);
1549                 js_free(j_calls->sign_justice_revoked_htlc_meth);
1550                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1551                 js_free(j_calls->sign_closing_transaction_meth);
1552                 js_free(j_calls->sign_channel_announcement_meth);
1553                 js_free(j_calls->ready_channel_meth);
1554                 FREE(j_calls);
1555         }
1556 }
1557 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1558         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1559         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1560         LDKPublicKey ret_ref;
1561         CHECK(*((uint32_t*)ret) == 33);
1562         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1563         return ret_ref;
1564 }
1565 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1566         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1567         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1568         LDKThirtyTwoBytes ret_ref;
1569         CHECK(*((uint32_t*)ret) == 32);
1570         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1571         return ret_ref;
1572 }
1573 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
1574         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1575         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
1576         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
1577         CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1578         CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1579         uint64_t holder_tx_ref = (uint64_t)holder_tx_var.inner;
1580         if (holder_tx_var.is_owned) {
1581                 holder_tx_ref |= 1;
1582         }
1583         uint32_t ret = js_invoke_function_1(j_calls->validate_holder_commitment_meth, holder_tx_ref);
1584         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1);
1585         ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
1586         return ret_conv;
1587 }
1588 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1589         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1590         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1591         LDKThirtyTwoBytes ret_ref;
1592         CHECK(*((uint32_t*)ret) == 32);
1593         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1594         return ret_ref;
1595 }
1596 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1597         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1598         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1599         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1600         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1601         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1602         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1603         if (commitment_tx_var.is_owned) {
1604                 commitment_tx_ref |= 1;
1605         }
1606         uint32_t ret = js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1607         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1608         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1609         return ret_conv;
1610 }
1611 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
1612         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1613         int8_tArray secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1614         memcpy((uint8_t*)(secret_arr + 4), *secret, 32);
1615         uint32_t ret = js_invoke_function_2(j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
1616         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1);
1617         ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
1618         return ret_conv;
1619 }
1620 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1621         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1622         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1623         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1624         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1625         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1626         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1627         if (commitment_tx_var.is_owned) {
1628                 commitment_tx_ref |= 1;
1629         }
1630         uint32_t ret = js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1631         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1632         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1633         return ret_conv;
1634 }
1635 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]) {
1636         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1637         LDKTransaction justice_tx_var = justice_tx;
1638         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1639         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1640         Transaction_free(justice_tx_var);
1641         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1642         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1643         uint32_t ret = js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
1644         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1645         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1646         return ret_conv;
1647 }
1648 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) {
1649         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1650         LDKTransaction justice_tx_var = justice_tx;
1651         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1652         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1653         Transaction_free(justice_tx_var);
1654         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1655         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1656         LDKHTLCOutputInCommitment htlc_var = *htlc;
1657         htlc_var = HTLCOutputInCommitment_clone(htlc);
1658         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1659         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1660         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1661         if (htlc_var.is_owned) {
1662                 htlc_ref |= 1;
1663         }
1664         uint32_t ret = js_invoke_function_5(j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
1665         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1666         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1667         return ret_conv;
1668 }
1669 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) {
1670         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1671         LDKTransaction htlc_tx_var = htlc_tx;
1672         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1673         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1674         Transaction_free(htlc_tx_var);
1675         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1676         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1677         LDKHTLCOutputInCommitment htlc_var = *htlc;
1678         htlc_var = HTLCOutputInCommitment_clone(htlc);
1679         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1680         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1681         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1682         if (htlc_var.is_owned) {
1683                 htlc_ref |= 1;
1684         }
1685         uint32_t ret = js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
1686         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1687         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1688         return ret_conv;
1689 }
1690 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
1691         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1692         LDKClosingTransaction closing_tx_var = *closing_tx;
1693         // Warning: we may need a move here but no clone is available for LDKClosingTransaction
1694         CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1695         CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1696         uint64_t closing_tx_ref = (uint64_t)closing_tx_var.inner;
1697         if (closing_tx_var.is_owned) {
1698                 closing_tx_ref |= 1;
1699         }
1700         uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_ref);
1701         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1702         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1703         return ret_conv;
1704 }
1705 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1706         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1707         LDKUnsignedChannelAnnouncement msg_var = *msg;
1708         msg_var = UnsignedChannelAnnouncement_clone(msg);
1709         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1710         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1711         uint64_t msg_ref = (uint64_t)msg_var.inner;
1712         if (msg_var.is_owned) {
1713                 msg_ref |= 1;
1714         }
1715         uint32_t ret = js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1716         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1717         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1718         return ret_conv;
1719 }
1720 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1721         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1722         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1723         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1724         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1725         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1726         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
1727         if (channel_parameters_var.is_owned) {
1728                 channel_parameters_ref |= 1;
1729         }
1730         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1731 }
1732 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
1733         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
1734         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1735 }
1736 static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1737         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
1738         atomic_init(&calls->refcnt, 1);
1739         //TODO: Assign calls->o from o
1740
1741         LDKChannelPublicKeys pubkeys_conv;
1742         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1743         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1744         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1745
1746         LDKBaseSign ret = {
1747                 .this_arg = (void*) calls,
1748                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
1749                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
1750                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
1751                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
1752                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
1753                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
1754                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
1755                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
1756                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
1757                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
1758                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
1759                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
1760                 .ready_channel = ready_channel_LDKBaseSign_jcall,
1761                 .free = LDKBaseSign_JCalls_free,
1762                 .pubkeys = pubkeys_conv,
1763                 .set_pubkeys = NULL,
1764         };
1765         return ret;
1766 }
1767 long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1768         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
1769         *res_ptr = LDKBaseSign_init(o, pubkeys);
1770         return (long)res_ptr;
1771 }
1772 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1773         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1774         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1775         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1776         return ret_arr;
1777 }
1778
1779 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1780         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1781         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1782         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1783         return ret_arr;
1784 }
1785
1786 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx) {
1787         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1788         LDKHolderCommitmentTransaction holder_tx_conv;
1789         holder_tx_conv.inner = (void*)(holder_tx & (~1));
1790         holder_tx_conv.is_owned = false;
1791         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
1792         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
1793         return (uint64_t)ret_conv;
1794 }
1795
1796 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
1797         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1798         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1799         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
1800         return ret_arr;
1801 }
1802
1803 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1804         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1805         LDKCommitmentTransaction commitment_tx_conv;
1806         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1807         commitment_tx_conv.is_owned = false;
1808         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1809         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1810         return (uint64_t)ret_conv;
1811 }
1812
1813 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_counterparty_revocation(uint32_t this_arg, int64_t idx, int8_tArray secret) {
1814         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1815         unsigned char secret_arr[32];
1816         CHECK(*((uint32_t*)secret) == 32);
1817         memcpy(secret_arr, (uint8_t*)(secret + 4), 32);
1818         unsigned char (*secret_ref)[32] = &secret_arr;
1819         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
1820         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
1821         return (uint64_t)ret_conv;
1822 }
1823
1824 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
1825         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1826         LDKHolderCommitmentTransaction commitment_tx_conv;
1827         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1828         commitment_tx_conv.is_owned = false;
1829         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1830         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1831         return (uint64_t)ret_conv;
1832 }
1833
1834 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) {
1835         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1836         LDKTransaction justice_tx_ref;
1837         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1838         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1839         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1840         justice_tx_ref.data_is_owned = true;
1841         unsigned char per_commitment_key_arr[32];
1842         CHECK(*((uint32_t*)per_commitment_key) == 32);
1843         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1844         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1845         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1846         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
1847         return (uint64_t)ret_conv;
1848 }
1849
1850 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) {
1851         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1852         LDKTransaction justice_tx_ref;
1853         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1854         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1855         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1856         justice_tx_ref.data_is_owned = true;
1857         unsigned char per_commitment_key_arr[32];
1858         CHECK(*((uint32_t*)per_commitment_key) == 32);
1859         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1860         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1861         LDKHTLCOutputInCommitment htlc_conv;
1862         htlc_conv.inner = (void*)(htlc & (~1));
1863         htlc_conv.is_owned = false;
1864         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1865         *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);
1866         return (uint64_t)ret_conv;
1867 }
1868
1869 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) {
1870         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1871         LDKTransaction htlc_tx_ref;
1872         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
1873         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1874         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
1875         htlc_tx_ref.data_is_owned = true;
1876         LDKPublicKey per_commitment_point_ref;
1877         CHECK(*((uint32_t*)per_commitment_point) == 33);
1878         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
1879         LDKHTLCOutputInCommitment htlc_conv;
1880         htlc_conv.inner = (void*)(htlc & (~1));
1881         htlc_conv.is_owned = false;
1882         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1883         *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);
1884         return (uint64_t)ret_conv;
1885 }
1886
1887 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
1888         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1889         LDKClosingTransaction closing_tx_conv;
1890         closing_tx_conv.inner = (void*)(closing_tx & (~1));
1891         closing_tx_conv.is_owned = false;
1892         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1893         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
1894         return (uint64_t)ret_conv;
1895 }
1896
1897 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
1898         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1899         LDKUnsignedChannelAnnouncement msg_conv;
1900         msg_conv.inner = (void*)(msg & (~1));
1901         msg_conv.is_owned = false;
1902         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1903         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1904         return (uint64_t)ret_conv;
1905 }
1906
1907 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
1908         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1909         LDKChannelTransactionParameters channel_parameters_conv;
1910         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1911         channel_parameters_conv.is_owned = false;
1912         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1913 }
1914
1915 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
1916         if (this_arg->set_pubkeys != NULL)
1917                 this_arg->set_pubkeys(this_arg);
1918         return this_arg->pubkeys;
1919 }
1920 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
1921         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1922         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
1923         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1924         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1925         uint64_t ret_ref = (uint64_t)ret_var.inner;
1926         if (ret_var.is_owned) {
1927                 ret_ref |= 1;
1928         }
1929         return ret_ref;
1930 }
1931
1932 typedef struct LDKSign_JCalls {
1933         atomic_size_t refcnt;
1934         LDKBaseSign_JCalls* BaseSign;
1935         uint32_t write_meth;
1936 } LDKSign_JCalls;
1937 static void LDKSign_JCalls_free(void* this_arg) {
1938         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1939         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1940                 js_free(j_calls->write_meth);
1941                 FREE(j_calls);
1942         }
1943 }
1944 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
1945         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1946         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
1947         LDKCVec_u8Z ret_ref;
1948         ret_ref.datalen = *((uint32_t*)ret);
1949         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1950         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
1951         return ret_ref;
1952 }
1953 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
1954         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
1955         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1956         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
1957 }
1958 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
1959         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1960         atomic_init(&calls->refcnt, 1);
1961         //TODO: Assign calls->o from o
1962
1963         LDKChannelPublicKeys pubkeys_conv;
1964         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1965         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1966         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1967
1968         LDKSign ret = {
1969                 .this_arg = (void*) calls,
1970                 .write = write_LDKSign_jcall,
1971                 .cloned = LDKSign_JCalls_cloned,
1972                 .free = LDKSign_JCalls_free,
1973                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
1974         };
1975         calls->BaseSign = ret.BaseSign.this_arg;
1976         return ret;
1977 }
1978 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
1979         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
1980         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
1981         return (long)res_ptr;
1982 }
1983 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
1984         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1985         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1986         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1987         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
1988         CVec_u8Z_free(ret_var);
1989         return ret_arr;
1990 }
1991
1992 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
1993         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
1994 }
1995 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
1996         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
1997         CHECK(val->result_ok);
1998         LDKSign* res_ret =MALLOC(sizeof(LDKSign), "LDKSign");
1999         *res_ret = Sign_clone(&(*val->contents.result));
2000         return (uint64_t)res_ret;
2001 }
2002 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
2003         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2004         CHECK(!val->result_ok);
2005         LDKDecodeError err_var = (*val->contents.err);
2006         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2007         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2008         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2009         return err_ref;
2010 }
2011 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_result_ok(uint32_t arg) {
2012         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2013 }
2014 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_ok(uint32_t arg) {
2015         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2016         CHECK(val->result_ok);
2017         int8_tArray es_arr = init_arr(68, sizeof(uint8_t), "Native int8_tArray Bytes");
2018         memcpy((uint8_t*)(es_arr + 4), (*val->contents.result).serialized_form, 68);
2019         return es_arr;
2020 }
2021 void  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_err(uint32_t arg) {
2022         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2023         CHECK(!val->result_ok);
2024         return *val->contents.err;
2025 }
2026 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2027         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2028         for (size_t i = 0; i < ret.datalen; i++) {
2029                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2030         }
2031         return ret;
2032 }
2033 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
2034         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2035 }
2036 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
2037         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2038         CHECK(val->result_ok);
2039         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2040         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
2041         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
2042         for (size_t m = 0; m < res_var.datalen; m++) {
2043                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
2044                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2045                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
2046                 res_arr_ptr[m] = res_conv_12_arr;
2047         }
2048         return res_arr;
2049 }
2050 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
2051         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2052         CHECK(!val->result_ok);
2053         return *val->contents.err;
2054 }
2055 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
2056         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2057 }
2058 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
2059         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2060         CHECK(val->result_ok);
2061         LDKInMemorySigner res_var = (*val->contents.result);
2062         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2063         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2064         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2065         return res_ref;
2066 }
2067 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
2068         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2069         CHECK(!val->result_ok);
2070         LDKDecodeError err_var = (*val->contents.err);
2071         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2072         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2073         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2074         return err_ref;
2075 }
2076 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
2077         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2078         ret->datalen = *((uint32_t*)elems);
2079         if (ret->datalen == 0) {
2080                 ret->data = NULL;
2081         } else {
2082                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2083                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2084                 for (size_t i = 0; i < ret->datalen; i++) {
2085                         uint32_t arr_elem = java_elems[i];
2086                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2087                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2088                         ret->data[i] = arr_elem_conv;
2089                 }
2090         }
2091         return (uint64_t)ret;
2092 }
2093 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2094         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2095         for (size_t i = 0; i < ret.datalen; i++) {
2096                 ret.data[i] = TxOut_clone(&orig->data[i]);
2097         }
2098         return ret;
2099 }
2100 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
2101         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2102 }
2103 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
2104         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2105         CHECK(val->result_ok);
2106         LDKTransaction res_var = (*val->contents.result);
2107         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2108         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
2109         return res_arr;
2110 }
2111 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
2112         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2113         CHECK(!val->result_ok);
2114         return *val->contents.err;
2115 }
2116 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
2117         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2118         LDKThirtyTwoBytes a_ref;
2119         CHECK(*((uint32_t*)a) == 32);
2120         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2121         ret->a = a_ref;
2122         LDKChannelMonitor b_conv;
2123         b_conv.inner = (void*)(b & (~1));
2124         b_conv.is_owned = (b & 1) || (b == 0);
2125         b_conv = ChannelMonitor_clone(&b_conv);
2126         ret->b = b_conv;
2127         return (uint64_t)ret;
2128 }
2129 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
2130         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2131         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2132         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2133         return a_arr;
2134 }
2135 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
2136         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2137         LDKChannelMonitor b_var = tuple->b;
2138         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2139         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2140         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2141         return b_ref;
2142 }
2143 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_BlockHashChannelMonitorZZ_new(uint32_tArray elems) {
2144         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2145         ret->datalen = *((uint32_t*)elems);
2146         if (ret->datalen == 0) {
2147                 ret->data = NULL;
2148         } else {
2149                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2150                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2151                 for (size_t i = 0; i < ret->datalen; i++) {
2152                         uint32_t arr_elem = java_elems[i];
2153                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2154                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2155                         ret->data[i] = arr_elem_conv;
2156                 }
2157         }
2158         return (uint64_t)ret;
2159 }
2160 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(uint32_t arg) {
2161         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2162 }
2163 uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(uint32_t arg) {
2164         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2165         CHECK(val->result_ok);
2166         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2167         uint32_tArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2168         uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
2169         for (size_t m = 0; m < res_var.datalen; m++) {
2170                 uint64_t res_conv_38_ref = (uint64_t)(&res_var.data[m]) | 1;
2171                 res_arr_ptr[m] = res_conv_38_ref;
2172         }
2173         return res_arr;
2174 }
2175 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
2176         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2177         CHECK(!val->result_ok);
2178         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
2179         return err_conv;
2180 }
2181 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) {
2182         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2183         switch(obj->tag) {
2184                 case LDKCOption_u16Z_Some: {
2185                         return 0 /* LDKCOption_u16Z - Some */; (void) obj->some;
2186                 }
2187                 case LDKCOption_u16Z_None: {
2188                         return 0 /* LDKCOption_u16Z - None */;
2189                 }
2190                 default: abort();
2191         }
2192 }
2193 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2194         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2195         switch(obj->tag) {
2196                 case LDKAPIError_APIMisuseError: {
2197                         LDKStr err_str = obj->api_misuse_error.err;
2198                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2199                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_conv;
2200                 }
2201                 case LDKAPIError_FeeRateTooHigh: {
2202                         LDKStr err_str = obj->fee_rate_too_high.err;
2203                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2204                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_conv; (void) obj->fee_rate_too_high.feerate;
2205                 }
2206                 case LDKAPIError_RouteError: {
2207                         LDKStr err_str = obj->route_error.err;
2208                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2209                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2210                 }
2211                 case LDKAPIError_ChannelUnavailable: {
2212                         LDKStr err_str = obj->channel_unavailable.err;
2213                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2214                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_conv;
2215                 }
2216                 case LDKAPIError_MonitorUpdateFailed: {
2217                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2218                 }
2219                 case LDKAPIError_IncompatibleShutdownScript: {
2220                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
2221                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2222                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2223                         uint64_t script_ref = (uint64_t)script_var.inner & ~1;
2224                         return 0 /* LDKAPIError - IncompatibleShutdownScript */; (void) script_ref;
2225                 }
2226                 default: abort();
2227         }
2228 }
2229 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
2230         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2231 }
2232 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2233         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2234         CHECK(val->result_ok);
2235         return *val->contents.result;
2236 }
2237 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2238         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2239         CHECK(!val->result_ok);
2240         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2241         return err_ref;
2242 }
2243 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
2244         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2245         ret->datalen = *((uint32_t*)elems);
2246         if (ret->datalen == 0) {
2247                 ret->data = NULL;
2248         } else {
2249                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2250                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2251                 for (size_t i = 0; i < ret->datalen; i++) {
2252                         uint32_t arr_elem = java_elems[i];
2253                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2254                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2255                         ret->data[i] = arr_elem_conv;
2256                 }
2257         }
2258         return (uint64_t)ret;
2259 }
2260 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2261         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2262         for (size_t i = 0; i < ret.datalen; i++) {
2263                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2264         }
2265         return ret;
2266 }
2267 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
2268         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2269         ret->datalen = *((uint32_t*)elems);
2270         if (ret->datalen == 0) {
2271                 ret->data = NULL;
2272         } else {
2273                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2274                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2275                 for (size_t i = 0; i < ret->datalen; i++) {
2276                         uint32_t arr_elem = java_elems[i];
2277                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2278                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
2279                         ret->data[i] = arr_elem_conv;
2280                 }
2281         }
2282         return (uint64_t)ret;
2283 }
2284 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2285         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2286         for (size_t i = 0; i < ret.datalen; i++) {
2287                 ret.data[i] = APIError_clone(&orig->data[i]);
2288         }
2289         return ret;
2290 }
2291 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2292         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
2293         switch(obj->tag) {
2294                 case LDKPaymentSendFailure_ParameterError: {
2295                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
2296                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
2297                 }
2298                 case LDKPaymentSendFailure_PathParameterError: {
2299                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
2300                         uint32_tArray path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2301                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
2302                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
2303                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2304                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
2305                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
2306                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
2307                         }
2308                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
2309                 }
2310                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2311                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
2312                         uint32_tArray all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2313                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
2314                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
2315                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
2316                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
2317                         }
2318                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
2319                 }
2320                 case LDKPaymentSendFailure_PartialFailure: {
2321                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
2322                         uint32_tArray partial_failure_arr = init_arr(partial_failure_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2323                         uint32_t *partial_failure_arr_ptr = (uint32_t*)(partial_failure_arr + 4);
2324                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
2325                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2326                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
2327                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
2328                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
2329                         }
2330                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) partial_failure_arr;
2331                 }
2332                 default: abort();
2333         }
2334 }
2335 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
2336         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2337 }
2338 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2339         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2340         CHECK(val->result_ok);
2341         return *val->contents.result;
2342 }
2343 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2344         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2345         CHECK(!val->result_ok);
2346         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2347         return err_ref;
2348 }
2349 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentHashPaymentSendFailureZ_result_ok(uint32_t arg) {
2350         return ((LDKCResult_PaymentHashPaymentSendFailureZ*)arg)->result_ok;
2351 }
2352 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentHashPaymentSendFailureZ_get_ok(uint32_t arg) {
2353         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
2354         CHECK(val->result_ok);
2355         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2356         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2357         return res_arr;
2358 }
2359 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentHashPaymentSendFailureZ_get_err(uint32_t arg) {
2360         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
2361         CHECK(!val->result_ok);
2362         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2363         return err_ref;
2364 }
2365 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
2366         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2367         switch(obj->tag) {
2368                 case LDKNetAddress_IPv4: {
2369                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
2370                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
2371                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
2372                 }
2373                 case LDKNetAddress_IPv6: {
2374                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
2375                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
2376                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
2377                 }
2378                 case LDKNetAddress_OnionV2: {
2379                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
2380                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
2381                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
2382                 }
2383                 case LDKNetAddress_OnionV3: {
2384                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2385                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
2386                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
2387                 }
2388                 default: abort();
2389         }
2390 }
2391 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
2392         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
2393         ret->datalen = *((uint32_t*)elems);
2394         if (ret->datalen == 0) {
2395                 ret->data = NULL;
2396         } else {
2397                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
2398                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2399                 for (size_t i = 0; i < ret->datalen; i++) {
2400                         uint32_t arr_elem = java_elems[i];
2401                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
2402                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
2403                         ret->data[i] = arr_elem_conv;
2404                 }
2405         }
2406         return (uint64_t)ret;
2407 }
2408 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2409         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2410         for (size_t i = 0; i < ret.datalen; i++) {
2411                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2412         }
2413         return ret;
2414 }
2415 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
2416         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
2417         LDKThirtyTwoBytes a_ref;
2418         CHECK(*((uint32_t*)a) == 32);
2419         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2420         ret->a = a_ref;
2421         LDKThirtyTwoBytes b_ref;
2422         CHECK(*((uint32_t*)b) == 32);
2423         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2424         ret->b = b_ref;
2425         return (uint64_t)ret;
2426 }
2427 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t ptr) {
2428         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
2429         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2430         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2431         return a_arr;
2432 }
2433 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t ptr) {
2434         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
2435         int8_tArray b_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2436         memcpy((uint8_t*)(b_arr + 4), tuple->b.data, 32);
2437         return b_arr;
2438 }
2439 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_result_ok(uint32_t arg) {
2440         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
2441 }
2442 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_ok(uint32_t arg) {
2443         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2444         CHECK(val->result_ok);
2445         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2446         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2447         return res_arr;
2448 }
2449 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_err(uint32_t arg) {
2450         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2451         CHECK(!val->result_ok);
2452         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2453         return err_ref;
2454 }
2455 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
2456         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2457         ret->datalen = *((uint32_t*)elems);
2458         if (ret->datalen == 0) {
2459                 ret->data = NULL;
2460         } else {
2461                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2462                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2463                 for (size_t i = 0; i < ret->datalen; i++) {
2464                         uint32_t arr_elem = java_elems[i];
2465                         LDKChannelMonitor arr_elem_conv;
2466                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2467                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2468                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2469                         ret->data[i] = arr_elem_conv;
2470                 }
2471         }
2472         return (uint64_t)ret;
2473 }
2474 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2475         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2476         for (size_t i = 0; i < ret.datalen; i++) {
2477                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2478         }
2479         return ret;
2480 }
2481 typedef struct LDKWatch_JCalls {
2482         atomic_size_t refcnt;
2483         uint32_t watch_channel_meth;
2484         uint32_t update_channel_meth;
2485         uint32_t release_pending_monitor_events_meth;
2486 } LDKWatch_JCalls;
2487 static void LDKWatch_JCalls_free(void* this_arg) {
2488         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2489         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2490                 js_free(j_calls->watch_channel_meth);
2491                 js_free(j_calls->update_channel_meth);
2492                 js_free(j_calls->release_pending_monitor_events_meth);
2493                 FREE(j_calls);
2494         }
2495 }
2496 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2497         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2498         LDKOutPoint funding_txo_var = funding_txo;
2499         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2500         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2501         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2502         if (funding_txo_var.is_owned) {
2503                 funding_txo_ref |= 1;
2504         }
2505         LDKChannelMonitor monitor_var = monitor;
2506         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2507         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2508         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
2509         if (monitor_var.is_owned) {
2510                 monitor_ref |= 1;
2511         }
2512         uint32_t ret = js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2513         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2514         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2515         return ret_conv;
2516 }
2517 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2518         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2519         LDKOutPoint funding_txo_var = funding_txo;
2520         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2521         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2522         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2523         if (funding_txo_var.is_owned) {
2524                 funding_txo_ref |= 1;
2525         }
2526         LDKChannelMonitorUpdate update_var = update;
2527         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2528         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2529         uint64_t update_ref = (uint64_t)update_var.inner;
2530         if (update_var.is_owned) {
2531                 update_ref |= 1;
2532         }
2533         uint32_t ret = js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2534         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2535         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2536         return ret_conv;
2537 }
2538 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
2539         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2540         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2541         LDKCVec_MonitorEventZ ret_constr;
2542         ret_constr.datalen = *((uint32_t*)ret);
2543         if (ret_constr.datalen > 0)
2544                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2545         else
2546                 ret_constr.data = NULL;
2547         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2548         for (size_t o = 0; o < ret_constr.datalen; o++) {
2549                 uint32_t ret_conv_14 = ret_vals[o];
2550                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
2551                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
2552                 ret_constr.data[o] = ret_conv_14_conv;
2553         }
2554         return ret_constr;
2555 }
2556 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
2557         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
2558         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2559 }
2560 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2561         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2562         atomic_init(&calls->refcnt, 1);
2563         //TODO: Assign calls->o from o
2564
2565         LDKWatch ret = {
2566                 .this_arg = (void*) calls,
2567                 .watch_channel = watch_channel_LDKWatch_jcall,
2568                 .update_channel = update_channel_LDKWatch_jcall,
2569                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
2570                 .free = LDKWatch_JCalls_free,
2571         };
2572         return ret;
2573 }
2574 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2575         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2576         *res_ptr = LDKWatch_init(o);
2577         return (long)res_ptr;
2578 }
2579 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2580         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2581         LDKOutPoint funding_txo_conv;
2582         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2583         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2584         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2585         LDKChannelMonitor monitor_conv;
2586         monitor_conv.inner = (void*)(monitor & (~1));
2587         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2588         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2589         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2590         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2591         return (uint64_t)ret_conv;
2592 }
2593
2594 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
2595         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2596         LDKOutPoint funding_txo_conv;
2597         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2598         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2599         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2600         LDKChannelMonitorUpdate update_conv;
2601         update_conv.inner = (void*)(update & (~1));
2602         update_conv.is_owned = (update & 1) || (update == 0);
2603         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2604         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2605         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2606         return (uint64_t)ret_conv;
2607 }
2608
2609 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
2610         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2611         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2612         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2613         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2614         for (size_t o = 0; o < ret_var.datalen; o++) {
2615                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2616                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
2617                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
2618                 ret_arr_ptr[o] = ret_conv_14_ref;
2619         }
2620         FREE(ret_var.data);
2621         return ret_arr;
2622 }
2623
2624 typedef struct LDKBroadcasterInterface_JCalls {
2625         atomic_size_t refcnt;
2626         uint32_t broadcast_transaction_meth;
2627 } LDKBroadcasterInterface_JCalls;
2628 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2629         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2630         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2631                 js_free(j_calls->broadcast_transaction_meth);
2632                 FREE(j_calls);
2633         }
2634 }
2635 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
2636         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2637         LDKTransaction tx_var = tx;
2638         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2639         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
2640         Transaction_free(tx_var);
2641         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
2642 }
2643 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
2644         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
2645         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2646 }
2647 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
2648         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2649         atomic_init(&calls->refcnt, 1);
2650         //TODO: Assign calls->o from o
2651
2652         LDKBroadcasterInterface ret = {
2653                 .this_arg = (void*) calls,
2654                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
2655                 .free = LDKBroadcasterInterface_JCalls_free,
2656         };
2657         return ret;
2658 }
2659 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
2660         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2661         *res_ptr = LDKBroadcasterInterface_init(o);
2662         return (long)res_ptr;
2663 }
2664 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
2665         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
2666         LDKTransaction tx_ref;
2667         tx_ref.datalen = *((uint32_t*)tx);
2668         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2669         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
2670         tx_ref.data_is_owned = true;
2671         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2672 }
2673
2674 typedef struct LDKKeysInterface_JCalls {
2675         atomic_size_t refcnt;
2676         uint32_t get_node_secret_meth;
2677         uint32_t get_destination_script_meth;
2678         uint32_t get_shutdown_scriptpubkey_meth;
2679         uint32_t get_channel_signer_meth;
2680         uint32_t get_secure_random_bytes_meth;
2681         uint32_t read_chan_signer_meth;
2682         uint32_t sign_invoice_meth;
2683 } LDKKeysInterface_JCalls;
2684 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2685         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2686         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2687                 js_free(j_calls->get_node_secret_meth);
2688                 js_free(j_calls->get_destination_script_meth);
2689                 js_free(j_calls->get_shutdown_scriptpubkey_meth);
2690                 js_free(j_calls->get_channel_signer_meth);
2691                 js_free(j_calls->get_secure_random_bytes_meth);
2692                 js_free(j_calls->read_chan_signer_meth);
2693                 js_free(j_calls->sign_invoice_meth);
2694                 FREE(j_calls);
2695         }
2696 }
2697 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
2698         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2699         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
2700         LDKSecretKey ret_ref;
2701         CHECK(*((uint32_t*)ret) == 32);
2702         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
2703         return ret_ref;
2704 }
2705 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
2706         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2707         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
2708         LDKCVec_u8Z ret_ref;
2709         ret_ref.datalen = *((uint32_t*)ret);
2710         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2711         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2712         return ret_ref;
2713 }
2714 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
2715         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2716         uint32_t ret = js_invoke_function_0(j_calls->get_shutdown_scriptpubkey_meth);
2717         LDKShutdownScript ret_conv;
2718         ret_conv.inner = (void*)(ret & (~1));
2719         ret_conv.is_owned = (ret & 1) || (ret == 0);
2720         ret_conv = ShutdownScript_clone(&ret_conv);
2721         return ret_conv;
2722 }
2723 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2724         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2725         uint32_t ret = js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
2726         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
2727         ret_conv = Sign_clone(&ret_conv);
2728         return ret_conv;
2729 }
2730 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
2731         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2732         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
2733         LDKThirtyTwoBytes ret_ref;
2734         CHECK(*((uint32_t*)ret) == 32);
2735         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
2736         return ret_ref;
2737 }
2738 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
2739         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2740         LDKu8slice reader_var = reader;
2741         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2742         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
2743         uint32_t ret = js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
2744         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
2745         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
2746         return ret_conv;
2747 }
2748 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
2749         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2750         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
2751         int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2752         memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
2753         CVec_u8Z_free(invoice_preimage_var);
2754         uint32_t ret = js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
2755         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
2756         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
2757         return ret_conv;
2758 }
2759 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
2760         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
2761         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2762 }
2763 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
2764         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2765         atomic_init(&calls->refcnt, 1);
2766         //TODO: Assign calls->o from o
2767
2768         LDKKeysInterface ret = {
2769                 .this_arg = (void*) calls,
2770                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
2771                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
2772                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
2773                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
2774                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
2775                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
2776                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
2777                 .free = LDKKeysInterface_JCalls_free,
2778         };
2779         return ret;
2780 }
2781 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
2782         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2783         *res_ptr = LDKKeysInterface_init(o);
2784         return (long)res_ptr;
2785 }
2786 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
2787         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2788         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2789         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
2790         return ret_arr;
2791 }
2792
2793 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
2794         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2795         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2796         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2797         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2798         CVec_u8Z_free(ret_var);
2799         return ret_arr;
2800 }
2801
2802 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
2803         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2804         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
2805         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2806         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2807         uint64_t ret_ref = (uint64_t)ret_var.inner;
2808         if (ret_var.is_owned) {
2809                 ret_ref |= 1;
2810         }
2811         return ret_ref;
2812 }
2813
2814 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
2815         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2816         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
2817         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2818         return (uint64_t)ret_ret;
2819 }
2820
2821 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2822         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2823         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2824         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2825         return ret_arr;
2826 }
2827
2828 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2829         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2830         LDKu8slice reader_ref;
2831         reader_ref.datalen = *((uint32_t*)reader);
2832         reader_ref.data = (int8_t*)(reader + 4);
2833         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
2834         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2835         return (uint64_t)ret_conv;
2836 }
2837
2838 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
2839         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2840         LDKCVec_u8Z invoice_preimage_ref;
2841         invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
2842         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
2843         memcpy(invoice_preimage_ref.data, (uint8_t*)(invoice_preimage + 4), invoice_preimage_ref.datalen);
2844         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
2845         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
2846         return (uint64_t)ret_conv;
2847 }
2848
2849 typedef struct LDKFeeEstimator_JCalls {
2850         atomic_size_t refcnt;
2851         uint32_t get_est_sat_per_1000_weight_meth;
2852 } LDKFeeEstimator_JCalls;
2853 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2854         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2855         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2856                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
2857                 FREE(j_calls);
2858         }
2859 }
2860 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2861         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2862         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
2863         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2864 }
2865 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
2866         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
2867         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2868 }
2869 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
2870         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2871         atomic_init(&calls->refcnt, 1);
2872         //TODO: Assign calls->o from o
2873
2874         LDKFeeEstimator ret = {
2875                 .this_arg = (void*) calls,
2876                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
2877                 .free = LDKFeeEstimator_JCalls_free,
2878         };
2879         return ret;
2880 }
2881 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
2882         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2883         *res_ptr = LDKFeeEstimator_init(o);
2884         return (long)res_ptr;
2885 }
2886 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
2887         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
2888         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
2889         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2890         return ret_val;
2891 }
2892
2893 typedef struct LDKLogger_JCalls {
2894         atomic_size_t refcnt;
2895         uint32_t log_meth;
2896 } LDKLogger_JCalls;
2897 static void LDKLogger_JCalls_free(void* this_arg) {
2898         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2899         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2900                 js_free(j_calls->log_meth);
2901                 FREE(j_calls);
2902         }
2903 }
2904 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
2905         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2906         const char* record_str = record;
2907         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
2908         js_invoke_function_1(j_calls->log_meth, record_conv);
2909 }
2910 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
2911         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
2912         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2913 }
2914 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
2915         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2916         atomic_init(&calls->refcnt, 1);
2917         //TODO: Assign calls->o from o
2918
2919         LDKLogger ret = {
2920                 .this_arg = (void*) calls,
2921                 .log = log_LDKLogger_jcall,
2922                 .free = LDKLogger_JCalls_free,
2923         };
2924         return ret;
2925 }
2926 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
2927         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2928         *res_ptr = LDKLogger_init(o);
2929         return (long)res_ptr;
2930 }
2931 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
2932         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
2933         LDKThirtyTwoBytes a_ref;
2934         CHECK(*((uint32_t*)a) == 32);
2935         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2936         ret->a = a_ref;
2937         LDKChannelManager b_conv;
2938         b_conv.inner = (void*)(b & (~1));
2939         b_conv.is_owned = (b & 1) || (b == 0);
2940         // Warning: we need a move here but no clone is available for LDKChannelManager
2941         ret->b = b_conv;
2942         return (uint64_t)ret;
2943 }
2944 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
2945         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2946         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2947         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2948         return a_arr;
2949 }
2950 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
2951         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2952         LDKChannelManager b_var = tuple->b;
2953         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2954         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2955         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2956         return b_ref;
2957 }
2958 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
2959         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
2960 }
2961 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
2962         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2963         CHECK(val->result_ok);
2964         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2965         return res_ref;
2966 }
2967 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
2968         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2969         CHECK(!val->result_ok);
2970         LDKDecodeError err_var = (*val->contents.err);
2971         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2972         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2973         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2974         return err_ref;
2975 }
2976 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
2977         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
2978 }
2979 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
2980         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
2981         CHECK(val->result_ok);
2982         LDKChannelConfig res_var = (*val->contents.result);
2983         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2984         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2985         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2986         return res_ref;
2987 }
2988 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
2989         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
2990         CHECK(!val->result_ok);
2991         LDKDecodeError err_var = (*val->contents.err);
2992         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2993         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2994         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2995         return err_ref;
2996 }
2997 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
2998         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
2999 }
3000 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
3001         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
3002         CHECK(val->result_ok);
3003         LDKOutPoint res_var = (*val->contents.result);
3004         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3005         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3006         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3007         return res_ref;
3008 }
3009 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
3010         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
3011         CHECK(!val->result_ok);
3012         LDKDecodeError err_var = (*val->contents.err);
3013         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3014         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3015         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3016         return err_ref;
3017 }
3018 typedef struct LDKType_JCalls {
3019         atomic_size_t refcnt;
3020         uint32_t type_id_meth;
3021         uint32_t debug_str_meth;
3022         uint32_t write_meth;
3023 } LDKType_JCalls;
3024 static void LDKType_JCalls_free(void* this_arg) {
3025         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3026         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3027                 js_free(j_calls->type_id_meth);
3028                 js_free(j_calls->debug_str_meth);
3029                 js_free(j_calls->write_meth);
3030                 FREE(j_calls);
3031         }
3032 }
3033 uint16_t type_id_LDKType_jcall(const void* this_arg) {
3034         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3035         return js_invoke_function_0(j_calls->type_id_meth);
3036 }
3037 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
3038         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3039         uint32_t ret = js_invoke_function_0(j_calls->debug_str_meth);
3040         LDKStr ret_conv = str_ref_to_owned_c(ret);
3041         return ret_conv;
3042 }
3043 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
3044         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3045         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
3046         LDKCVec_u8Z ret_ref;
3047         ret_ref.datalen = *((uint32_t*)ret);
3048         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3049         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
3050         return ret_ref;
3051 }
3052 static void LDKType_JCalls_cloned(LDKType* new_obj) {
3053         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
3054         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3055 }
3056 static inline LDKType LDKType_init (/*TODO: JS Object Reference */void* o) {
3057         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
3058         atomic_init(&calls->refcnt, 1);
3059         //TODO: Assign calls->o from o
3060
3061         LDKType ret = {
3062                 .this_arg = (void*) calls,
3063                 .type_id = type_id_LDKType_jcall,
3064                 .debug_str = debug_str_LDKType_jcall,
3065                 .write = write_LDKType_jcall,
3066                 .cloned = LDKType_JCalls_cloned,
3067                 .free = LDKType_JCalls_free,
3068         };
3069         return ret;
3070 }
3071 long  __attribute__((visibility("default"))) TS_LDKType_new(/*TODO: JS Object Reference */void* o) {
3072         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
3073         *res_ptr = LDKType_init(o);
3074         return (long)res_ptr;
3075 }
3076 int16_t  __attribute__((visibility("default"))) TS_Type_type_id(uint32_t this_arg) {
3077         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
3078         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
3079         return ret_val;
3080 }
3081
3082 jstring  __attribute__((visibility("default"))) TS_Type_debug_str(uint32_t this_arg) {
3083         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
3084         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
3085         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
3086         Str_free(ret_str);
3087         return ret_conv;
3088 }
3089
3090 int8_tArray  __attribute__((visibility("default"))) TS_Type_write(uint32_t this_arg) {
3091         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
3092         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3093         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3094         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3095         CVec_u8Z_free(ret_var);
3096         return ret_arr;
3097 }
3098
3099 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_TypeZ_ref_from_ptr(uint32_t ptr) {
3100         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
3101         switch(obj->tag) {
3102                 case LDKCOption_TypeZ_Some: {
3103                         LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType");
3104                         *some_ret = Type_clone(&obj->some);
3105                         return 0 /* LDKCOption_TypeZ - Some */; (void) (uint64_t)some_ret;
3106                 }
3107                 case LDKCOption_TypeZ_None: {
3108                         return 0 /* LDKCOption_TypeZ - None */;
3109                 }
3110                 default: abort();
3111         }
3112 }
3113 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_result_ok(uint32_t arg) {
3114         return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok;
3115 }
3116 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t arg) {
3117         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
3118         CHECK(val->result_ok);
3119         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3120         return res_ref;
3121 }
3122 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_err(uint32_t arg) {
3123         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
3124         CHECK(!val->result_ok);
3125         LDKDecodeError 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 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) {
3132         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
3133 }
3134 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_ok(uint32_t arg) {
3135         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
3136         CHECK(val->result_ok);
3137         uint32_t res_conv = LDKSiPrefix_to_js((*val->contents.result));
3138         return res_conv;
3139 }
3140 void  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_err(uint32_t arg) {
3141         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
3142         CHECK(!val->result_ok);
3143         return *val->contents.err;
3144 }
3145 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_result_ok(uint32_t arg) {
3146         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
3147 }
3148 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_ok(uint32_t arg) {
3149         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
3150         CHECK(val->result_ok);
3151         LDKInvoice res_var = (*val->contents.result);
3152         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3153         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3154         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3155         return res_ref;
3156 }
3157 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
3158         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
3159         CHECK(!val->result_ok);
3160         return *val->contents.err;
3161 }
3162 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_result_ok(uint32_t arg) {
3163         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
3164 }
3165 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_ok(uint32_t arg) {
3166         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
3167         CHECK(val->result_ok);
3168         LDKSignedRawInvoice res_var = (*val->contents.result);
3169         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3170         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3171         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3172         return res_ref;
3173 }
3174 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
3175         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
3176         CHECK(!val->result_ok);
3177         return *val->contents.err;
3178 }
3179 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
3180         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
3181         LDKRawInvoice a_conv;
3182         a_conv.inner = (void*)(a & (~1));
3183         a_conv.is_owned = (a & 1) || (a == 0);
3184         a_conv = RawInvoice_clone(&a_conv);
3185         ret->a = a_conv;
3186         LDKThirtyTwoBytes b_ref;
3187         CHECK(*((uint32_t*)b) == 32);
3188         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
3189         ret->b = b_ref;
3190         LDKInvoiceSignature c_conv;
3191         c_conv.inner = (void*)(c & (~1));
3192         c_conv.is_owned = (c & 1) || (c == 0);
3193         c_conv = InvoiceSignature_clone(&c_conv);
3194         ret->c = c_conv;
3195         return (uint64_t)ret;
3196 }
3197 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t ptr) {
3198         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
3199         LDKRawInvoice a_var = tuple->a;
3200         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3201         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3202         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3203         return a_ref;
3204 }
3205 int8_tArray  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t ptr) {
3206         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
3207         int8_tArray b_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3208         memcpy((uint8_t*)(b_arr + 4), tuple->b.data, 32);
3209         return b_arr;
3210 }
3211 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t ptr) {
3212         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
3213         LDKInvoiceSignature c_var = tuple->c;
3214         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3215         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3216         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
3217         return c_ref;
3218 }
3219 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_result_ok(uint32_t arg) {
3220         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
3221 }
3222 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_ok(uint32_t arg) {
3223         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3224         CHECK(val->result_ok);
3225         LDKPayeePubKey res_var = (*val->contents.result);
3226         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3227         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3228         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3229         return res_ref;
3230 }
3231 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
3232         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3233         CHECK(!val->result_ok);
3234         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3235         return err_conv;
3236 }
3237 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_PrivateRouteZ_new(uint32_tArray elems) {
3238         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
3239         ret->datalen = *((uint32_t*)elems);
3240         if (ret->datalen == 0) {
3241                 ret->data = NULL;
3242         } else {
3243                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
3244                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3245                 for (size_t i = 0; i < ret->datalen; i++) {
3246                         uint32_t arr_elem = java_elems[i];
3247                         LDKPrivateRoute arr_elem_conv;
3248                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3249                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3250                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
3251                         ret->data[i] = arr_elem_conv;
3252                 }
3253         }
3254         return (uint64_t)ret;
3255 }
3256 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
3257         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
3258         for (size_t i = 0; i < ret.datalen; i++) {
3259                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
3260         }
3261         return ret;
3262 }
3263 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_result_ok(uint32_t arg) {
3264         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
3265 }
3266 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t arg) {
3267         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3268         CHECK(val->result_ok);
3269         LDKPositiveTimestamp res_var = (*val->contents.result);
3270         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3271         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3272         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3273         return res_ref;
3274 }
3275 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
3276         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3277         CHECK(!val->result_ok);
3278         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3279         return err_conv;
3280 }
3281 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_result_ok(uint32_t arg) {
3282         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
3283 }
3284 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_ok(uint32_t arg) {
3285         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3286         CHECK(val->result_ok);
3287         return *val->contents.result;
3288 }
3289 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_err(uint32_t arg) {
3290         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3291         CHECK(!val->result_ok);
3292         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3293         return err_conv;
3294 }
3295 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_result_ok(uint32_t arg) {
3296         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
3297 }
3298 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_ok(uint32_t arg) {
3299         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3300         CHECK(val->result_ok);
3301         LDKInvoice res_var = (*val->contents.result);
3302         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3303         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3304         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3305         return res_ref;
3306 }
3307 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
3308         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3309         CHECK(!val->result_ok);
3310         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3311         return err_conv;
3312 }
3313 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_result_ok(uint32_t arg) {
3314         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
3315 }
3316 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_ok(uint32_t arg) {
3317         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3318         CHECK(val->result_ok);
3319         LDKDescription res_var = (*val->contents.result);
3320         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3321         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3322         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3323         return res_ref;
3324 }
3325 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
3326         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3327         CHECK(!val->result_ok);
3328         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3329         return err_conv;
3330 }
3331 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_result_ok(uint32_t arg) {
3332         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
3333 }
3334 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_ok(uint32_t arg) {
3335         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3336         CHECK(val->result_ok);
3337         LDKExpiryTime res_var = (*val->contents.result);
3338         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3339         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3340         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3341         return res_ref;
3342 }
3343 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
3344         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3345         CHECK(!val->result_ok);
3346         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3347         return err_conv;
3348 }
3349 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_result_ok(uint32_t arg) {
3350         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
3351 }
3352 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_ok(uint32_t arg) {
3353         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3354         CHECK(val->result_ok);
3355         LDKPrivateRoute res_var = (*val->contents.result);
3356         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3357         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3358         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3359         return res_ref;
3360 }
3361 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
3362         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3363         CHECK(!val->result_ok);
3364         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3365         return err_conv;
3366 }
3367 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_result_ok(uint32_t arg) {
3368         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
3369 }
3370 jstring  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_ok(uint32_t arg) {
3371         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3372         CHECK(val->result_ok);
3373         LDKStr res_str = (*val->contents.result);
3374         jstring res_conv = str_ref_to_ts(res_str.chars, res_str.len);
3375         return res_conv;
3376 }
3377 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_err(uint32_t arg) {
3378         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3379         CHECK(!val->result_ok);
3380         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3381         return err_conv;
3382 }
3383 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3384         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
3385 }
3386 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3387         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3388         CHECK(val->result_ok);
3389         LDKChannelMonitorUpdate res_var = (*val->contents.result);
3390         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3391         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3392         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3393         return res_ref;
3394 }
3395 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
3396         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3397         CHECK(!val->result_ok);
3398         LDKDecodeError err_var = (*val->contents.err);
3399         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3400         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3401         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3402         return err_ref;
3403 }
3404 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3405         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
3406 }
3407 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3408         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3409         CHECK(val->result_ok);
3410         LDKHTLCUpdate res_var = (*val->contents.result);
3411         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3412         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3413         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3414         return res_ref;
3415 }
3416 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
3417         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3418         CHECK(!val->result_ok);
3419         LDKDecodeError err_var = (*val->contents.err);
3420         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3421         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3422         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3423         return err_ref;
3424 }
3425 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
3426         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
3427 }
3428 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
3429         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3430         CHECK(val->result_ok);
3431         return *val->contents.result;
3432 }
3433 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
3434         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3435         CHECK(!val->result_ok);
3436         LDKMonitorUpdateError err_var = (*val->contents.err);
3437         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3438         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3439         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3440         return err_ref;
3441 }
3442 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
3443         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
3444         LDKOutPoint a_conv;
3445         a_conv.inner = (void*)(a & (~1));
3446         a_conv.is_owned = (a & 1) || (a == 0);
3447         a_conv = OutPoint_clone(&a_conv);
3448         ret->a = a_conv;
3449         LDKCVec_u8Z b_ref;
3450         b_ref.datalen = *((uint32_t*)b);
3451         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3452         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3453         ret->b = b_ref;
3454         return (uint64_t)ret;
3455 }
3456 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
3457         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
3458         LDKOutPoint a_var = tuple->a;
3459         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3460         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3461         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3462         return a_ref;
3463 }
3464 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
3465         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
3466         LDKCVec_u8Z b_var = tuple->b;
3467         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3468         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
3469         return b_arr;
3470 }
3471 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
3472         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
3473         ret->a = a;
3474         LDKCVec_u8Z b_ref;
3475         b_ref.datalen = *((uint32_t*)b);
3476         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3477         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3478         ret->b = b_ref;
3479         return (uint64_t)ret;
3480 }
3481 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_a(uint32_t ptr) {
3482         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
3483         return tuple->a;
3484 }
3485 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_b(uint32_t ptr) {
3486         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
3487         LDKCVec_u8Z b_var = tuple->b;
3488         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3489         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
3490         return b_arr;
3491 }
3492 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
3493         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
3494         ret->datalen = *((uint32_t*)elems);
3495         if (ret->datalen == 0) {
3496                 ret->data = NULL;
3497         } else {
3498                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
3499                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3500                 for (size_t i = 0; i < ret->datalen; i++) {
3501                         uint32_t arr_elem = java_elems[i];
3502                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
3503                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
3504                         ret->data[i] = arr_elem_conv;
3505                 }
3506         }
3507         return (uint64_t)ret;
3508 }
3509 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
3510         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
3511         for (size_t i = 0; i < ret.datalen; i++) {
3512                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
3513         }
3514         return ret;
3515 }
3516 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
3517         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
3518         LDKThirtyTwoBytes a_ref;
3519         CHECK(*((uint32_t*)a) == 32);
3520         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3521         ret->a = a_ref;
3522         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
3523         b_constr.datalen = *((uint32_t*)b);
3524         if (b_constr.datalen > 0)
3525                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
3526         else
3527                 b_constr.data = NULL;
3528         uint32_t* b_vals = (uint32_t*)(b + 4);
3529         for (size_t e = 0; e < b_constr.datalen; e++) {
3530                 uint32_t b_conv_30 = b_vals[e];
3531                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
3532                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
3533                 b_constr.data[e] = b_conv_30_conv;
3534         }
3535         ret->b = b_constr;
3536         return (uint64_t)ret;
3537 }
3538 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t ptr) {
3539         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
3540         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3541         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
3542         return a_arr;
3543 }
3544 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t ptr) {
3545         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
3546         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
3547         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3548         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
3549         for (size_t e = 0; e < b_var.datalen; e++) {
3550                 uint64_t b_conv_30_ref = (uint64_t)(&b_var.data[e]) | 1;
3551                 b_arr_ptr[e] = b_conv_30_ref;
3552         }
3553         return b_arr;
3554 }
3555 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
3556         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
3557         ret->datalen = *((uint32_t*)elems);
3558         if (ret->datalen == 0) {
3559                 ret->data = NULL;
3560         } else {
3561                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
3562                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3563                 for (size_t i = 0; i < ret->datalen; i++) {
3564                         uint32_t arr_elem = java_elems[i];
3565                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
3566                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
3567                         ret->data[i] = arr_elem_conv;
3568                 }
3569         }
3570         return (uint64_t)ret;
3571 }
3572 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
3573         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 };
3574         for (size_t i = 0; i < ret.datalen; i++) {
3575                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
3576         }
3577         return ret;
3578 }
3579 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentPurpose_ref_from_ptr(uint32_t ptr) {
3580         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
3581         switch(obj->tag) {
3582                 case LDKPaymentPurpose_InvoicePayment: {
3583                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3584                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->invoice_payment.payment_preimage.data, 32);
3585                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3586                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->invoice_payment.payment_secret.data, 32);
3587                         return 0 /* LDKPaymentPurpose - InvoicePayment */; (void) payment_preimage_arr; (void) payment_secret_arr; (void) obj->invoice_payment.user_payment_id;
3588                 }
3589                 case LDKPaymentPurpose_SpontaneousPayment: {
3590                         int8_tArray spontaneous_payment_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3591                         memcpy((uint8_t*)(spontaneous_payment_arr + 4), obj->spontaneous_payment.data, 32);
3592                         return 0 /* LDKPaymentPurpose - SpontaneousPayment */; (void) spontaneous_payment_arr;
3593                 }
3594                 default: abort();
3595         }
3596 }
3597 uint32_t __attribute__((visibility("default"))) TS_LDKClosureReason_ref_from_ptr(uint32_t ptr) {
3598         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
3599         switch(obj->tag) {
3600                 case LDKClosureReason_CounterpartyForceClosed: {
3601                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
3602                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
3603                         return 0 /* LDKClosureReason - CounterpartyForceClosed */; (void) peer_msg_conv;
3604                 }
3605                 case LDKClosureReason_HolderForceClosed: {
3606                         return 0 /* LDKClosureReason - HolderForceClosed */;
3607                 }
3608                 case LDKClosureReason_CooperativeClosure: {
3609                         return 0 /* LDKClosureReason - CooperativeClosure */;
3610                 }
3611                 case LDKClosureReason_CommitmentTxConfirmed: {
3612                         return 0 /* LDKClosureReason - CommitmentTxConfirmed */;
3613                 }
3614                 case LDKClosureReason_ProcessingError: {
3615                         LDKStr err_str = obj->processing_error.err;
3616                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3617                         return 0 /* LDKClosureReason - ProcessingError */; (void) err_conv;
3618                 }
3619                 case LDKClosureReason_DisconnectedPeer: {
3620                         return 0 /* LDKClosureReason - DisconnectedPeer */;
3621                 }
3622                 case LDKClosureReason_OutdatedChannelManager: {
3623                         return 0 /* LDKClosureReason - OutdatedChannelManager */;
3624                 }
3625                 default: abort();
3626         }
3627 }
3628 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
3629         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
3630         switch(obj->tag) {
3631                 case LDKEvent_FundingGenerationReady: {
3632                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3633                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
3634                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3635                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3636                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
3637                         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;
3638                 }
3639                 case LDKEvent_PaymentReceived: {
3640                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3641                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
3642                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
3643                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) obj->payment_received.amt; (void) purpose_ref;
3644                 }
3645                 case LDKEvent_PaymentSent: {
3646                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3647                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
3648                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
3649                 }
3650                 case LDKEvent_PaymentPathFailed: {
3651                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3652                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_path_failed.payment_hash.data, 32);
3653                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
3654                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
3655                         uint32_tArray path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3656                         uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
3657                         for (size_t k = 0; k < path_var.datalen; k++) {
3658                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3659                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3660                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3661                                 uint64_t path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
3662                                 path_arr_ptr[k] = path_conv_10_ref;
3663                         }
3664                         return 0 /* LDKEvent - PaymentPathFailed */; (void) payment_hash_arr; (void) obj->payment_path_failed.rejected_by_dest; (void) network_update_ref; (void) obj->payment_path_failed.all_paths_failed; (void) path_arr;
3665                 }
3666                 case LDKEvent_PendingHTLCsForwardable: {
3667                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
3668                 }
3669                 case LDKEvent_SpendableOutputs: {
3670                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3671                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3672                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
3673                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3674                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
3675                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3676                         }
3677                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
3678                 }
3679                 case LDKEvent_PaymentForwarded: {
3680                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
3681                         return 0 /* LDKEvent - PaymentForwarded */; (void) fee_earned_msat_ref; (void) obj->payment_forwarded.claim_from_onchain_tx;
3682                 }
3683                 case LDKEvent_ChannelClosed: {
3684                         int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3685                         memcpy((uint8_t*)(channel_id_arr + 4), obj->channel_closed.channel_id.data, 32);
3686                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
3687                         return 0 /* LDKEvent - ChannelClosed */; (void) channel_id_arr; (void) reason_ref;
3688                 }
3689                 default: abort();
3690         }
3691 }
3692 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
3693         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
3694         ret->datalen = *((uint32_t*)elems);
3695         if (ret->datalen == 0) {
3696                 ret->data = NULL;
3697         } else {
3698                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
3699                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3700                 for (size_t i = 0; i < ret->datalen; i++) {
3701                         uint32_t arr_elem = java_elems[i];
3702                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
3703                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
3704                         ret->data[i] = arr_elem_conv;
3705                 }
3706         }
3707         return (uint64_t)ret;
3708 }
3709 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
3710         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
3711         for (size_t i = 0; i < ret.datalen; i++) {
3712                 ret.data[i] = Event_clone(&orig->data[i]);
3713         }
3714         return ret;
3715 }
3716 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
3717         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
3718         ret->a = a;
3719         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
3720         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
3721         ret->b = b_conv;
3722         return (uint64_t)ret;
3723 }
3724 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
3725         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
3726         return tuple->a;
3727 }
3728 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
3729         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
3730         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
3731         return (uint64_t)b_ref;
3732 }
3733 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
3734         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
3735         ret->datalen = *((uint32_t*)elems);
3736         if (ret->datalen == 0) {
3737                 ret->data = NULL;
3738         } else {
3739                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
3740                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3741                 for (size_t i = 0; i < ret->datalen; i++) {
3742                         uint32_t arr_elem = java_elems[i];
3743                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
3744                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
3745                         ret->data[i] = arr_elem_conv;
3746                 }
3747         }
3748         return (uint64_t)ret;
3749 }
3750 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
3751         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
3752         for (size_t i = 0; i < ret.datalen; i++) {
3753                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
3754         }
3755         return ret;
3756 }
3757 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
3758         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
3759         LDKThirtyTwoBytes a_ref;
3760         CHECK(*((uint32_t*)a) == 32);
3761         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3762         ret->a = a_ref;
3763         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
3764         b_constr.datalen = *((uint32_t*)b);
3765         if (b_constr.datalen > 0)
3766                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
3767         else
3768                 b_constr.data = NULL;
3769         uint32_t* b_vals = (uint32_t*)(b + 4);
3770         for (size_t z = 0; z < b_constr.datalen; z++) {
3771                 uint32_t b_conv_25 = b_vals[z];
3772                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
3773                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
3774                 b_constr.data[z] = b_conv_25_conv;
3775         }
3776         ret->b = b_constr;
3777         return (uint64_t)ret;
3778 }
3779 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
3780         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
3781         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3782         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
3783         return a_arr;
3784 }
3785 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
3786         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
3787         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
3788         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3789         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
3790         for (size_t z = 0; z < b_var.datalen; z++) {
3791                 uint64_t b_conv_25_ref = (uint64_t)(&b_var.data[z]) | 1;
3792                 b_arr_ptr[z] = b_conv_25_ref;
3793         }
3794         return b_arr;
3795 }
3796 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
3797         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
3798         ret->datalen = *((uint32_t*)elems);
3799         if (ret->datalen == 0) {
3800                 ret->data = NULL;
3801         } else {
3802                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
3803                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3804                 for (size_t i = 0; i < ret->datalen; i++) {
3805                         uint32_t arr_elem = java_elems[i];
3806                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
3807                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
3808                         ret->data[i] = arr_elem_conv;
3809                 }
3810         }
3811         return (uint64_t)ret;
3812 }
3813 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
3814         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 };
3815         for (size_t i = 0; i < ret.datalen; i++) {
3816                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
3817         }
3818         return ret;
3819 }
3820 uint32_t __attribute__((visibility("default"))) TS_LDKBalance_ref_from_ptr(uint32_t ptr) {
3821         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
3822         switch(obj->tag) {
3823                 case LDKBalance_ClaimableOnChannelClose: {
3824                         return 0 /* LDKBalance - ClaimableOnChannelClose */; (void) obj->claimable_on_channel_close.claimable_amount_satoshis;
3825                 }
3826                 case LDKBalance_ClaimableAwaitingConfirmations: {
3827                         return 0 /* LDKBalance - ClaimableAwaitingConfirmations */; (void) obj->claimable_awaiting_confirmations.claimable_amount_satoshis; (void) obj->claimable_awaiting_confirmations.confirmation_height;
3828                 }
3829                 case LDKBalance_ContentiousClaimable: {
3830                         return 0 /* LDKBalance - ContentiousClaimable */; (void) obj->contentious_claimable.claimable_amount_satoshis; (void) obj->contentious_claimable.timeout_height;
3831                 }
3832                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
3833                         return 0 /* LDKBalance - MaybeClaimableHTLCAwaitingTimeout */; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
3834                 }
3835                 default: abort();
3836         }
3837 }
3838 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_BalanceZ_new(uint32_tArray elems) {
3839         LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ");
3840         ret->datalen = *((uint32_t*)elems);
3841         if (ret->datalen == 0) {
3842                 ret->data = NULL;
3843         } else {
3844                 ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ 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                         LDKBalance arr_elem_conv = *(LDKBalance*)(((uint64_t)arr_elem) & ~1);
3849                         arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
3850                         ret->data[i] = arr_elem_conv;
3851                 }
3852         }
3853         return (uint64_t)ret;
3854 }
3855 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
3856         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
3857         for (size_t i = 0; i < ret.datalen; i++) {
3858                 ret.data[i] = Balance_clone(&orig->data[i]);
3859         }
3860         return ret;
3861 }
3862 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
3863         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
3864 }
3865 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
3866         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
3867         CHECK(val->result_ok);
3868         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
3869         return res_ref;
3870 }
3871 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
3872         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
3873         CHECK(!val->result_ok);
3874         LDKDecodeError err_var = (*val->contents.err);
3875         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3876         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3877         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3878         return err_ref;
3879 }
3880 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
3881         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
3882 }
3883 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
3884         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
3885         CHECK(val->result_ok);
3886         return *val->contents.result;
3887 }
3888 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
3889         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
3890         CHECK(!val->result_ok);
3891         LDKLightningError err_var = (*val->contents.err);
3892         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3893         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3894         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3895         return err_ref;
3896 }
3897 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
3898         LDKC2Tuple_PublicKeyTypeZ* ret = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
3899         LDKPublicKey a_ref;
3900         CHECK(*((uint32_t*)a) == 33);
3901         memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33);
3902         ret->a = a_ref;
3903         LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1);
3904         b_conv = Type_clone(&b_conv);
3905         ret->b = b_conv;
3906         return (uint64_t)ret;
3907 }
3908 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PublicKeyTypeZ_get_a(uint32_t ptr) {
3909         LDKC2Tuple_PublicKeyTypeZ *tuple = (LDKC2Tuple_PublicKeyTypeZ*)(ptr & ~1);
3910         int8_tArray a_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3911         memcpy((uint8_t*)(a_arr + 4), tuple->a.compressed_form, 33);
3912         return a_arr;
3913 }
3914 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PublicKeyTypeZ_get_b(uint32_t ptr) {
3915         LDKC2Tuple_PublicKeyTypeZ *tuple = (LDKC2Tuple_PublicKeyTypeZ*)(ptr & ~1);
3916         LDKType* b_ret =MALLOC(sizeof(LDKType), "LDKType");
3917         *b_ret = Type_clone(&tuple->b);
3918         return (uint64_t)b_ret;
3919 }
3920 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_PublicKeyTypeZZ_new(uint32_tArray elems) {
3921         LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ");
3922         ret->datalen = *((uint32_t*)elems);
3923         if (ret->datalen == 0) {
3924                 ret->data = NULL;
3925         } else {
3926                 ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ Data");
3927                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3928                 for (size_t i = 0; i < ret->datalen; i++) {
3929                         uint32_t arr_elem = java_elems[i];
3930                         LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1);
3931                         arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
3932                         ret->data[i] = arr_elem_conv;
3933                 }
3934         }
3935         return (uint64_t)ret;
3936 }
3937 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
3938         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
3939         for (size_t i = 0; i < ret.datalen; i++) {
3940                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
3941         }
3942         return ret;
3943 }
3944 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
3945         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3946 }
3947 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
3948         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
3949         CHECK(val->result_ok);
3950         return *val->contents.result;
3951 }
3952 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
3953         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
3954         CHECK(!val->result_ok);
3955         LDKLightningError err_var = (*val->contents.err);
3956         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3957         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3958         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3959         return err_ref;
3960 }
3961 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
3962         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
3963         LDKChannelAnnouncement a_conv;
3964         a_conv.inner = (void*)(a & (~1));
3965         a_conv.is_owned = (a & 1) || (a == 0);
3966         a_conv = ChannelAnnouncement_clone(&a_conv);
3967         ret->a = a_conv;
3968         LDKChannelUpdate b_conv;
3969         b_conv.inner = (void*)(b & (~1));
3970         b_conv.is_owned = (b & 1) || (b == 0);
3971         b_conv = ChannelUpdate_clone(&b_conv);
3972         ret->b = b_conv;
3973         LDKChannelUpdate c_conv;
3974         c_conv.inner = (void*)(c & (~1));
3975         c_conv.is_owned = (c & 1) || (c == 0);
3976         c_conv = ChannelUpdate_clone(&c_conv);
3977         ret->c = c_conv;
3978         return (uint64_t)ret;
3979 }
3980 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t ptr) {
3981         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3982         LDKChannelAnnouncement a_var = tuple->a;
3983         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3984         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3985         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3986         return a_ref;
3987 }
3988 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t ptr) {
3989         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3990         LDKChannelUpdate b_var = tuple->b;
3991         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3992         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3993         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
3994         return b_ref;
3995 }
3996 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t ptr) {
3997         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3998         LDKChannelUpdate c_var = tuple->c;
3999         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4000         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4001         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4002         return c_ref;
4003 }
4004 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
4005         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
4006         ret->datalen = *((uint32_t*)elems);
4007         if (ret->datalen == 0) {
4008                 ret->data = NULL;
4009         } else {
4010                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
4011                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4012                 for (size_t i = 0; i < ret->datalen; i++) {
4013                         uint32_t arr_elem = java_elems[i];
4014                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
4015                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
4016                         ret->data[i] = arr_elem_conv;
4017                 }
4018         }
4019         return (uint64_t)ret;
4020 }
4021 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4022         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4023         for (size_t i = 0; i < ret.datalen; i++) {
4024                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4025         }
4026         return ret;
4027 }
4028 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
4029         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
4030         ret->datalen = *((uint32_t*)elems);
4031         if (ret->datalen == 0) {
4032                 ret->data = NULL;
4033         } else {
4034                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
4035                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4036                 for (size_t i = 0; i < ret->datalen; i++) {
4037                         uint32_t arr_elem = java_elems[i];
4038                         LDKNodeAnnouncement arr_elem_conv;
4039                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4040                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4041                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
4042                         ret->data[i] = arr_elem_conv;
4043                 }
4044         }
4045         return (uint64_t)ret;
4046 }
4047 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
4048         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
4049         for (size_t i = 0; i < ret.datalen; i++) {
4050                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
4051         }
4052         return ret;
4053 }
4054 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
4055         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
4056 }
4057 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
4058         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4059         CHECK(val->result_ok);
4060         LDKCVec_u8Z res_var = (*val->contents.result);
4061         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4062         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
4063         return res_arr;
4064 }
4065 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
4066         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4067         CHECK(!val->result_ok);
4068         LDKPeerHandleError err_var = (*val->contents.err);
4069         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4070         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4071         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4072         return err_ref;
4073 }
4074 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
4075         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
4076 }
4077 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
4078         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4079         CHECK(val->result_ok);
4080         return *val->contents.result;
4081 }
4082 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
4083         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4084         CHECK(!val->result_ok);
4085         LDKPeerHandleError err_var = (*val->contents.err);
4086         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4087         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4088         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4089         return err_ref;
4090 }
4091 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
4092         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
4093 }
4094 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
4095         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4096         CHECK(val->result_ok);
4097         return *val->contents.result;
4098 }
4099 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
4100         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4101         CHECK(!val->result_ok);
4102         LDKPeerHandleError err_var = (*val->contents.err);
4103         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4104         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4105         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4106         return err_ref;
4107 }
4108 typedef struct LDKAccess_JCalls {
4109         atomic_size_t refcnt;
4110         uint32_t get_utxo_meth;
4111 } LDKAccess_JCalls;
4112 static void LDKAccess_JCalls_free(void* this_arg) {
4113         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4114         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4115                 js_free(j_calls->get_utxo_meth);
4116                 FREE(j_calls);
4117         }
4118 }
4119 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4120         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4121         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4122         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4123         uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4124         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4125         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
4126         return ret_conv;
4127 }
4128 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
4129         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
4130         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4131 }
4132 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4133         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4134         atomic_init(&calls->refcnt, 1);
4135         //TODO: Assign calls->o from o
4136
4137         LDKAccess ret = {
4138                 .this_arg = (void*) calls,
4139                 .get_utxo = get_utxo_LDKAccess_jcall,
4140                 .free = LDKAccess_JCalls_free,
4141         };
4142         return ret;
4143 }
4144 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4145         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4146         *res_ptr = LDKAccess_init(o);
4147         return (long)res_ptr;
4148 }
4149 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4150         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
4151         unsigned char genesis_hash_arr[32];
4152         CHECK(*((uint32_t*)genesis_hash) == 32);
4153         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4154         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4155         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4156         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4157         return (uint64_t)ret_conv;
4158 }
4159
4160 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_AccessZ_ref_from_ptr(uint32_t ptr) {
4161         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
4162         switch(obj->tag) {
4163                 case LDKCOption_AccessZ_Some: {
4164                         LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess");
4165                         *some_ret = obj->some;
4166                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
4167                         return 0 /* LDKCOption_AccessZ - Some */; (void) (uint64_t)some_ret;
4168                 }
4169                 case LDKCOption_AccessZ_None: {
4170                         return 0 /* LDKCOption_AccessZ - None */;
4171                 }
4172                 default: abort();
4173         }
4174 }
4175 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
4176         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
4177 }
4178 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
4179         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4180         CHECK(val->result_ok);
4181         LDKDirectionalChannelInfo res_var = (*val->contents.result);
4182         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4183         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4184         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4185         return res_ref;
4186 }
4187 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
4188         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4189         CHECK(!val->result_ok);
4190         LDKDecodeError err_var = (*val->contents.err);
4191         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4192         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4193         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4194         return err_ref;
4195 }
4196 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
4197         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
4198 }
4199 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
4200         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4201         CHECK(val->result_ok);
4202         LDKChannelInfo res_var = (*val->contents.result);
4203         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4204         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4205         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4206         return res_ref;
4207 }
4208 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
4209         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4210         CHECK(!val->result_ok);
4211         LDKDecodeError err_var = (*val->contents.err);
4212         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4213         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4214         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4215         return err_ref;
4216 }
4217 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
4218         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
4219 }
4220 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
4221         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4222         CHECK(val->result_ok);
4223         LDKRoutingFees res_var = (*val->contents.result);
4224         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4225         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4226         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4227         return res_ref;
4228 }
4229 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
4230         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4231         CHECK(!val->result_ok);
4232         LDKDecodeError err_var = (*val->contents.err);
4233         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4234         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4235         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4236         return err_ref;
4237 }
4238 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
4239         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
4240 }
4241 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
4242         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4243         CHECK(val->result_ok);
4244         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
4245         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4246         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4247         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4248         return res_ref;
4249 }
4250 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
4251         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4252         CHECK(!val->result_ok);
4253         LDKDecodeError err_var = (*val->contents.err);
4254         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4255         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4256         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4257         return err_ref;
4258 }
4259 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
4260         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
4261         ret->datalen = *((uint32_t*)elems);
4262         if (ret->datalen == 0) {
4263                 ret->data = NULL;
4264         } else {
4265                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
4266                 int64_t *java_elems = (int64_t*)(elems + 4);
4267                 for (size_t i = 0; i < ret->datalen; i++) {
4268                         ret->data[i] = java_elems[i];
4269                 }
4270         }
4271         return (uint64_t)ret;
4272 }
4273 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
4274         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
4275         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
4276         return ret;
4277 }
4278 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
4279         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
4280 }
4281 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
4282         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
4283         CHECK(val->result_ok);
4284         LDKNodeInfo 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_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
4291         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(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_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
4300         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
4301 }
4302 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
4303         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
4304         CHECK(val->result_ok);
4305         LDKNetworkGraph 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_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
4312         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(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_NetAddressu8Z_result_ok(uint32_t arg) {
4321         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
4322 }
4323 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
4324         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
4325         CHECK(val->result_ok);
4326         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4327         return res_ref;
4328 }
4329 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
4330         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
4331         CHECK(!val->result_ok);
4332         return *val->contents.err;
4333 }
4334 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
4335         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
4336 }
4337 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
4338         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
4339         CHECK(val->result_ok);
4340         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
4341         *res_conv = (*val->contents.result);
4342         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
4343         return (uint64_t)res_conv;
4344 }
4345 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
4346         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
4347         CHECK(!val->result_ok);
4348         LDKDecodeError err_var = (*val->contents.err);
4349         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4350         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4351         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4352         return err_ref;
4353 }
4354 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_result_ok(uint32_t arg) {
4355         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
4356 }
4357 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_ok(uint32_t arg) {
4358         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
4359         CHECK(val->result_ok);
4360         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4361         return res_ref;
4362 }
4363 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_err(uint32_t arg) {
4364         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
4365         CHECK(!val->result_ok);
4366         LDKDecodeError err_var = (*val->contents.err);
4367         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4368         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4369         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4370         return err_ref;
4371 }
4372 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
4373         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
4374         ret->datalen = *((uint32_t*)elems);
4375         if (ret->datalen == 0) {
4376                 ret->data = NULL;
4377         } else {
4378                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
4379                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4380                 for (size_t i = 0; i < ret->datalen; i++) {
4381                         uint32_t arr_elem = java_elems[i];
4382                         LDKUpdateAddHTLC arr_elem_conv;
4383                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4384                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4385                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
4386                         ret->data[i] = arr_elem_conv;
4387                 }
4388         }
4389         return (uint64_t)ret;
4390 }
4391 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
4392         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
4393         for (size_t i = 0; i < ret.datalen; i++) {
4394                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
4395         }
4396         return ret;
4397 }
4398 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
4399         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
4400         ret->datalen = *((uint32_t*)elems);
4401         if (ret->datalen == 0) {
4402                 ret->data = NULL;
4403         } else {
4404                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
4405                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4406                 for (size_t i = 0; i < ret->datalen; i++) {
4407                         uint32_t arr_elem = java_elems[i];
4408                         LDKUpdateFulfillHTLC arr_elem_conv;
4409                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4410                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4411                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
4412                         ret->data[i] = arr_elem_conv;
4413                 }
4414         }
4415         return (uint64_t)ret;
4416 }
4417 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
4418         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
4419         for (size_t i = 0; i < ret.datalen; i++) {
4420                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
4421         }
4422         return ret;
4423 }
4424 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
4425         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
4426         ret->datalen = *((uint32_t*)elems);
4427         if (ret->datalen == 0) {
4428                 ret->data = NULL;
4429         } else {
4430                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
4431                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4432                 for (size_t i = 0; i < ret->datalen; i++) {
4433                         uint32_t arr_elem = java_elems[i];
4434                         LDKUpdateFailHTLC arr_elem_conv;
4435                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4436                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4437                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
4438                         ret->data[i] = arr_elem_conv;
4439                 }
4440         }
4441         return (uint64_t)ret;
4442 }
4443 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
4444         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
4445         for (size_t i = 0; i < ret.datalen; i++) {
4446                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
4447         }
4448         return ret;
4449 }
4450 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
4451         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
4452         ret->datalen = *((uint32_t*)elems);
4453         if (ret->datalen == 0) {
4454                 ret->data = NULL;
4455         } else {
4456                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
4457                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4458                 for (size_t i = 0; i < ret->datalen; i++) {
4459                         uint32_t arr_elem = java_elems[i];
4460                         LDKUpdateFailMalformedHTLC arr_elem_conv;
4461                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4462                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4463                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
4464                         ret->data[i] = arr_elem_conv;
4465                 }
4466         }
4467         return (uint64_t)ret;
4468 }
4469 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
4470         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
4471         for (size_t i = 0; i < ret.datalen; i++) {
4472                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
4473         }
4474         return ret;
4475 }
4476 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
4477         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
4478 }
4479 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
4480         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4481         CHECK(val->result_ok);
4482         LDKAcceptChannel res_var = (*val->contents.result);
4483         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4484         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4485         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4486         return res_ref;
4487 }
4488 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
4489         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4490         CHECK(!val->result_ok);
4491         LDKDecodeError err_var = (*val->contents.err);
4492         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4493         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4494         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4495         return err_ref;
4496 }
4497 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
4498         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
4499 }
4500 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
4501         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4502         CHECK(val->result_ok);
4503         LDKAnnouncementSignatures res_var = (*val->contents.result);
4504         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4505         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4506         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4507         return res_ref;
4508 }
4509 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
4510         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4511         CHECK(!val->result_ok);
4512         LDKDecodeError err_var = (*val->contents.err);
4513         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4514         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4515         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4516         return err_ref;
4517 }
4518 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
4519         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
4520 }
4521 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
4522         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4523         CHECK(val->result_ok);
4524         LDKChannelReestablish res_var = (*val->contents.result);
4525         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4526         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4527         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4528         return res_ref;
4529 }
4530 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
4531         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4532         CHECK(!val->result_ok);
4533         LDKDecodeError err_var = (*val->contents.err);
4534         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4535         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4536         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4537         return err_ref;
4538 }
4539 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4540         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
4541 }
4542 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4543         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4544         CHECK(val->result_ok);
4545         LDKClosingSigned res_var = (*val->contents.result);
4546         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4547         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4548         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4549         return res_ref;
4550 }
4551 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
4552         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4553         CHECK(!val->result_ok);
4554         LDKDecodeError err_var = (*val->contents.err);
4555         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4556         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4557         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4558         return err_ref;
4559 }
4560 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_result_ok(uint32_t arg) {
4561         return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok;
4562 }
4563 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t arg) {
4564         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
4565         CHECK(val->result_ok);
4566         LDKClosingSignedFeeRange res_var = (*val->contents.result);
4567         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4568         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4569         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4570         return res_ref;
4571 }
4572 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t arg) {
4573         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
4574         CHECK(!val->result_ok);
4575         LDKDecodeError err_var = (*val->contents.err);
4576         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4577         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4578         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4579         return err_ref;
4580 }
4581 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
4582         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
4583 }
4584 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
4585         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4586         CHECK(val->result_ok);
4587         LDKCommitmentSigned res_var = (*val->contents.result);
4588         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4589         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4590         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4591         return res_ref;
4592 }
4593 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
4594         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4595         CHECK(!val->result_ok);
4596         LDKDecodeError err_var = (*val->contents.err);
4597         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4598         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4599         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4600         return err_ref;
4601 }
4602 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
4603         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
4604 }
4605 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
4606         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4607         CHECK(val->result_ok);
4608         LDKFundingCreated res_var = (*val->contents.result);
4609         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4610         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4611         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4612         return res_ref;
4613 }
4614 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
4615         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4616         CHECK(!val->result_ok);
4617         LDKDecodeError err_var = (*val->contents.err);
4618         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4619         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4620         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4621         return err_ref;
4622 }
4623 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4624         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
4625 }
4626 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4627         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4628         CHECK(val->result_ok);
4629         LDKFundingSigned res_var = (*val->contents.result);
4630         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4631         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4632         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4633         return res_ref;
4634 }
4635 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
4636         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4637         CHECK(!val->result_ok);
4638         LDKDecodeError err_var = (*val->contents.err);
4639         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4640         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4641         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4642         return err_ref;
4643 }
4644 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
4645         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
4646 }
4647 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
4648         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4649         CHECK(val->result_ok);
4650         LDKFundingLocked res_var = (*val->contents.result);
4651         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4652         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4653         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4654         return res_ref;
4655 }
4656 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
4657         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4658         CHECK(!val->result_ok);
4659         LDKDecodeError err_var = (*val->contents.err);
4660         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4661         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4662         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4663         return err_ref;
4664 }
4665 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
4666         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
4667 }
4668 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
4669         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4670         CHECK(val->result_ok);
4671         LDKInit res_var = (*val->contents.result);
4672         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4673         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4674         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4675         return res_ref;
4676 }
4677 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
4678         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4679         CHECK(!val->result_ok);
4680         LDKDecodeError err_var = (*val->contents.err);
4681         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4682         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4683         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4684         return err_ref;
4685 }
4686 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
4687         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
4688 }
4689 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
4690         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4691         CHECK(val->result_ok);
4692         LDKOpenChannel res_var = (*val->contents.result);
4693         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4694         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4695         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4696         return res_ref;
4697 }
4698 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
4699         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4700         CHECK(!val->result_ok);
4701         LDKDecodeError err_var = (*val->contents.err);
4702         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4703         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4704         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4705         return err_ref;
4706 }
4707 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
4708         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
4709 }
4710 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
4711         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4712         CHECK(val->result_ok);
4713         LDKRevokeAndACK res_var = (*val->contents.result);
4714         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4715         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4716         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4717         return res_ref;
4718 }
4719 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
4720         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4721         CHECK(!val->result_ok);
4722         LDKDecodeError err_var = (*val->contents.err);
4723         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4724         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4725         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4726         return err_ref;
4727 }
4728 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
4729         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
4730 }
4731 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
4732         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4733         CHECK(val->result_ok);
4734         LDKShutdown res_var = (*val->contents.result);
4735         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4736         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4737         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4738         return res_ref;
4739 }
4740 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
4741         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4742         CHECK(!val->result_ok);
4743         LDKDecodeError err_var = (*val->contents.err);
4744         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4745         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4746         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4747         return err_ref;
4748 }
4749 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4750         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
4751 }
4752 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4753         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4754         CHECK(val->result_ok);
4755         LDKUpdateFailHTLC res_var = (*val->contents.result);
4756         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4757         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4758         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4759         return res_ref;
4760 }
4761 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
4762         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4763         CHECK(!val->result_ok);
4764         LDKDecodeError err_var = (*val->contents.err);
4765         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4766         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4767         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4768         return err_ref;
4769 }
4770 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4771         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
4772 }
4773 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4774         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4775         CHECK(val->result_ok);
4776         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
4777         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4778         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4779         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4780         return res_ref;
4781 }
4782 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
4783         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4784         CHECK(!val->result_ok);
4785         LDKDecodeError err_var = (*val->contents.err);
4786         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4787         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4788         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4789         return err_ref;
4790 }
4791 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
4792         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
4793 }
4794 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
4795         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4796         CHECK(val->result_ok);
4797         LDKUpdateFee res_var = (*val->contents.result);
4798         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4799         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4800         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4801         return res_ref;
4802 }
4803 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
4804         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4805         CHECK(!val->result_ok);
4806         LDKDecodeError err_var = (*val->contents.err);
4807         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4808         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4809         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4810         return err_ref;
4811 }
4812 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4813         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
4814 }
4815 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4816         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4817         CHECK(val->result_ok);
4818         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
4819         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4820         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4821         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4822         return res_ref;
4823 }
4824 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
4825         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4826         CHECK(!val->result_ok);
4827         LDKDecodeError err_var = (*val->contents.err);
4828         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4829         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4830         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4831         return err_ref;
4832 }
4833 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4834         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
4835 }
4836 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4837         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4838         CHECK(val->result_ok);
4839         LDKUpdateAddHTLC res_var = (*val->contents.result);
4840         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4841         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4842         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4843         return res_ref;
4844 }
4845 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
4846         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4847         CHECK(!val->result_ok);
4848         LDKDecodeError err_var = (*val->contents.err);
4849         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4850         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4851         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4852         return err_ref;
4853 }
4854 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
4855         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
4856 }
4857 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
4858         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4859         CHECK(val->result_ok);
4860         LDKPing res_var = (*val->contents.result);
4861         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4862         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4863         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4864         return res_ref;
4865 }
4866 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
4867         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4868         CHECK(!val->result_ok);
4869         LDKDecodeError err_var = (*val->contents.err);
4870         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4871         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4872         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4873         return err_ref;
4874 }
4875 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
4876         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
4877 }
4878 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
4879         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4880         CHECK(val->result_ok);
4881         LDKPong res_var = (*val->contents.result);
4882         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4883         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4884         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4885         return res_ref;
4886 }
4887 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
4888         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4889         CHECK(!val->result_ok);
4890         LDKDecodeError err_var = (*val->contents.err);
4891         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4892         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4893         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4894         return err_ref;
4895 }
4896 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4897         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4898 }
4899 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4900         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4901         CHECK(val->result_ok);
4902         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
4903         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4904         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4905         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4906         return res_ref;
4907 }
4908 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4909         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4910         CHECK(!val->result_ok);
4911         LDKDecodeError err_var = (*val->contents.err);
4912         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4913         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4914         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4915         return err_ref;
4916 }
4917 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4918         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4919 }
4920 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4921         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4922         CHECK(val->result_ok);
4923         LDKChannelAnnouncement res_var = (*val->contents.result);
4924         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4925         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4926         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4927         return res_ref;
4928 }
4929 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4930         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4931         CHECK(!val->result_ok);
4932         LDKDecodeError err_var = (*val->contents.err);
4933         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4934         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4935         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4936         return err_ref;
4937 }
4938 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
4939         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
4940 }
4941 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
4942         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4943         CHECK(val->result_ok);
4944         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
4945         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4946         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4947         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4948         return res_ref;
4949 }
4950 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
4951         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4952         CHECK(!val->result_ok);
4953         LDKDecodeError err_var = (*val->contents.err);
4954         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4955         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4956         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4957         return err_ref;
4958 }
4959 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
4960         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
4961 }
4962 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
4963         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4964         CHECK(val->result_ok);
4965         LDKChannelUpdate res_var = (*val->contents.result);
4966         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4967         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4968         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4969         return res_ref;
4970 }
4971 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
4972         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4973         CHECK(!val->result_ok);
4974         LDKDecodeError err_var = (*val->contents.err);
4975         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4976         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4977         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4978         return err_ref;
4979 }
4980 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
4981         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
4982 }
4983 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
4984         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4985         CHECK(val->result_ok);
4986         LDKErrorMessage res_var = (*val->contents.result);
4987         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4988         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4989         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4990         return res_ref;
4991 }
4992 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
4993         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4994         CHECK(!val->result_ok);
4995         LDKDecodeError err_var = (*val->contents.err);
4996         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4997         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4998         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4999         return err_ref;
5000 }
5001 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5002         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5003 }
5004 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5005         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5006         CHECK(val->result_ok);
5007         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5008         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5009         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5010         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5011         return res_ref;
5012 }
5013 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5014         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5015         CHECK(!val->result_ok);
5016         LDKDecodeError err_var = (*val->contents.err);
5017         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5018         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5019         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5020         return err_ref;
5021 }
5022 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5023         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5024 }
5025 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5026         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5027         CHECK(val->result_ok);
5028         LDKNodeAnnouncement res_var = (*val->contents.result);
5029         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5030         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5031         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5032         return res_ref;
5033 }
5034 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5035         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5036         CHECK(!val->result_ok);
5037         LDKDecodeError err_var = (*val->contents.err);
5038         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5039         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5040         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5041         return err_ref;
5042 }
5043 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
5044         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
5045 }
5046 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
5047         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5048         CHECK(val->result_ok);
5049         LDKQueryShortChannelIds res_var = (*val->contents.result);
5050         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5051         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5052         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5053         return res_ref;
5054 }
5055 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
5056         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5057         CHECK(!val->result_ok);
5058         LDKDecodeError err_var = (*val->contents.err);
5059         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5060         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5061         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5062         return err_ref;
5063 }
5064 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
5065         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
5066 }
5067 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
5068         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5069         CHECK(val->result_ok);
5070         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5071         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5072         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5073         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5074         return res_ref;
5075 }
5076 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
5077         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5078         CHECK(!val->result_ok);
5079         LDKDecodeError err_var = (*val->contents.err);
5080         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5081         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5082         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5083         return err_ref;
5084 }
5085 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
5086         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
5087 }
5088 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
5089         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5090         CHECK(val->result_ok);
5091         LDKQueryChannelRange res_var = (*val->contents.result);
5092         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5093         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5094         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5095         return res_ref;
5096 }
5097 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
5098         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5099         CHECK(!val->result_ok);
5100         LDKDecodeError err_var = (*val->contents.err);
5101         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5102         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5103         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5104         return err_ref;
5105 }
5106 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
5107         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
5108 }
5109 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
5110         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5111         CHECK(val->result_ok);
5112         LDKReplyChannelRange res_var = (*val->contents.result);
5113         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5114         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5115         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5116         return res_ref;
5117 }
5118 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
5119         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5120         CHECK(!val->result_ok);
5121         LDKDecodeError err_var = (*val->contents.err);
5122         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5123         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5124         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5125         return err_ref;
5126 }
5127 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
5128         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
5129 }
5130 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
5131         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5132         CHECK(val->result_ok);
5133         LDKGossipTimestampFilter res_var = (*val->contents.result);
5134         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5135         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5136         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5137         return res_ref;
5138 }
5139 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
5140         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5141         CHECK(!val->result_ok);
5142         LDKDecodeError err_var = (*val->contents.err);
5143         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5144         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5145         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5146         return err_ref;
5147 }
5148 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
5149         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
5150         switch(obj->tag) {
5151                 case LDKSignOrCreationError_SignError: {
5152                         return 0 /* LDKSignOrCreationError - SignError */;
5153                 }
5154                 case LDKSignOrCreationError_CreationError: {
5155                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
5156                         return 0 /* LDKSignOrCreationError - CreationError */; (void) creation_error_conv;
5157                 }
5158                 default: abort();
5159         }
5160 }
5161 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_result_ok(uint32_t arg) {
5162         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
5163 }
5164 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t arg) {
5165         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5166         CHECK(val->result_ok);
5167         LDKInvoice res_var = (*val->contents.result);
5168         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5169         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5170         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5171         return res_ref;
5172 }
5173 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
5174         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5175         CHECK(!val->result_ok);
5176         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5177         return err_ref;
5178 }
5179 typedef struct LDKFilter_JCalls {
5180         atomic_size_t refcnt;
5181         uint32_t register_tx_meth;
5182         uint32_t register_output_meth;
5183 } LDKFilter_JCalls;
5184 static void LDKFilter_JCalls_free(void* this_arg) {
5185         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5186         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5187                 js_free(j_calls->register_tx_meth);
5188                 js_free(j_calls->register_output_meth);
5189                 FREE(j_calls);
5190         }
5191 }
5192 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5193         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5194         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5195         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5196         LDKu8slice script_pubkey_var = script_pubkey;
5197         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5198         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
5199         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5200 }
5201 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5202         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5203         LDKWatchedOutput output_var = output;
5204         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5205         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5206         uint64_t output_ref = (uint64_t)output_var.inner;
5207         if (output_var.is_owned) {
5208                 output_ref |= 1;
5209         }
5210         uint32_t ret = js_invoke_function_1(j_calls->register_output_meth, output_ref);
5211         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
5212         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
5213         return ret_conv;
5214 }
5215 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
5216         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
5217         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5218 }
5219 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
5220         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5221         atomic_init(&calls->refcnt, 1);
5222         //TODO: Assign calls->o from o
5223
5224         LDKFilter ret = {
5225                 .this_arg = (void*) calls,
5226                 .register_tx = register_tx_LDKFilter_jcall,
5227                 .register_output = register_output_LDKFilter_jcall,
5228                 .free = LDKFilter_JCalls_free,
5229         };
5230         return ret;
5231 }
5232 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
5233         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5234         *res_ptr = LDKFilter_init(o);
5235         return (long)res_ptr;
5236 }
5237 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5238         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5239         unsigned char txid_arr[32];
5240         CHECK(*((uint32_t*)txid) == 32);
5241         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5242         unsigned char (*txid_ref)[32] = &txid_arr;
5243         LDKu8slice script_pubkey_ref;
5244         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
5245         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
5246         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5247 }
5248
5249 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5250         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5251         LDKWatchedOutput output_conv;
5252         output_conv.inner = (void*)(output & (~1));
5253         output_conv.is_owned = (output & 1) || (output == 0);
5254         output_conv = WatchedOutput_clone(&output_conv);
5255         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5256         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5257         uint64_t ret_ref = (uint64_t)ret_copy;
5258         return ret_ref;
5259 }
5260
5261 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_FilterZ_ref_from_ptr(uint32_t ptr) {
5262         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
5263         switch(obj->tag) {
5264                 case LDKCOption_FilterZ_Some: {
5265                         LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter");
5266                         *some_ret = obj->some;
5267                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
5268                         return 0 /* LDKCOption_FilterZ - Some */; (void) (uint64_t)some_ret;
5269                 }
5270                 case LDKCOption_FilterZ_None: {
5271                         return 0 /* LDKCOption_FilterZ - None */;
5272                 }
5273                 default: abort();
5274         }
5275 }
5276 typedef struct LDKMessageSendEventsProvider_JCalls {
5277         atomic_size_t refcnt;
5278         uint32_t get_and_clear_pending_msg_events_meth;
5279 } LDKMessageSendEventsProvider_JCalls;
5280 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
5281         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5282         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5283                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
5284                 FREE(j_calls);
5285         }
5286 }
5287 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
5288         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5289         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
5290         LDKCVec_MessageSendEventZ ret_constr;
5291         ret_constr.datalen = *((uint32_t*)ret);
5292         if (ret_constr.datalen > 0)
5293                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
5294         else
5295                 ret_constr.data = NULL;
5296         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5297         for (size_t s = 0; s < ret_constr.datalen; s++) {
5298                 uint32_t ret_conv_18 = ret_vals[s];
5299                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
5300                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
5301                 ret_constr.data[s] = ret_conv_18_conv;
5302         }
5303         return ret_constr;
5304 }
5305 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
5306         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
5307         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5308 }
5309 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
5310         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
5311         atomic_init(&calls->refcnt, 1);
5312         //TODO: Assign calls->o from o
5313
5314         LDKMessageSendEventsProvider ret = {
5315                 .this_arg = (void*) calls,
5316                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
5317                 .free = LDKMessageSendEventsProvider_JCalls_free,
5318         };
5319         return ret;
5320 }
5321 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
5322         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
5323         *res_ptr = LDKMessageSendEventsProvider_init(o);
5324         return (long)res_ptr;
5325 }
5326 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
5327         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
5328         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
5329         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5330         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5331         for (size_t s = 0; s < ret_var.datalen; s++) {
5332                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
5333                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
5334                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
5335                 ret_arr_ptr[s] = ret_conv_18_ref;
5336         }
5337         FREE(ret_var.data);
5338         return ret_arr;
5339 }
5340
5341 typedef struct LDKEventHandler_JCalls {
5342         atomic_size_t refcnt;
5343         uint32_t handle_event_meth;
5344 } LDKEventHandler_JCalls;
5345 static void LDKEventHandler_JCalls_free(void* this_arg) {
5346         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
5347         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5348                 js_free(j_calls->handle_event_meth);
5349                 FREE(j_calls);
5350         }
5351 }
5352 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
5353         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
5354         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
5355         *ret_event = Event_clone(event);
5356         js_invoke_function_1(j_calls->handle_event_meth, (uint64_t)ret_event);
5357 }
5358 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
5359         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
5360         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5361 }
5362 static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) {
5363         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
5364         atomic_init(&calls->refcnt, 1);
5365         //TODO: Assign calls->o from o
5366
5367         LDKEventHandler ret = {
5368                 .this_arg = (void*) calls,
5369                 .handle_event = handle_event_LDKEventHandler_jcall,
5370                 .free = LDKEventHandler_JCalls_free,
5371         };
5372         return ret;
5373 }
5374 long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS Object Reference */void* o) {
5375         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
5376         *res_ptr = LDKEventHandler_init(o);
5377         return (long)res_ptr;
5378 }
5379 void  __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
5380         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
5381         LDKEvent* event_conv = (LDKEvent*)event;
5382         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
5383 }
5384
5385 typedef struct LDKEventsProvider_JCalls {
5386         atomic_size_t refcnt;
5387         uint32_t process_pending_events_meth;
5388 } LDKEventsProvider_JCalls;
5389 static void LDKEventsProvider_JCalls_free(void* this_arg) {
5390         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5391         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5392                 js_free(j_calls->process_pending_events_meth);
5393                 FREE(j_calls);
5394         }
5395 }
5396 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
5397         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5398         LDKEventHandler* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
5399         *handler_ret = handler;
5400         js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)handler_ret);
5401 }
5402 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
5403         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
5404         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5405 }
5406 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
5407         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
5408         atomic_init(&calls->refcnt, 1);
5409         //TODO: Assign calls->o from o
5410
5411         LDKEventsProvider ret = {
5412                 .this_arg = (void*) calls,
5413                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
5414                 .free = LDKEventsProvider_JCalls_free,
5415         };
5416         return ret;
5417 }
5418 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
5419         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5420         *res_ptr = LDKEventsProvider_init(o);
5421         return (long)res_ptr;
5422 }
5423 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
5424         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
5425         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
5426         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
5427 }
5428
5429 typedef struct LDKListen_JCalls {
5430         atomic_size_t refcnt;
5431         uint32_t block_connected_meth;
5432         uint32_t block_disconnected_meth;
5433 } LDKListen_JCalls;
5434 static void LDKListen_JCalls_free(void* this_arg) {
5435         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5436         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5437                 js_free(j_calls->block_connected_meth);
5438                 js_free(j_calls->block_disconnected_meth);
5439                 FREE(j_calls);
5440         }
5441 }
5442 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
5443         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5444         LDKu8slice block_var = block;
5445         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5446         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
5447         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
5448 }
5449 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5450         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5451         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5452         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5453         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
5454 }
5455 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
5456         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
5457         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5458 }
5459 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
5460         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
5461         atomic_init(&calls->refcnt, 1);
5462         //TODO: Assign calls->o from o
5463
5464         LDKListen ret = {
5465                 .this_arg = (void*) calls,
5466                 .block_connected = block_connected_LDKListen_jcall,
5467                 .block_disconnected = block_disconnected_LDKListen_jcall,
5468                 .free = LDKListen_JCalls_free,
5469         };
5470         return ret;
5471 }
5472 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
5473         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
5474         *res_ptr = LDKListen_init(o);
5475         return (long)res_ptr;
5476 }
5477 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
5478         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5479         LDKu8slice block_ref;
5480         block_ref.datalen = *((uint32_t*)block);
5481         block_ref.data = (int8_t*)(block + 4);
5482         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
5483 }
5484
5485 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
5486         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5487         unsigned char header_arr[80];
5488         CHECK(*((uint32_t*)header) == 80);
5489         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5490         unsigned char (*header_ref)[80] = &header_arr;
5491         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
5492 }
5493
5494 typedef struct LDKConfirm_JCalls {
5495         atomic_size_t refcnt;
5496         uint32_t transactions_confirmed_meth;
5497         uint32_t transaction_unconfirmed_meth;
5498         uint32_t best_block_updated_meth;
5499         uint32_t get_relevant_txids_meth;
5500 } LDKConfirm_JCalls;
5501 static void LDKConfirm_JCalls_free(void* this_arg) {
5502         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5503         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5504                 js_free(j_calls->transactions_confirmed_meth);
5505                 js_free(j_calls->transaction_unconfirmed_meth);
5506                 js_free(j_calls->best_block_updated_meth);
5507                 js_free(j_calls->get_relevant_txids_meth);
5508                 FREE(j_calls);
5509         }
5510 }
5511 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
5512         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5513         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5514         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5515         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
5516         uint32_tArray txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5517         uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
5518         for (size_t e = 0; e < txdata_var.datalen; e++) {
5519                 LDKC2Tuple_usizeTransactionZ* txdata_conv_30_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
5520                 *txdata_conv_30_ref = txdata_var.data[e];
5521                 txdata_arr_ptr[e] = (uint64_t)txdata_conv_30_ref;
5522         }
5523         FREE(txdata_var.data);
5524         js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
5525 }
5526 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
5527         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5528         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5529         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5530         js_invoke_function_1(j_calls->transaction_unconfirmed_meth, txid_arr);
5531 }
5532 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5533         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5534         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5535         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5536         js_invoke_function_2(j_calls->best_block_updated_meth, header_arr, height);
5537 }
5538 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
5539         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5540         ptrArray ret = js_invoke_function_0(j_calls->get_relevant_txids_meth);
5541         LDKCVec_TxidZ ret_constr;
5542         ret_constr.datalen = *((uint32_t*)ret);
5543         if (ret_constr.datalen > 0)
5544                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
5545         else
5546                 ret_constr.data = NULL;
5547         int8_tArray* ret_vals = (int8_tArray*)(ret + 4);
5548         for (size_t m = 0; m < ret_constr.datalen; m++) {
5549                 int8_tArray ret_conv_12 = ret_vals[m];
5550                 LDKThirtyTwoBytes ret_conv_12_ref;
5551                 CHECK(*((uint32_t*)ret_conv_12) == 32);
5552                 memcpy(ret_conv_12_ref.data, (uint8_t*)(ret_conv_12 + 4), 32);
5553                 ret_constr.data[m] = ret_conv_12_ref;
5554         }
5555         return ret_constr;
5556 }
5557 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
5558         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
5559         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5560 }
5561 static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) {
5562         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
5563         atomic_init(&calls->refcnt, 1);
5564         //TODO: Assign calls->o from o
5565
5566         LDKConfirm ret = {
5567                 .this_arg = (void*) calls,
5568                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
5569                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
5570                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
5571                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
5572                 .free = LDKConfirm_JCalls_free,
5573         };
5574         return ret;
5575 }
5576 long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object Reference */void* o) {
5577         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
5578         *res_ptr = LDKConfirm_init(o);
5579         return (long)res_ptr;
5580 }
5581 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
5582         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5583         unsigned char header_arr[80];
5584         CHECK(*((uint32_t*)header) == 80);
5585         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5586         unsigned char (*header_ref)[80] = &header_arr;
5587         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5588         txdata_constr.datalen = *((uint32_t*)txdata);
5589         if (txdata_constr.datalen > 0)
5590                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5591         else
5592                 txdata_constr.data = NULL;
5593         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
5594         for (size_t e = 0; e < txdata_constr.datalen; e++) {
5595                 uint32_t txdata_conv_30 = txdata_vals[e];
5596                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
5597                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
5598                 txdata_constr.data[e] = txdata_conv_30_conv;
5599         }
5600         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
5601 }
5602
5603 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
5604         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5605         unsigned char txid_arr[32];
5606         CHECK(*((uint32_t*)txid) == 32);
5607         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5608         unsigned char (*txid_ref)[32] = &txid_arr;
5609         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
5610 }
5611
5612 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
5613         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5614         unsigned char header_arr[80];
5615         CHECK(*((uint32_t*)header) == 80);
5616         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5617         unsigned char (*header_ref)[80] = &header_arr;
5618         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
5619 }
5620
5621 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
5622         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5623         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
5624         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
5625         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
5626         for (size_t m = 0; m < ret_var.datalen; m++) {
5627                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5628                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
5629                 ret_arr_ptr[m] = ret_conv_12_arr;
5630         }
5631         FREE(ret_var.data);
5632         return ret_arr;
5633 }
5634
5635 typedef struct LDKPersist_JCalls {
5636         atomic_size_t refcnt;
5637         uint32_t persist_new_channel_meth;
5638         uint32_t update_persisted_channel_meth;
5639 } LDKPersist_JCalls;
5640 static void LDKPersist_JCalls_free(void* this_arg) {
5641         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5642         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5643                 js_free(j_calls->persist_new_channel_meth);
5644                 js_free(j_calls->update_persisted_channel_meth);
5645                 FREE(j_calls);
5646         }
5647 }
5648 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
5649         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5650         LDKOutPoint id_var = id;
5651         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5652         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5653         uint64_t id_ref = (uint64_t)id_var.inner;
5654         if (id_var.is_owned) {
5655                 id_ref |= 1;
5656         }
5657         LDKChannelMonitor data_var = *data;
5658         data_var = ChannelMonitor_clone(data);
5659         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5660         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5661         uint64_t data_ref = (uint64_t)data_var.inner;
5662         if (data_var.is_owned) {
5663                 data_ref |= 1;
5664         }
5665         uint32_t ret = js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
5666         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5667         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5668         return ret_conv;
5669 }
5670 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
5671         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5672         LDKOutPoint id_var = id;
5673         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5674         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5675         uint64_t id_ref = (uint64_t)id_var.inner;
5676         if (id_var.is_owned) {
5677                 id_ref |= 1;
5678         }
5679         LDKChannelMonitorUpdate update_var = *update;
5680         update_var = ChannelMonitorUpdate_clone(update);
5681         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5682         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5683         uint64_t update_ref = (uint64_t)update_var.inner;
5684         if (update_var.is_owned) {
5685                 update_ref |= 1;
5686         }
5687         LDKChannelMonitor data_var = *data;
5688         data_var = ChannelMonitor_clone(data);
5689         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5690         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5691         uint64_t data_ref = (uint64_t)data_var.inner;
5692         if (data_var.is_owned) {
5693                 data_ref |= 1;
5694         }
5695         uint32_t ret = js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
5696         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5697         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5698         return ret_conv;
5699 }
5700 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
5701         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
5702         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5703 }
5704 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
5705         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5706         atomic_init(&calls->refcnt, 1);
5707         //TODO: Assign calls->o from o
5708
5709         LDKPersist ret = {
5710                 .this_arg = (void*) calls,
5711                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
5712                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
5713                 .free = LDKPersist_JCalls_free,
5714         };
5715         return ret;
5716 }
5717 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
5718         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5719         *res_ptr = LDKPersist_init(o);
5720         return (long)res_ptr;
5721 }
5722 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
5723         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5724         LDKOutPoint id_conv;
5725         id_conv.inner = (void*)(id & (~1));
5726         id_conv.is_owned = (id & 1) || (id == 0);
5727         id_conv = OutPoint_clone(&id_conv);
5728         LDKChannelMonitor data_conv;
5729         data_conv.inner = (void*)(data & (~1));
5730         data_conv.is_owned = false;
5731         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5732         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
5733         return (uint64_t)ret_conv;
5734 }
5735
5736 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
5737         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5738         LDKOutPoint id_conv;
5739         id_conv.inner = (void*)(id & (~1));
5740         id_conv.is_owned = (id & 1) || (id == 0);
5741         id_conv = OutPoint_clone(&id_conv);
5742         LDKChannelMonitorUpdate update_conv;
5743         update_conv.inner = (void*)(update & (~1));
5744         update_conv.is_owned = false;
5745         LDKChannelMonitor data_conv;
5746         data_conv.inner = (void*)(data & (~1));
5747         data_conv.is_owned = false;
5748         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5749         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
5750         return (uint64_t)ret_conv;
5751 }
5752
5753 typedef struct LDKChannelMessageHandler_JCalls {
5754         atomic_size_t refcnt;
5755         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5756         uint32_t handle_open_channel_meth;
5757         uint32_t handle_accept_channel_meth;
5758         uint32_t handle_funding_created_meth;
5759         uint32_t handle_funding_signed_meth;
5760         uint32_t handle_funding_locked_meth;
5761         uint32_t handle_shutdown_meth;
5762         uint32_t handle_closing_signed_meth;
5763         uint32_t handle_update_add_htlc_meth;
5764         uint32_t handle_update_fulfill_htlc_meth;
5765         uint32_t handle_update_fail_htlc_meth;
5766         uint32_t handle_update_fail_malformed_htlc_meth;
5767         uint32_t handle_commitment_signed_meth;
5768         uint32_t handle_revoke_and_ack_meth;
5769         uint32_t handle_update_fee_meth;
5770         uint32_t handle_announcement_signatures_meth;
5771         uint32_t peer_disconnected_meth;
5772         uint32_t peer_connected_meth;
5773         uint32_t handle_channel_reestablish_meth;
5774         uint32_t handle_channel_update_meth;
5775         uint32_t handle_error_meth;
5776 } LDKChannelMessageHandler_JCalls;
5777 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5778         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5779         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5780                 js_free(j_calls->handle_open_channel_meth);
5781                 js_free(j_calls->handle_accept_channel_meth);
5782                 js_free(j_calls->handle_funding_created_meth);
5783                 js_free(j_calls->handle_funding_signed_meth);
5784                 js_free(j_calls->handle_funding_locked_meth);
5785                 js_free(j_calls->handle_shutdown_meth);
5786                 js_free(j_calls->handle_closing_signed_meth);
5787                 js_free(j_calls->handle_update_add_htlc_meth);
5788                 js_free(j_calls->handle_update_fulfill_htlc_meth);
5789                 js_free(j_calls->handle_update_fail_htlc_meth);
5790                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
5791                 js_free(j_calls->handle_commitment_signed_meth);
5792                 js_free(j_calls->handle_revoke_and_ack_meth);
5793                 js_free(j_calls->handle_update_fee_meth);
5794                 js_free(j_calls->handle_announcement_signatures_meth);
5795                 js_free(j_calls->peer_disconnected_meth);
5796                 js_free(j_calls->peer_connected_meth);
5797                 js_free(j_calls->handle_channel_reestablish_meth);
5798                 js_free(j_calls->handle_channel_update_meth);
5799                 js_free(j_calls->handle_error_meth);
5800                 FREE(j_calls);
5801         }
5802 }
5803 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5804         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5805         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5806         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5807         LDKInitFeatures their_features_var = their_features;
5808         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5809         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5810         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5811         if (their_features_var.is_owned) {
5812                 their_features_ref |= 1;
5813         }
5814         LDKOpenChannel msg_var = *msg;
5815         msg_var = OpenChannel_clone(msg);
5816         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5817         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5818         uint64_t msg_ref = (uint64_t)msg_var.inner;
5819         if (msg_var.is_owned) {
5820                 msg_ref |= 1;
5821         }
5822         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5823 }
5824 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
5825         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5826         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5827         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5828         LDKInitFeatures their_features_var = their_features;
5829         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5830         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5831         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5832         if (their_features_var.is_owned) {
5833                 their_features_ref |= 1;
5834         }
5835         LDKAcceptChannel msg_var = *msg;
5836         msg_var = AcceptChannel_clone(msg);
5837         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5838         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5839         uint64_t msg_ref = (uint64_t)msg_var.inner;
5840         if (msg_var.is_owned) {
5841                 msg_ref |= 1;
5842         }
5843         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5844 }
5845 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
5846         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5847         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5848         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5849         LDKFundingCreated msg_var = *msg;
5850         msg_var = FundingCreated_clone(msg);
5851         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5852         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5853         uint64_t msg_ref = (uint64_t)msg_var.inner;
5854         if (msg_var.is_owned) {
5855                 msg_ref |= 1;
5856         }
5857         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
5858 }
5859 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
5860         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5861         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5862         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5863         LDKFundingSigned msg_var = *msg;
5864         msg_var = FundingSigned_clone(msg);
5865         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5866         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5867         uint64_t msg_ref = (uint64_t)msg_var.inner;
5868         if (msg_var.is_owned) {
5869                 msg_ref |= 1;
5870         }
5871         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
5872 }
5873 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
5874         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5875         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5876         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5877         LDKFundingLocked msg_var = *msg;
5878         msg_var = FundingLocked_clone(msg);
5879         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5880         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5881         uint64_t msg_ref = (uint64_t)msg_var.inner;
5882         if (msg_var.is_owned) {
5883                 msg_ref |= 1;
5884         }
5885         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
5886 }
5887 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
5888         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5889         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5890         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5891         LDKInitFeatures their_features_var = *their_features;
5892         their_features_var = InitFeatures_clone(their_features);
5893         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5894         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5895         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5896         if (their_features_var.is_owned) {
5897                 their_features_ref |= 1;
5898         }
5899         LDKShutdown msg_var = *msg;
5900         msg_var = Shutdown_clone(msg);
5901         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5902         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5903         uint64_t msg_ref = (uint64_t)msg_var.inner;
5904         if (msg_var.is_owned) {
5905                 msg_ref |= 1;
5906         }
5907         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
5908 }
5909 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
5910         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5911         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5912         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5913         LDKClosingSigned msg_var = *msg;
5914         msg_var = ClosingSigned_clone(msg);
5915         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5916         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5917         uint64_t msg_ref = (uint64_t)msg_var.inner;
5918         if (msg_var.is_owned) {
5919                 msg_ref |= 1;
5920         }
5921         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
5922 }
5923 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
5924         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5925         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5926         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5927         LDKUpdateAddHTLC msg_var = *msg;
5928         msg_var = UpdateAddHTLC_clone(msg);
5929         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5930         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5931         uint64_t msg_ref = (uint64_t)msg_var.inner;
5932         if (msg_var.is_owned) {
5933                 msg_ref |= 1;
5934         }
5935         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
5936 }
5937 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
5938         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5939         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5940         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5941         LDKUpdateFulfillHTLC msg_var = *msg;
5942         msg_var = UpdateFulfillHTLC_clone(msg);
5943         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5944         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5945         uint64_t msg_ref = (uint64_t)msg_var.inner;
5946         if (msg_var.is_owned) {
5947                 msg_ref |= 1;
5948         }
5949         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
5950 }
5951 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
5952         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5953         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5954         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5955         LDKUpdateFailHTLC msg_var = *msg;
5956         msg_var = UpdateFailHTLC_clone(msg);
5957         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5958         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5959         uint64_t msg_ref = (uint64_t)msg_var.inner;
5960         if (msg_var.is_owned) {
5961                 msg_ref |= 1;
5962         }
5963         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
5964 }
5965 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
5966         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5967         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5968         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5969         LDKUpdateFailMalformedHTLC msg_var = *msg;
5970         msg_var = UpdateFailMalformedHTLC_clone(msg);
5971         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5972         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5973         uint64_t msg_ref = (uint64_t)msg_var.inner;
5974         if (msg_var.is_owned) {
5975                 msg_ref |= 1;
5976         }
5977         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
5978 }
5979 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
5980         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5981         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5982         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5983         LDKCommitmentSigned msg_var = *msg;
5984         msg_var = CommitmentSigned_clone(msg);
5985         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5986         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5987         uint64_t msg_ref = (uint64_t)msg_var.inner;
5988         if (msg_var.is_owned) {
5989                 msg_ref |= 1;
5990         }
5991         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
5992 }
5993 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
5994         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5995         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5996         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5997         LDKRevokeAndACK msg_var = *msg;
5998         msg_var = RevokeAndACK_clone(msg);
5999         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6000         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6001         uint64_t msg_ref = (uint64_t)msg_var.inner;
6002         if (msg_var.is_owned) {
6003                 msg_ref |= 1;
6004         }
6005         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
6006 }
6007 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
6008         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6009         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6010         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6011         LDKUpdateFee msg_var = *msg;
6012         msg_var = UpdateFee_clone(msg);
6013         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6014         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6015         uint64_t msg_ref = (uint64_t)msg_var.inner;
6016         if (msg_var.is_owned) {
6017                 msg_ref |= 1;
6018         }
6019         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
6020 }
6021 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
6022         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6023         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6024         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6025         LDKAnnouncementSignatures msg_var = *msg;
6026         msg_var = AnnouncementSignatures_clone(msg);
6027         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6028         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6029         uint64_t msg_ref = (uint64_t)msg_var.inner;
6030         if (msg_var.is_owned) {
6031                 msg_ref |= 1;
6032         }
6033         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
6034 }
6035 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
6036         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6037         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6038         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6039         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
6040 }
6041 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
6042         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6043         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6044         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6045         LDKInit msg_var = *msg;
6046         msg_var = Init_clone(msg);
6047         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6048         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6049         uint64_t msg_ref = (uint64_t)msg_var.inner;
6050         if (msg_var.is_owned) {
6051                 msg_ref |= 1;
6052         }
6053         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
6054 }
6055 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
6056         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6057         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6058         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6059         LDKChannelReestablish msg_var = *msg;
6060         msg_var = ChannelReestablish_clone(msg);
6061         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6062         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6063         uint64_t msg_ref = (uint64_t)msg_var.inner;
6064         if (msg_var.is_owned) {
6065                 msg_ref |= 1;
6066         }
6067         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
6068 }
6069 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
6070         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6071         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6072         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6073         LDKChannelUpdate msg_var = *msg;
6074         msg_var = ChannelUpdate_clone(msg);
6075         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6076         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6077         uint64_t msg_ref = (uint64_t)msg_var.inner;
6078         if (msg_var.is_owned) {
6079                 msg_ref |= 1;
6080         }
6081         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
6082 }
6083 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
6084         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6085         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6086         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6087         LDKErrorMessage msg_var = *msg;
6088         msg_var = ErrorMessage_clone(msg);
6089         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6090         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6091         uint64_t msg_ref = (uint64_t)msg_var.inner;
6092         if (msg_var.is_owned) {
6093                 msg_ref |= 1;
6094         }
6095         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
6096 }
6097 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
6098         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
6099         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6100         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6101 }
6102 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6103         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
6104         atomic_init(&calls->refcnt, 1);
6105         //TODO: Assign calls->o from o
6106
6107         LDKChannelMessageHandler ret = {
6108                 .this_arg = (void*) calls,
6109                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
6110                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
6111                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
6112                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
6113                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
6114                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
6115                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
6116                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
6117                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
6118                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
6119                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
6120                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
6121                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
6122                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
6123                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
6124                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
6125                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
6126                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
6127                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
6128                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
6129                 .free = LDKChannelMessageHandler_JCalls_free,
6130                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6131         };
6132         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6133         return ret;
6134 }
6135 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6136         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
6137         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
6138         return (long)res_ptr;
6139 }
6140 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) {
6141         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6142         LDKPublicKey their_node_id_ref;
6143         CHECK(*((uint32_t*)their_node_id) == 33);
6144         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6145         LDKInitFeatures their_features_conv;
6146         their_features_conv.inner = (void*)(their_features & (~1));
6147         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6148         their_features_conv = InitFeatures_clone(&their_features_conv);
6149         LDKOpenChannel msg_conv;
6150         msg_conv.inner = (void*)(msg & (~1));
6151         msg_conv.is_owned = false;
6152         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6153 }
6154
6155 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) {
6156         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6157         LDKPublicKey their_node_id_ref;
6158         CHECK(*((uint32_t*)their_node_id) == 33);
6159         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6160         LDKInitFeatures their_features_conv;
6161         their_features_conv.inner = (void*)(their_features & (~1));
6162         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6163         their_features_conv = InitFeatures_clone(&their_features_conv);
6164         LDKAcceptChannel msg_conv;
6165         msg_conv.inner = (void*)(msg & (~1));
6166         msg_conv.is_owned = false;
6167         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6168 }
6169
6170 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6171         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6172         LDKPublicKey their_node_id_ref;
6173         CHECK(*((uint32_t*)their_node_id) == 33);
6174         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6175         LDKFundingCreated msg_conv;
6176         msg_conv.inner = (void*)(msg & (~1));
6177         msg_conv.is_owned = false;
6178         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6179 }
6180
6181 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6182         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6183         LDKPublicKey their_node_id_ref;
6184         CHECK(*((uint32_t*)their_node_id) == 33);
6185         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6186         LDKFundingSigned msg_conv;
6187         msg_conv.inner = (void*)(msg & (~1));
6188         msg_conv.is_owned = false;
6189         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6190 }
6191
6192 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6193         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((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         LDKFundingLocked msg_conv;
6198         msg_conv.inner = (void*)(msg & (~1));
6199         msg_conv.is_owned = false;
6200         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6201 }
6202
6203 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
6204         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6205         LDKPublicKey their_node_id_ref;
6206         CHECK(*((uint32_t*)their_node_id) == 33);
6207         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6208         LDKInitFeatures their_features_conv;
6209         their_features_conv.inner = (void*)(their_features & (~1));
6210         their_features_conv.is_owned = false;
6211         LDKShutdown msg_conv;
6212         msg_conv.inner = (void*)(msg & (~1));
6213         msg_conv.is_owned = false;
6214         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
6215 }
6216
6217 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6218         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6219         LDKPublicKey their_node_id_ref;
6220         CHECK(*((uint32_t*)their_node_id) == 33);
6221         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6222         LDKClosingSigned msg_conv;
6223         msg_conv.inner = (void*)(msg & (~1));
6224         msg_conv.is_owned = false;
6225         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6226 }
6227
6228 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6229         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6230         LDKPublicKey their_node_id_ref;
6231         CHECK(*((uint32_t*)their_node_id) == 33);
6232         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6233         LDKUpdateAddHTLC msg_conv;
6234         msg_conv.inner = (void*)(msg & (~1));
6235         msg_conv.is_owned = false;
6236         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6237 }
6238
6239 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6240         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6241         LDKPublicKey their_node_id_ref;
6242         CHECK(*((uint32_t*)their_node_id) == 33);
6243         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6244         LDKUpdateFulfillHTLC msg_conv;
6245         msg_conv.inner = (void*)(msg & (~1));
6246         msg_conv.is_owned = false;
6247         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6248 }
6249
6250 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6251         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6252         LDKPublicKey their_node_id_ref;
6253         CHECK(*((uint32_t*)their_node_id) == 33);
6254         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6255         LDKUpdateFailHTLC msg_conv;
6256         msg_conv.inner = (void*)(msg & (~1));
6257         msg_conv.is_owned = false;
6258         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6259 }
6260
6261 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6262         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6263         LDKPublicKey their_node_id_ref;
6264         CHECK(*((uint32_t*)their_node_id) == 33);
6265         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6266         LDKUpdateFailMalformedHTLC msg_conv;
6267         msg_conv.inner = (void*)(msg & (~1));
6268         msg_conv.is_owned = false;
6269         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6270 }
6271
6272 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6273         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6274         LDKPublicKey their_node_id_ref;
6275         CHECK(*((uint32_t*)their_node_id) == 33);
6276         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6277         LDKCommitmentSigned msg_conv;
6278         msg_conv.inner = (void*)(msg & (~1));
6279         msg_conv.is_owned = false;
6280         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6281 }
6282
6283 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6284         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6285         LDKPublicKey their_node_id_ref;
6286         CHECK(*((uint32_t*)their_node_id) == 33);
6287         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6288         LDKRevokeAndACK msg_conv;
6289         msg_conv.inner = (void*)(msg & (~1));
6290         msg_conv.is_owned = false;
6291         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6292 }
6293
6294 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6295         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6296         LDKPublicKey their_node_id_ref;
6297         CHECK(*((uint32_t*)their_node_id) == 33);
6298         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6299         LDKUpdateFee msg_conv;
6300         msg_conv.inner = (void*)(msg & (~1));
6301         msg_conv.is_owned = false;
6302         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6303 }
6304
6305 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6306         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6307         LDKPublicKey their_node_id_ref;
6308         CHECK(*((uint32_t*)their_node_id) == 33);
6309         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6310         LDKAnnouncementSignatures msg_conv;
6311         msg_conv.inner = (void*)(msg & (~1));
6312         msg_conv.is_owned = false;
6313         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6314 }
6315
6316 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
6317         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6318         LDKPublicKey their_node_id_ref;
6319         CHECK(*((uint32_t*)their_node_id) == 33);
6320         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6321         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
6322 }
6323
6324 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6325         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6326         LDKPublicKey their_node_id_ref;
6327         CHECK(*((uint32_t*)their_node_id) == 33);
6328         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6329         LDKInit msg_conv;
6330         msg_conv.inner = (void*)(msg & (~1));
6331         msg_conv.is_owned = false;
6332         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6333 }
6334
6335 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6336         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6337         LDKPublicKey their_node_id_ref;
6338         CHECK(*((uint32_t*)their_node_id) == 33);
6339         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6340         LDKChannelReestablish msg_conv;
6341         msg_conv.inner = (void*)(msg & (~1));
6342         msg_conv.is_owned = false;
6343         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6344 }
6345
6346 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6347         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6348         LDKPublicKey their_node_id_ref;
6349         CHECK(*((uint32_t*)their_node_id) == 33);
6350         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6351         LDKChannelUpdate msg_conv;
6352         msg_conv.inner = (void*)(msg & (~1));
6353         msg_conv.is_owned = false;
6354         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6355 }
6356
6357 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6358         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6359         LDKPublicKey their_node_id_ref;
6360         CHECK(*((uint32_t*)their_node_id) == 33);
6361         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6362         LDKErrorMessage msg_conv;
6363         msg_conv.inner = (void*)(msg & (~1));
6364         msg_conv.is_owned = false;
6365         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6366 }
6367
6368 typedef struct LDKRoutingMessageHandler_JCalls {
6369         atomic_size_t refcnt;
6370         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6371         uint32_t handle_node_announcement_meth;
6372         uint32_t handle_channel_announcement_meth;
6373         uint32_t handle_channel_update_meth;
6374         uint32_t get_next_channel_announcements_meth;
6375         uint32_t get_next_node_announcements_meth;
6376         uint32_t sync_routing_table_meth;
6377         uint32_t handle_reply_channel_range_meth;
6378         uint32_t handle_reply_short_channel_ids_end_meth;
6379         uint32_t handle_query_channel_range_meth;
6380         uint32_t handle_query_short_channel_ids_meth;
6381 } LDKRoutingMessageHandler_JCalls;
6382 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
6383         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6384         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6385                 js_free(j_calls->handle_node_announcement_meth);
6386                 js_free(j_calls->handle_channel_announcement_meth);
6387                 js_free(j_calls->handle_channel_update_meth);
6388                 js_free(j_calls->get_next_channel_announcements_meth);
6389                 js_free(j_calls->get_next_node_announcements_meth);
6390                 js_free(j_calls->sync_routing_table_meth);
6391                 js_free(j_calls->handle_reply_channel_range_meth);
6392                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
6393                 js_free(j_calls->handle_query_channel_range_meth);
6394                 js_free(j_calls->handle_query_short_channel_ids_meth);
6395                 FREE(j_calls);
6396         }
6397 }
6398 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
6399         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6400         LDKNodeAnnouncement msg_var = *msg;
6401         msg_var = NodeAnnouncement_clone(msg);
6402         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6403         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6404         uint64_t msg_ref = (uint64_t)msg_var.inner;
6405         if (msg_var.is_owned) {
6406                 msg_ref |= 1;
6407         }
6408         uint32_t ret = js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
6409         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6410         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6411         return ret_conv;
6412 }
6413 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
6414         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6415         LDKChannelAnnouncement msg_var = *msg;
6416         msg_var = ChannelAnnouncement_clone(msg);
6417         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6418         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6419         uint64_t msg_ref = (uint64_t)msg_var.inner;
6420         if (msg_var.is_owned) {
6421                 msg_ref |= 1;
6422         }
6423         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
6424         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6425         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6426         return ret_conv;
6427 }
6428 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
6429         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6430         LDKChannelUpdate msg_var = *msg;
6431         msg_var = ChannelUpdate_clone(msg);
6432         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6433         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6434         uint64_t msg_ref = (uint64_t)msg_var.inner;
6435         if (msg_var.is_owned) {
6436                 msg_ref |= 1;
6437         }
6438         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
6439         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6440         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6441         return ret_conv;
6442 }
6443 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
6444         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6445         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
6446         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
6447         ret_constr.datalen = *((uint32_t*)ret);
6448         if (ret_constr.datalen > 0)
6449                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
6450         else
6451                 ret_constr.data = NULL;
6452         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6453         for (size_t l = 0; l < ret_constr.datalen; l++) {
6454                 uint32_t ret_conv_63 = ret_vals[l];
6455                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
6456                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
6457                 ret_constr.data[l] = ret_conv_63_conv;
6458         }
6459         return ret_constr;
6460 }
6461 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
6462         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6463         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6464         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
6465         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
6466         LDKCVec_NodeAnnouncementZ ret_constr;
6467         ret_constr.datalen = *((uint32_t*)ret);
6468         if (ret_constr.datalen > 0)
6469                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6470         else
6471                 ret_constr.data = NULL;
6472         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6473         for (size_t s = 0; s < ret_constr.datalen; s++) {
6474                 uint32_t ret_conv_18 = ret_vals[s];
6475                 LDKNodeAnnouncement ret_conv_18_conv;
6476                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
6477                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
6478                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
6479                 ret_constr.data[s] = ret_conv_18_conv;
6480         }
6481         return ret_constr;
6482 }
6483 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
6484         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6485         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6486         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6487         LDKInit init_var = *init;
6488         init_var = Init_clone(init);
6489         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6490         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6491         uint64_t init_ref = (uint64_t)init_var.inner;
6492         if (init_var.is_owned) {
6493                 init_ref |= 1;
6494         }
6495         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
6496 }
6497 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
6498         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6499         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6500         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6501         LDKReplyChannelRange msg_var = msg;
6502         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6503         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6504         uint64_t msg_ref = (uint64_t)msg_var.inner;
6505         if (msg_var.is_owned) {
6506                 msg_ref |= 1;
6507         }
6508         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6509         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6510         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6511         return ret_conv;
6512 }
6513 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6514         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6515         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6516         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6517         LDKReplyShortChannelIdsEnd msg_var = msg;
6518         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6519         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6520         uint64_t msg_ref = (uint64_t)msg_var.inner;
6521         if (msg_var.is_owned) {
6522                 msg_ref |= 1;
6523         }
6524         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6525         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6526         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6527         return ret_conv;
6528 }
6529 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6530         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6531         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6532         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6533         LDKQueryChannelRange msg_var = msg;
6534         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6535         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6536         uint64_t msg_ref = (uint64_t)msg_var.inner;
6537         if (msg_var.is_owned) {
6538                 msg_ref |= 1;
6539         }
6540         uint32_t ret = js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6541         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6542         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6543         return ret_conv;
6544 }
6545 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6546         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6547         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6548         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6549         LDKQueryShortChannelIds msg_var = msg;
6550         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6551         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6552         uint64_t msg_ref = (uint64_t)msg_var.inner;
6553         if (msg_var.is_owned) {
6554                 msg_ref |= 1;
6555         }
6556         uint32_t ret = js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6557         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6558         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6559         return ret_conv;
6560 }
6561 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
6562         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
6563         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6564         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6565 }
6566 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6567         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6568         atomic_init(&calls->refcnt, 1);
6569         //TODO: Assign calls->o from o
6570
6571         LDKRoutingMessageHandler ret = {
6572                 .this_arg = (void*) calls,
6573                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
6574                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
6575                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
6576                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
6577                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
6578                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
6579                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
6580                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
6581                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
6582                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
6583                 .free = LDKRoutingMessageHandler_JCalls_free,
6584                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6585         };
6586         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6587         return ret;
6588 }
6589 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6590         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6591         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
6592         return (long)res_ptr;
6593 }
6594 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
6595         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6596         LDKNodeAnnouncement msg_conv;
6597         msg_conv.inner = (void*)(msg & (~1));
6598         msg_conv.is_owned = false;
6599         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6600         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6601         return (uint64_t)ret_conv;
6602 }
6603
6604 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
6605         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6606         LDKChannelAnnouncement msg_conv;
6607         msg_conv.inner = (void*)(msg & (~1));
6608         msg_conv.is_owned = false;
6609         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6610         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6611         return (uint64_t)ret_conv;
6612 }
6613
6614 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
6615         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6616         LDKChannelUpdate msg_conv;
6617         msg_conv.inner = (void*)(msg & (~1));
6618         msg_conv.is_owned = false;
6619         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6620         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6621         return (uint64_t)ret_conv;
6622 }
6623
6624 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
6625         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6626         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6627         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6628         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6629         for (size_t l = 0; l < ret_var.datalen; l++) {
6630                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6631                 *ret_conv_63_ref = ret_var.data[l];
6632                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
6633         }
6634         FREE(ret_var.data);
6635         return ret_arr;
6636 }
6637
6638 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
6639         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6640         LDKPublicKey starting_point_ref;
6641         CHECK(*((uint32_t*)starting_point) == 33);
6642         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
6643         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6644         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6645         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6646         for (size_t s = 0; s < ret_var.datalen; s++) {
6647                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6648                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6649                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6650                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
6651                 if (ret_conv_18_var.is_owned) {
6652                         ret_conv_18_ref |= 1;
6653                 }
6654                 ret_arr_ptr[s] = ret_conv_18_ref;
6655         }
6656         FREE(ret_var.data);
6657         return ret_arr;
6658 }
6659
6660 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
6661         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6662         LDKPublicKey their_node_id_ref;
6663         CHECK(*((uint32_t*)their_node_id) == 33);
6664         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6665         LDKInit init_conv;
6666         init_conv.inner = (void*)(init & (~1));
6667         init_conv.is_owned = false;
6668         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
6669 }
6670
6671 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6672         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6673         LDKPublicKey their_node_id_ref;
6674         CHECK(*((uint32_t*)their_node_id) == 33);
6675         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6676         LDKReplyChannelRange msg_conv;
6677         msg_conv.inner = (void*)(msg & (~1));
6678         msg_conv.is_owned = (msg & 1) || (msg == 0);
6679         msg_conv = ReplyChannelRange_clone(&msg_conv);
6680         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6681         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6682         return (uint64_t)ret_conv;
6683 }
6684
6685 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) {
6686         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6687         LDKPublicKey their_node_id_ref;
6688         CHECK(*((uint32_t*)their_node_id) == 33);
6689         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6690         LDKReplyShortChannelIdsEnd msg_conv;
6691         msg_conv.inner = (void*)(msg & (~1));
6692         msg_conv.is_owned = (msg & 1) || (msg == 0);
6693         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
6694         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6695         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6696         return (uint64_t)ret_conv;
6697 }
6698
6699 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6700         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6701         LDKPublicKey their_node_id_ref;
6702         CHECK(*((uint32_t*)their_node_id) == 33);
6703         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6704         LDKQueryChannelRange msg_conv;
6705         msg_conv.inner = (void*)(msg & (~1));
6706         msg_conv.is_owned = (msg & 1) || (msg == 0);
6707         msg_conv = QueryChannelRange_clone(&msg_conv);
6708         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6709         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6710         return (uint64_t)ret_conv;
6711 }
6712
6713 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6714         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6715         LDKPublicKey their_node_id_ref;
6716         CHECK(*((uint32_t*)their_node_id) == 33);
6717         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6718         LDKQueryShortChannelIds msg_conv;
6719         msg_conv.inner = (void*)(msg & (~1));
6720         msg_conv.is_owned = (msg & 1) || (msg == 0);
6721         msg_conv = QueryShortChannelIds_clone(&msg_conv);
6722         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6723         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6724         return (uint64_t)ret_conv;
6725 }
6726
6727 typedef struct LDKCustomMessageReader_JCalls {
6728         atomic_size_t refcnt;
6729         uint32_t read_meth;
6730 } LDKCustomMessageReader_JCalls;
6731 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
6732         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
6733         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6734                 js_free(j_calls->read_meth);
6735                 FREE(j_calls);
6736         }
6737 }
6738 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
6739         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
6740         LDKu8slice buffer_var = buffer;
6741         int8_tArray buffer_arr = init_arr(buffer_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6742         memcpy((uint8_t*)(buffer_arr + 4), buffer_var.data, buffer_var.datalen);
6743         uint32_t ret = js_invoke_function_2(j_calls->read_meth, message_type, buffer_arr);
6744         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1);
6745         ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1));
6746         return ret_conv;
6747 }
6748 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
6749         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
6750         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6751 }
6752 static inline LDKCustomMessageReader LDKCustomMessageReader_init (/*TODO: JS Object Reference */void* o) {
6753         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
6754         atomic_init(&calls->refcnt, 1);
6755         //TODO: Assign calls->o from o
6756
6757         LDKCustomMessageReader ret = {
6758                 .this_arg = (void*) calls,
6759                 .read = read_LDKCustomMessageReader_jcall,
6760                 .free = LDKCustomMessageReader_JCalls_free,
6761         };
6762         return ret;
6763 }
6764 long  __attribute__((visibility("default"))) TS_LDKCustomMessageReader_new(/*TODO: JS Object Reference */void* o) {
6765         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
6766         *res_ptr = LDKCustomMessageReader_init(o);
6767         return (long)res_ptr;
6768 }
6769 uint32_t  __attribute__((visibility("default"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
6770         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)(((uint64_t)this_arg) & ~1);
6771         LDKu8slice buffer_ref;
6772         buffer_ref.datalen = *((uint32_t*)buffer);
6773         buffer_ref.data = (int8_t*)(buffer + 4);
6774         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
6775         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
6776         return (uint64_t)ret_conv;
6777 }
6778
6779 typedef struct LDKCustomMessageHandler_JCalls {
6780         atomic_size_t refcnt;
6781         LDKCustomMessageReader_JCalls* CustomMessageReader;
6782         uint32_t handle_custom_message_meth;
6783         uint32_t get_and_clear_pending_msg_meth;
6784 } LDKCustomMessageHandler_JCalls;
6785 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
6786         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
6787         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6788                 js_free(j_calls->handle_custom_message_meth);
6789                 js_free(j_calls->get_and_clear_pending_msg_meth);
6790                 FREE(j_calls);
6791         }
6792 }
6793 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
6794         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
6795         LDKType* msg_ret =MALLOC(sizeof(LDKType), "LDKType");
6796         *msg_ret = msg;
6797         int8_tArray sender_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6798         memcpy((uint8_t*)(sender_node_id_arr + 4), sender_node_id.compressed_form, 33);
6799         uint32_t ret = js_invoke_function_2(j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
6800         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6801         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6802         return ret_conv;
6803 }
6804 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
6805         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
6806         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_meth);
6807         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
6808         ret_constr.datalen = *((uint32_t*)ret);
6809         if (ret_constr.datalen > 0)
6810                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
6811         else
6812                 ret_constr.data = NULL;
6813         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6814         for (size_t c = 0; c < ret_constr.datalen; c++) {
6815                 uint32_t ret_conv_28 = ret_vals[c];
6816                 LDKC2Tuple_PublicKeyTypeZ ret_conv_28_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_28) & ~1);
6817                 ret_conv_28_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_28) & ~1));
6818                 ret_constr.data[c] = ret_conv_28_conv;
6819         }
6820         return ret_constr;
6821 }
6822 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
6823         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
6824         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6825         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
6826 }
6827 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* CustomMessageReader) {
6828         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
6829         atomic_init(&calls->refcnt, 1);
6830         //TODO: Assign calls->o from o
6831
6832         LDKCustomMessageHandler ret = {
6833                 .this_arg = (void*) calls,
6834                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
6835                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
6836                 .free = LDKCustomMessageHandler_JCalls_free,
6837                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
6838         };
6839         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
6840         return ret;
6841 }
6842 long  __attribute__((visibility("default"))) TS_LDKCustomMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* CustomMessageReader) {
6843         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
6844         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
6845         return (long)res_ptr;
6846 }
6847 uint32_t  __attribute__((visibility("default"))) TS_CustomMessageHandler_handle_custom_message(uint32_t this_arg, uint32_t msg, int8_tArray sender_node_id) {
6848         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1);
6849         LDKType msg_conv = *(LDKType*)(((uint64_t)msg) & ~1);
6850         LDKPublicKey sender_node_id_ref;
6851         CHECK(*((uint32_t*)sender_node_id) == 33);
6852         memcpy(sender_node_id_ref.compressed_form, (uint8_t*)(sender_node_id + 4), 33);
6853         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6854         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
6855         return (uint64_t)ret_conv;
6856 }
6857
6858 uint32_tArray  __attribute__((visibility("default"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
6859         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1);
6860         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
6861         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6862         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6863         for (size_t c = 0; c < ret_var.datalen; c++) {
6864                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_28_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
6865                 *ret_conv_28_ref = ret_var.data[c];
6866                 ret_arr_ptr[c] = (uint64_t)ret_conv_28_ref;
6867         }
6868         FREE(ret_var.data);
6869         return ret_arr;
6870 }
6871
6872 typedef struct LDKSocketDescriptor_JCalls {
6873         atomic_size_t refcnt;
6874         uint32_t send_data_meth;
6875         uint32_t disconnect_socket_meth;
6876         uint32_t eq_meth;
6877         uint32_t hash_meth;
6878 } LDKSocketDescriptor_JCalls;
6879 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
6880         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6881         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6882                 js_free(j_calls->send_data_meth);
6883                 js_free(j_calls->disconnect_socket_meth);
6884                 js_free(j_calls->eq_meth);
6885                 js_free(j_calls->hash_meth);
6886                 FREE(j_calls);
6887         }
6888 }
6889 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
6890         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6891         LDKu8slice data_var = data;
6892         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6893         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
6894         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
6895 }
6896 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
6897         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6898         js_invoke_function_0(j_calls->disconnect_socket_meth);
6899 }
6900 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
6901         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6902         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6903         *other_arg_clone = SocketDescriptor_clone(other_arg);
6904         return js_invoke_function_1(j_calls->eq_meth, (uint64_t)other_arg_clone);
6905 }
6906 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
6907         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6908         return js_invoke_function_0(j_calls->hash_meth);
6909 }
6910 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
6911         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
6912         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6913 }
6914 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
6915         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
6916         atomic_init(&calls->refcnt, 1);
6917         //TODO: Assign calls->o from o
6918
6919         LDKSocketDescriptor ret = {
6920                 .this_arg = (void*) calls,
6921                 .send_data = send_data_LDKSocketDescriptor_jcall,
6922                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
6923                 .eq = eq_LDKSocketDescriptor_jcall,
6924                 .hash = hash_LDKSocketDescriptor_jcall,
6925                 .cloned = LDKSocketDescriptor_JCalls_cloned,
6926                 .free = LDKSocketDescriptor_JCalls_free,
6927         };
6928         return ret;
6929 }
6930 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
6931         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6932         *res_ptr = LDKSocketDescriptor_init(o);
6933         return (long)res_ptr;
6934 }
6935 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
6936         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6937         LDKu8slice data_ref;
6938         data_ref.datalen = *((uint32_t*)data);
6939         data_ref.data = (int8_t*)(data + 4);
6940         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
6941         return ret_val;
6942 }
6943
6944 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
6945         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6946         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
6947 }
6948
6949 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
6950         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6951         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
6952         return ret_val;
6953 }
6954
6955 typedef struct LDKChannelManagerPersister_JCalls {
6956         atomic_size_t refcnt;
6957         uint32_t persist_manager_meth;
6958 } LDKChannelManagerPersister_JCalls;
6959 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
6960         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6961         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6962                 js_free(j_calls->persist_manager_meth);
6963                 FREE(j_calls);
6964         }
6965 }
6966 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
6967         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6968         LDKChannelManager channel_manager_var = *channel_manager;
6969         // Warning: we may need a move here but no clone is available for LDKChannelManager
6970         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6971         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6972         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
6973         if (channel_manager_var.is_owned) {
6974                 channel_manager_ref |= 1;
6975         }
6976         uint32_t ret = js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
6977         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
6978         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
6979         return ret_conv;
6980 }
6981 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
6982         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
6983         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6984 }
6985 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (/*TODO: JS Object Reference */void* o) {
6986         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
6987         atomic_init(&calls->refcnt, 1);
6988         //TODO: Assign calls->o from o
6989
6990         LDKChannelManagerPersister ret = {
6991                 .this_arg = (void*) calls,
6992                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
6993                 .free = LDKChannelManagerPersister_JCalls_free,
6994         };
6995         return ret;
6996 }
6997 long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/*TODO: JS Object Reference */void* o) {
6998         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
6999         *res_ptr = LDKChannelManagerPersister_init(o);
7000         return (long)res_ptr;
7001 }
7002 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
7003         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
7004         LDKChannelManager channel_manager_conv;
7005         channel_manager_conv.inner = (void*)(channel_manager & (~1));
7006         channel_manager_conv.is_owned = false;
7007         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7008         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
7009         return (uint64_t)ret_conv;
7010 }
7011
7012 uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint32_t ptr) {
7013         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
7014         switch(obj->tag) {
7015                 case LDKFallback_SegWitProgram: {
7016                         uint8_t version_val = obj->seg_wit_program.version._0;
7017                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
7018                         int8_tArray program_arr = init_arr(program_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7019                         memcpy((uint8_t*)(program_arr + 4), program_var.data, program_var.datalen);
7020                         return 0 /* LDKFallback - SegWitProgram */; (void) version_val; (void) program_arr;
7021                 }
7022                 case LDKFallback_PubKeyHash: {
7023                         int8_tArray pub_key_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
7024                         memcpy((uint8_t*)(pub_key_hash_arr + 4), obj->pub_key_hash.data, 20);
7025                         return 0 /* LDKFallback - PubKeyHash */; (void) pub_key_hash_arr;
7026                 }
7027                 case LDKFallback_ScriptHash: {
7028                         int8_tArray script_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
7029                         memcpy((uint8_t*)(script_hash_arr + 4), obj->script_hash.data, 20);
7030                         return 0 /* LDKFallback - ScriptHash */; (void) script_hash_arr;
7031                 }
7032                 default: abort();
7033         }
7034 }
7035 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
7036         LDKStr ret_str = _ldk_get_compiled_version();
7037         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
7038         Str_free(ret_str);
7039         return ret_conv;
7040 }
7041
7042 jstring  __attribute__((visibility("default"))) TS__ldk_c_bindings_get_compiled_version() {
7043         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
7044         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
7045         Str_free(ret_str);
7046         return ret_conv;
7047 }
7048
7049 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
7050         LDKTransaction _res_ref;
7051         _res_ref.datalen = *((uint32_t*)_res);
7052         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
7053         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
7054         _res_ref.data_is_owned = true;
7055         Transaction_free(_res_ref);
7056 }
7057
7058 uint32_t  __attribute__((visibility("default"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
7059         LDKCVec_u8Z script_pubkey_ref;
7060         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
7061         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
7062         memcpy(script_pubkey_ref.data, (uint8_t*)(script_pubkey + 4), script_pubkey_ref.datalen);
7063         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7064         *ret_ref = TxOut_new(script_pubkey_ref, value);
7065         return (uint64_t)ret_ref;
7066 }
7067
7068 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
7069         if ((_res & 1) != 0) return;
7070         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
7071         FREE((void*)_res);
7072         TxOut_free(_res_conv);
7073 }
7074
7075 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
7076         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
7077         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7078         *ret_ref = TxOut_clone(orig_conv);
7079         return (uint64_t)ret_ref;
7080 }
7081
7082 void  __attribute__((visibility("default"))) TS_Str_free(jstring _res) {
7083         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
7084         Str_free(dummy);
7085 }
7086
7087 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
7088         LDKSecretKey o_ref;
7089         CHECK(*((uint32_t*)o) == 32);
7090         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
7091         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
7092         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
7093         return (uint64_t)ret_conv;
7094 }
7095
7096 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
7097         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
7098         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
7099         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
7100         return (uint64_t)ret_conv;
7101 }
7102
7103 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
7104         if ((_res & 1) != 0) return;
7105         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
7106         FREE((void*)_res);
7107         CResult_SecretKeyErrorZ_free(_res_conv);
7108 }
7109
7110 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
7111         LDKPublicKey o_ref;
7112         CHECK(*((uint32_t*)o) == 33);
7113         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
7114         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
7115         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
7116         return (uint64_t)ret_conv;
7117 }
7118
7119 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
7120         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
7121         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
7122         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
7123         return (uint64_t)ret_conv;
7124 }
7125
7126 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
7127         if ((_res & 1) != 0) return;
7128         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
7129         FREE((void*)_res);
7130         CResult_PublicKeyErrorZ_free(_res_conv);
7131 }
7132
7133 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
7134         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
7135         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
7136         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
7137         return (uint64_t)ret_conv;
7138 }
7139
7140 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
7141         LDKTxCreationKeys o_conv;
7142         o_conv.inner = (void*)(o & (~1));
7143         o_conv.is_owned = (o & 1) || (o == 0);
7144         o_conv = TxCreationKeys_clone(&o_conv);
7145         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
7146         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
7147         return (uint64_t)ret_conv;
7148 }
7149
7150 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
7151         LDKDecodeError e_conv;
7152         e_conv.inner = (void*)(e & (~1));
7153         e_conv.is_owned = (e & 1) || (e == 0);
7154         e_conv = DecodeError_clone(&e_conv);
7155         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
7156         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
7157         return (uint64_t)ret_conv;
7158 }
7159
7160 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
7161         if ((_res & 1) != 0) return;
7162         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
7163         FREE((void*)_res);
7164         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
7165 }
7166
7167 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
7168         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
7169         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
7170         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
7171         return (uint64_t)ret_conv;
7172 }
7173
7174 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
7175         LDKChannelPublicKeys o_conv;
7176         o_conv.inner = (void*)(o & (~1));
7177         o_conv.is_owned = (o & 1) || (o == 0);
7178         o_conv = ChannelPublicKeys_clone(&o_conv);
7179         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
7180         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
7181         return (uint64_t)ret_conv;
7182 }
7183
7184 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
7185         LDKDecodeError e_conv;
7186         e_conv.inner = (void*)(e & (~1));
7187         e_conv.is_owned = (e & 1) || (e == 0);
7188         e_conv = DecodeError_clone(&e_conv);
7189         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
7190         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
7191         return (uint64_t)ret_conv;
7192 }
7193
7194 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
7195         if ((_res & 1) != 0) return;
7196         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
7197         FREE((void*)_res);
7198         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
7199 }
7200
7201 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
7202         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
7203         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
7204         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
7205         return (uint64_t)ret_conv;
7206 }
7207
7208 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
7209         LDKTxCreationKeys o_conv;
7210         o_conv.inner = (void*)(o & (~1));
7211         o_conv.is_owned = (o & 1) || (o == 0);
7212         o_conv = TxCreationKeys_clone(&o_conv);
7213         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
7214         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
7215         return (uint64_t)ret_conv;
7216 }
7217
7218 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
7219         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
7220         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
7221         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
7222         return (uint64_t)ret_conv;
7223 }
7224
7225 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
7226         if ((_res & 1) != 0) return;
7227         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
7228         FREE((void*)_res);
7229         CResult_TxCreationKeysErrorZ_free(_res_conv);
7230 }
7231
7232 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
7233         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
7234         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
7235         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
7236         return (uint64_t)ret_conv;
7237 }
7238
7239 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
7240         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
7241         *ret_copy = COption_u32Z_some(o);
7242         uint64_t ret_ref = (uint64_t)ret_copy;
7243         return ret_ref;
7244 }
7245
7246 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
7247         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
7248         *ret_copy = COption_u32Z_none();
7249         uint64_t ret_ref = (uint64_t)ret_copy;
7250         return ret_ref;
7251 }
7252
7253 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
7254         if ((_res & 1) != 0) return;
7255         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
7256         FREE((void*)_res);
7257         COption_u32Z_free(_res_conv);
7258 }
7259
7260 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
7261         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
7262         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
7263         *ret_copy = COption_u32Z_clone(orig_conv);
7264         uint64_t ret_ref = (uint64_t)ret_copy;
7265         return ret_ref;
7266 }
7267
7268 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
7269         LDKHTLCOutputInCommitment o_conv;
7270         o_conv.inner = (void*)(o & (~1));
7271         o_conv.is_owned = (o & 1) || (o == 0);
7272         o_conv = HTLCOutputInCommitment_clone(&o_conv);
7273         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7274         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
7275         return (uint64_t)ret_conv;
7276 }
7277
7278 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
7279         LDKDecodeError e_conv;
7280         e_conv.inner = (void*)(e & (~1));
7281         e_conv.is_owned = (e & 1) || (e == 0);
7282         e_conv = DecodeError_clone(&e_conv);
7283         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7284         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
7285         return (uint64_t)ret_conv;
7286 }
7287
7288 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
7289         if ((_res & 1) != 0) return;
7290         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
7291         FREE((void*)_res);
7292         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
7293 }
7294
7295 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
7296         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
7297         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7298         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
7299         return (uint64_t)ret_conv;
7300 }
7301
7302 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
7303         LDKCounterpartyChannelTransactionParameters o_conv;
7304         o_conv.inner = (void*)(o & (~1));
7305         o_conv.is_owned = (o & 1) || (o == 0);
7306         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
7307         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7308         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
7309         return (uint64_t)ret_conv;
7310 }
7311
7312 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
7313         LDKDecodeError e_conv;
7314         e_conv.inner = (void*)(e & (~1));
7315         e_conv.is_owned = (e & 1) || (e == 0);
7316         e_conv = DecodeError_clone(&e_conv);
7317         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7318         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
7319         return (uint64_t)ret_conv;
7320 }
7321
7322 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
7323         if ((_res & 1) != 0) return;
7324         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
7325         FREE((void*)_res);
7326         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
7327 }
7328
7329 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
7330         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
7331         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7332         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
7333         return (uint64_t)ret_conv;
7334 }
7335
7336 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
7337         LDKChannelTransactionParameters o_conv;
7338         o_conv.inner = (void*)(o & (~1));
7339         o_conv.is_owned = (o & 1) || (o == 0);
7340         o_conv = ChannelTransactionParameters_clone(&o_conv);
7341         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7342         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
7343         return (uint64_t)ret_conv;
7344 }
7345
7346 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
7347         LDKDecodeError e_conv;
7348         e_conv.inner = (void*)(e & (~1));
7349         e_conv.is_owned = (e & 1) || (e == 0);
7350         e_conv = DecodeError_clone(&e_conv);
7351         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7352         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
7353         return (uint64_t)ret_conv;
7354 }
7355
7356 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
7357         if ((_res & 1) != 0) return;
7358         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
7359         FREE((void*)_res);
7360         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
7361 }
7362
7363 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
7364         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
7365         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7366         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
7367         return (uint64_t)ret_conv;
7368 }
7369
7370 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
7371         LDKCVec_SignatureZ _res_constr;
7372         _res_constr.datalen = *((uint32_t*)_res);
7373         if (_res_constr.datalen > 0)
7374                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7375         else
7376                 _res_constr.data = NULL;
7377         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7378         for (size_t m = 0; m < _res_constr.datalen; m++) {
7379                 int8_tArray _res_conv_12 = _res_vals[m];
7380                 LDKSignature _res_conv_12_ref;
7381                 CHECK(*((uint32_t*)_res_conv_12) == 64);
7382                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
7383                 _res_constr.data[m] = _res_conv_12_ref;
7384         }
7385         CVec_SignatureZ_free(_res_constr);
7386 }
7387
7388 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
7389         LDKHolderCommitmentTransaction o_conv;
7390         o_conv.inner = (void*)(o & (~1));
7391         o_conv.is_owned = (o & 1) || (o == 0);
7392         o_conv = HolderCommitmentTransaction_clone(&o_conv);
7393         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7394         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
7395         return (uint64_t)ret_conv;
7396 }
7397
7398 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
7399         LDKDecodeError e_conv;
7400         e_conv.inner = (void*)(e & (~1));
7401         e_conv.is_owned = (e & 1) || (e == 0);
7402         e_conv = DecodeError_clone(&e_conv);
7403         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7404         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
7405         return (uint64_t)ret_conv;
7406 }
7407
7408 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
7409         if ((_res & 1) != 0) return;
7410         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7411         FREE((void*)_res);
7412         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
7413 }
7414
7415 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
7416         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
7417         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7418         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
7419         return (uint64_t)ret_conv;
7420 }
7421
7422 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
7423         LDKBuiltCommitmentTransaction o_conv;
7424         o_conv.inner = (void*)(o & (~1));
7425         o_conv.is_owned = (o & 1) || (o == 0);
7426         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
7427         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7428         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
7429         return (uint64_t)ret_conv;
7430 }
7431
7432 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
7433         LDKDecodeError e_conv;
7434         e_conv.inner = (void*)(e & (~1));
7435         e_conv.is_owned = (e & 1) || (e == 0);
7436         e_conv = DecodeError_clone(&e_conv);
7437         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7438         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
7439         return (uint64_t)ret_conv;
7440 }
7441
7442 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
7443         if ((_res & 1) != 0) return;
7444         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7445         FREE((void*)_res);
7446         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
7447 }
7448
7449 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
7450         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
7451         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7452         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
7453         return (uint64_t)ret_conv;
7454 }
7455
7456 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
7457         LDKTrustedClosingTransaction o_conv;
7458         o_conv.inner = (void*)(o & (~1));
7459         o_conv.is_owned = (o & 1) || (o == 0);
7460         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
7461         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
7462         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
7463         return (uint64_t)ret_conv;
7464 }
7465
7466 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
7467         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
7468         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
7469         return (uint64_t)ret_conv;
7470 }
7471
7472 void  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
7473         if ((_res & 1) != 0) return;
7474         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(((uint64_t)_res) & ~1);
7475         FREE((void*)_res);
7476         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
7477 }
7478
7479 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
7480         LDKCommitmentTransaction o_conv;
7481         o_conv.inner = (void*)(o & (~1));
7482         o_conv.is_owned = (o & 1) || (o == 0);
7483         o_conv = CommitmentTransaction_clone(&o_conv);
7484         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7485         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
7486         return (uint64_t)ret_conv;
7487 }
7488
7489 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
7490         LDKDecodeError e_conv;
7491         e_conv.inner = (void*)(e & (~1));
7492         e_conv.is_owned = (e & 1) || (e == 0);
7493         e_conv = DecodeError_clone(&e_conv);
7494         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7495         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
7496         return (uint64_t)ret_conv;
7497 }
7498
7499 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
7500         if ((_res & 1) != 0) return;
7501         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7502         FREE((void*)_res);
7503         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
7504 }
7505
7506 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
7507         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
7508         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7509         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
7510         return (uint64_t)ret_conv;
7511 }
7512
7513 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
7514         LDKTrustedCommitmentTransaction o_conv;
7515         o_conv.inner = (void*)(o & (~1));
7516         o_conv.is_owned = (o & 1) || (o == 0);
7517         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
7518         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
7519         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
7520         return (uint64_t)ret_conv;
7521 }
7522
7523 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
7524         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
7525         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
7526         return (uint64_t)ret_conv;
7527 }
7528
7529 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
7530         if ((_res & 1) != 0) return;
7531         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
7532         FREE((void*)_res);
7533         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
7534 }
7535
7536 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
7537         LDKCVec_SignatureZ o_constr;
7538         o_constr.datalen = *((uint32_t*)o);
7539         if (o_constr.datalen > 0)
7540                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7541         else
7542                 o_constr.data = NULL;
7543         int8_tArray* o_vals = (int8_tArray*)(o + 4);
7544         for (size_t m = 0; m < o_constr.datalen; m++) {
7545                 int8_tArray o_conv_12 = o_vals[m];
7546                 LDKSignature o_conv_12_ref;
7547                 CHECK(*((uint32_t*)o_conv_12) == 64);
7548                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
7549                 o_constr.data[m] = o_conv_12_ref;
7550         }
7551         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7552         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
7553         return (uint64_t)ret_conv;
7554 }
7555
7556 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
7557         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7558         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
7559         return (uint64_t)ret_conv;
7560 }
7561
7562 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
7563         if ((_res & 1) != 0) return;
7564         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
7565         FREE((void*)_res);
7566         CResult_CVec_SignatureZNoneZ_free(_res_conv);
7567 }
7568
7569 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
7570         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
7571         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7572         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
7573         return (uint64_t)ret_conv;
7574 }
7575
7576 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
7577         LDKShutdownScript o_conv;
7578         o_conv.inner = (void*)(o & (~1));
7579         o_conv.is_owned = (o & 1) || (o == 0);
7580         o_conv = ShutdownScript_clone(&o_conv);
7581         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
7582         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
7583         return (uint64_t)ret_conv;
7584 }
7585
7586 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
7587         LDKDecodeError e_conv;
7588         e_conv.inner = (void*)(e & (~1));
7589         e_conv.is_owned = (e & 1) || (e == 0);
7590         e_conv = DecodeError_clone(&e_conv);
7591         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
7592         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
7593         return (uint64_t)ret_conv;
7594 }
7595
7596 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
7597         if ((_res & 1) != 0) return;
7598         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1);
7599         FREE((void*)_res);
7600         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
7601 }
7602
7603 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
7604         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
7605         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
7606         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
7607         return (uint64_t)ret_conv;
7608 }
7609
7610 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
7611         LDKShutdownScript o_conv;
7612         o_conv.inner = (void*)(o & (~1));
7613         o_conv.is_owned = (o & 1) || (o == 0);
7614         o_conv = ShutdownScript_clone(&o_conv);
7615         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
7616         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
7617         return (uint64_t)ret_conv;
7618 }
7619
7620 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
7621         LDKInvalidShutdownScript e_conv;
7622         e_conv.inner = (void*)(e & (~1));
7623         e_conv.is_owned = (e & 1) || (e == 0);
7624         // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript
7625         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
7626         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
7627         return (uint64_t)ret_conv;
7628 }
7629
7630 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
7631         if ((_res & 1) != 0) return;
7632         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1);
7633         FREE((void*)_res);
7634         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
7635 }
7636
7637 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
7638         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7639         *ret_conv = CResult_NoneErrorZ_ok();
7640         return (uint64_t)ret_conv;
7641 }
7642
7643 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
7644         LDKIOError e_conv = LDKIOError_from_js(e);
7645         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7646         *ret_conv = CResult_NoneErrorZ_err(e_conv);
7647         return (uint64_t)ret_conv;
7648 }
7649
7650 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
7651         if ((_res & 1) != 0) return;
7652         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
7653         FREE((void*)_res);
7654         CResult_NoneErrorZ_free(_res_conv);
7655 }
7656
7657 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
7658         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
7659         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7660         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
7661         return (uint64_t)ret_conv;
7662 }
7663
7664 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
7665         LDKRouteHop o_conv;
7666         o_conv.inner = (void*)(o & (~1));
7667         o_conv.is_owned = (o & 1) || (o == 0);
7668         o_conv = RouteHop_clone(&o_conv);
7669         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
7670         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
7671         return (uint64_t)ret_conv;
7672 }
7673
7674 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
7675         LDKDecodeError e_conv;
7676         e_conv.inner = (void*)(e & (~1));
7677         e_conv.is_owned = (e & 1) || (e == 0);
7678         e_conv = DecodeError_clone(&e_conv);
7679         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
7680         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
7681         return (uint64_t)ret_conv;
7682 }
7683
7684 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
7685         if ((_res & 1) != 0) return;
7686         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
7687         FREE((void*)_res);
7688         CResult_RouteHopDecodeErrorZ_free(_res_conv);
7689 }
7690
7691 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
7692         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
7693         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
7694         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
7695         return (uint64_t)ret_conv;
7696 }
7697
7698 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
7699         LDKCVec_RouteHopZ _res_constr;
7700         _res_constr.datalen = *((uint32_t*)_res);
7701         if (_res_constr.datalen > 0)
7702                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7703         else
7704                 _res_constr.data = NULL;
7705         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7706         for (size_t k = 0; k < _res_constr.datalen; k++) {
7707                 uint32_t _res_conv_10 = _res_vals[k];
7708                 LDKRouteHop _res_conv_10_conv;
7709                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
7710                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
7711                 _res_constr.data[k] = _res_conv_10_conv;
7712         }
7713         CVec_RouteHopZ_free(_res_constr);
7714 }
7715
7716 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
7717         LDKCVec_CVec_RouteHopZZ _res_constr;
7718         _res_constr.datalen = *((uint32_t*)_res);
7719         if (_res_constr.datalen > 0)
7720                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
7721         else
7722                 _res_constr.data = NULL;
7723         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
7724         for (size_t m = 0; m < _res_constr.datalen; m++) {
7725                 uint32_tArray _res_conv_12 = _res_vals[m];
7726                 LDKCVec_RouteHopZ _res_conv_12_constr;
7727                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
7728                 if (_res_conv_12_constr.datalen > 0)
7729                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7730                 else
7731                         _res_conv_12_constr.data = NULL;
7732                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
7733                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
7734                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
7735                         LDKRouteHop _res_conv_12_conv_10_conv;
7736                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
7737                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
7738                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
7739                 }
7740                 _res_constr.data[m] = _res_conv_12_constr;
7741         }
7742         CVec_CVec_RouteHopZZ_free(_res_constr);
7743 }
7744
7745 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
7746         LDKRoute o_conv;
7747         o_conv.inner = (void*)(o & (~1));
7748         o_conv.is_owned = (o & 1) || (o == 0);
7749         o_conv = Route_clone(&o_conv);
7750         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7751         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7752         return (uint64_t)ret_conv;
7753 }
7754
7755 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
7756         LDKDecodeError e_conv;
7757         e_conv.inner = (void*)(e & (~1));
7758         e_conv.is_owned = (e & 1) || (e == 0);
7759         e_conv = DecodeError_clone(&e_conv);
7760         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7761         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7762         return (uint64_t)ret_conv;
7763 }
7764
7765 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
7766         if ((_res & 1) != 0) return;
7767         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7768         FREE((void*)_res);
7769         CResult_RouteDecodeErrorZ_free(_res_conv);
7770 }
7771
7772 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
7773         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7774         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7775         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7776         return (uint64_t)ret_conv;
7777 }
7778
7779 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
7780         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7781         *ret_copy = COption_u64Z_some(o);
7782         uint64_t ret_ref = (uint64_t)ret_copy;
7783         return ret_ref;
7784 }
7785
7786 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
7787         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7788         *ret_copy = COption_u64Z_none();
7789         uint64_t ret_ref = (uint64_t)ret_copy;
7790         return ret_ref;
7791 }
7792
7793 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
7794         if ((_res & 1) != 0) return;
7795         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
7796         FREE((void*)_res);
7797         COption_u64Z_free(_res_conv);
7798 }
7799
7800 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
7801         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
7802         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7803         *ret_copy = COption_u64Z_clone(orig_conv);
7804         uint64_t ret_ref = (uint64_t)ret_copy;
7805         return ret_ref;
7806 }
7807
7808 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
7809         LDKCVec_ChannelDetailsZ _res_constr;
7810         _res_constr.datalen = *((uint32_t*)_res);
7811         if (_res_constr.datalen > 0)
7812                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7813         else
7814                 _res_constr.data = NULL;
7815         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7816         for (size_t q = 0; q < _res_constr.datalen; q++) {
7817                 uint32_t _res_conv_16 = _res_vals[q];
7818                 LDKChannelDetails _res_conv_16_conv;
7819                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7820                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7821                 _res_constr.data[q] = _res_conv_16_conv;
7822         }
7823         CVec_ChannelDetailsZ_free(_res_constr);
7824 }
7825
7826 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
7827         LDKCVec_RouteHintZ _res_constr;
7828         _res_constr.datalen = *((uint32_t*)_res);
7829         if (_res_constr.datalen > 0)
7830                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7831         else
7832                 _res_constr.data = NULL;
7833         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7834         for (size_t l = 0; l < _res_constr.datalen; l++) {
7835                 uint32_t _res_conv_11 = _res_vals[l];
7836                 LDKRouteHint _res_conv_11_conv;
7837                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
7838                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
7839                 _res_constr.data[l] = _res_conv_11_conv;
7840         }
7841         CVec_RouteHintZ_free(_res_constr);
7842 }
7843
7844 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
7845         LDKRoute o_conv;
7846         o_conv.inner = (void*)(o & (~1));
7847         o_conv.is_owned = (o & 1) || (o == 0);
7848         o_conv = Route_clone(&o_conv);
7849         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7850         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
7851         return (uint64_t)ret_conv;
7852 }
7853
7854 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
7855         LDKLightningError e_conv;
7856         e_conv.inner = (void*)(e & (~1));
7857         e_conv.is_owned = (e & 1) || (e == 0);
7858         e_conv = LightningError_clone(&e_conv);
7859         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7860         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
7861         return (uint64_t)ret_conv;
7862 }
7863
7864 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
7865         if ((_res & 1) != 0) return;
7866         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
7867         FREE((void*)_res);
7868         CResult_RouteLightningErrorZ_free(_res_conv);
7869 }
7870
7871 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
7872         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
7873         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7874         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
7875         return (uint64_t)ret_conv;
7876 }
7877
7878 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
7879         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
7880         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
7881         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7882         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
7883         return (uint64_t)ret_conv;
7884 }
7885
7886 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
7887         LDKAccessError e_conv = LDKAccessError_from_js(e);
7888         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7889         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
7890         return (uint64_t)ret_conv;
7891 }
7892
7893 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
7894         if ((_res & 1) != 0) return;
7895         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
7896         FREE((void*)_res);
7897         CResult_TxOutAccessErrorZ_free(_res_conv);
7898 }
7899
7900 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
7901         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
7902         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7903         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
7904         return (uint64_t)ret_conv;
7905 }
7906
7907 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
7908         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
7909         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7910         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
7911         return (uint64_t)ret_ref;
7912 }
7913
7914 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
7915         LDKTransaction b_ref;
7916         b_ref.datalen = *((uint32_t*)b);
7917         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
7918         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
7919         b_ref.data_is_owned = true;
7920         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7921         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
7922         return (uint64_t)ret_ref;
7923 }
7924
7925 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
7926         if ((_res & 1) != 0) return;
7927         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
7928         FREE((void*)_res);
7929         C2Tuple_usizeTransactionZ_free(_res_conv);
7930 }
7931
7932 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
7933         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
7934         _res_constr.datalen = *((uint32_t*)_res);
7935         if (_res_constr.datalen > 0)
7936                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7937         else
7938                 _res_constr.data = NULL;
7939         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7940         for (size_t e = 0; e < _res_constr.datalen; e++) {
7941                 uint32_t _res_conv_30 = _res_vals[e];
7942                 LDKC2Tuple_usizeTransactionZ _res_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_30) & ~1);
7943                 FREE((void*)_res_conv_30);
7944                 _res_constr.data[e] = _res_conv_30_conv;
7945         }
7946         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
7947 }
7948
7949 void  __attribute__((visibility("default"))) TS_CVec_TxidZ_free(ptrArray _res) {
7950         LDKCVec_TxidZ _res_constr;
7951         _res_constr.datalen = *((uint32_t*)_res);
7952         if (_res_constr.datalen > 0)
7953                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7954         else
7955                 _res_constr.data = NULL;
7956         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7957         for (size_t m = 0; m < _res_constr.datalen; m++) {
7958                 int8_tArray _res_conv_12 = _res_vals[m];
7959                 LDKThirtyTwoBytes _res_conv_12_ref;
7960                 CHECK(*((uint32_t*)_res_conv_12) == 32);
7961                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), 32);
7962                 _res_constr.data[m] = _res_conv_12_ref;
7963         }
7964         CVec_TxidZ_free(_res_constr);
7965 }
7966
7967 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
7968         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7969         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
7970         return (uint64_t)ret_conv;
7971 }
7972
7973 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
7974         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
7975         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7976         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
7977         return (uint64_t)ret_conv;
7978 }
7979
7980 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
7981         if ((_res & 1) != 0) return;
7982         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
7983         FREE((void*)_res);
7984         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
7985 }
7986
7987 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
7988         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
7989         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7990         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
7991         return (uint64_t)ret_conv;
7992 }
7993
7994 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
7995         LDKCVec_MonitorEventZ _res_constr;
7996         _res_constr.datalen = *((uint32_t*)_res);
7997         if (_res_constr.datalen > 0)
7998                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
7999         else
8000                 _res_constr.data = NULL;
8001         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8002         for (size_t o = 0; o < _res_constr.datalen; o++) {
8003                 uint32_t _res_conv_14 = _res_vals[o];
8004                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
8005                 FREE((void*)_res_conv_14);
8006                 _res_constr.data[o] = _res_conv_14_conv;
8007         }
8008         CVec_MonitorEventZ_free(_res_constr);
8009 }
8010
8011 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
8012         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
8013         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
8014         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8015         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
8016         uint64_t ret_ref = (uint64_t)ret_copy;
8017         return ret_ref;
8018 }
8019
8020 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
8021         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8022         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
8023         uint64_t ret_ref = (uint64_t)ret_copy;
8024         return ret_ref;
8025 }
8026
8027 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
8028         if ((_res & 1) != 0) return;
8029         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
8030         FREE((void*)_res);
8031         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
8032 }
8033
8034 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
8035         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
8036         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8037         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
8038         uint64_t ret_ref = (uint64_t)ret_copy;
8039         return ret_ref;
8040 }
8041
8042 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
8043         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(((uint64_t)o) & ~1);
8044         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
8045         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
8046         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
8047         uint64_t ret_ref = (uint64_t)ret_copy;
8048         return ret_ref;
8049 }
8050
8051 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_none() {
8052         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
8053         *ret_copy = COption_NetworkUpdateZ_none();
8054         uint64_t ret_ref = (uint64_t)ret_copy;
8055         return ret_ref;
8056 }
8057
8058 void  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
8059         if ((_res & 1) != 0) return;
8060         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)_res) & ~1);
8061         FREE((void*)_res);
8062         COption_NetworkUpdateZ_free(_res_conv);
8063 }
8064
8065 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
8066         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
8067         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
8068         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
8069         uint64_t ret_ref = (uint64_t)ret_copy;
8070         return ret_ref;
8071 }
8072
8073 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
8074         LDKCVec_SpendableOutputDescriptorZ _res_constr;
8075         _res_constr.datalen = *((uint32_t*)_res);
8076         if (_res_constr.datalen > 0)
8077                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
8078         else
8079                 _res_constr.data = NULL;
8080         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8081         for (size_t b = 0; b < _res_constr.datalen; b++) {
8082                 uint32_t _res_conv_27 = _res_vals[b];
8083                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
8084                 FREE((void*)_res_conv_27);
8085                 _res_constr.data[b] = _res_conv_27_conv;
8086         }
8087         CVec_SpendableOutputDescriptorZ_free(_res_constr);
8088 }
8089
8090 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
8091         LDKCVec_MessageSendEventZ _res_constr;
8092         _res_constr.datalen = *((uint32_t*)_res);
8093         if (_res_constr.datalen > 0)
8094                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
8095         else
8096                 _res_constr.data = NULL;
8097         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8098         for (size_t s = 0; s < _res_constr.datalen; s++) {
8099                 uint32_t _res_conv_18 = _res_vals[s];
8100                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
8101                 FREE((void*)_res_conv_18);
8102                 _res_constr.data[s] = _res_conv_18_conv;
8103         }
8104         CVec_MessageSendEventZ_free(_res_constr);
8105 }
8106
8107 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
8108         LDKInitFeatures o_conv;
8109         o_conv.inner = (void*)(o & (~1));
8110         o_conv.is_owned = (o & 1) || (o == 0);
8111         o_conv = InitFeatures_clone(&o_conv);
8112         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
8113         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
8114         return (uint64_t)ret_conv;
8115 }
8116
8117 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
8118         LDKDecodeError e_conv;
8119         e_conv.inner = (void*)(e & (~1));
8120         e_conv.is_owned = (e & 1) || (e == 0);
8121         e_conv = DecodeError_clone(&e_conv);
8122         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
8123         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
8124         return (uint64_t)ret_conv;
8125 }
8126
8127 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
8128         if ((_res & 1) != 0) return;
8129         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8130         FREE((void*)_res);
8131         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
8132 }
8133
8134 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
8135         LDKNodeFeatures o_conv;
8136         o_conv.inner = (void*)(o & (~1));
8137         o_conv.is_owned = (o & 1) || (o == 0);
8138         o_conv = NodeFeatures_clone(&o_conv);
8139         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
8140         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
8141         return (uint64_t)ret_conv;
8142 }
8143
8144 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
8145         LDKDecodeError e_conv;
8146         e_conv.inner = (void*)(e & (~1));
8147         e_conv.is_owned = (e & 1) || (e == 0);
8148         e_conv = DecodeError_clone(&e_conv);
8149         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
8150         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
8151         return (uint64_t)ret_conv;
8152 }
8153
8154 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
8155         if ((_res & 1) != 0) return;
8156         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8157         FREE((void*)_res);
8158         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
8159 }
8160
8161 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
8162         LDKChannelFeatures o_conv;
8163         o_conv.inner = (void*)(o & (~1));
8164         o_conv.is_owned = (o & 1) || (o == 0);
8165         o_conv = ChannelFeatures_clone(&o_conv);
8166         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
8167         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
8168         return (uint64_t)ret_conv;
8169 }
8170
8171 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
8172         LDKDecodeError e_conv;
8173         e_conv.inner = (void*)(e & (~1));
8174         e_conv.is_owned = (e & 1) || (e == 0);
8175         e_conv = DecodeError_clone(&e_conv);
8176         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
8177         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
8178         return (uint64_t)ret_conv;
8179 }
8180
8181 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
8182         if ((_res & 1) != 0) return;
8183         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8184         FREE((void*)_res);
8185         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
8186 }
8187
8188 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
8189         LDKInvoiceFeatures o_conv;
8190         o_conv.inner = (void*)(o & (~1));
8191         o_conv.is_owned = (o & 1) || (o == 0);
8192         o_conv = InvoiceFeatures_clone(&o_conv);
8193         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
8194         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
8195         return (uint64_t)ret_conv;
8196 }
8197
8198 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
8199         LDKDecodeError e_conv;
8200         e_conv.inner = (void*)(e & (~1));
8201         e_conv.is_owned = (e & 1) || (e == 0);
8202         e_conv = DecodeError_clone(&e_conv);
8203         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
8204         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
8205         return (uint64_t)ret_conv;
8206 }
8207
8208 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
8209         if ((_res & 1) != 0) return;
8210         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8211         FREE((void*)_res);
8212         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
8213 }
8214
8215 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
8216         LDKDelayedPaymentOutputDescriptor o_conv;
8217         o_conv.inner = (void*)(o & (~1));
8218         o_conv.is_owned = (o & 1) || (o == 0);
8219         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
8220         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
8221         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
8222         return (uint64_t)ret_conv;
8223 }
8224
8225 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
8226         LDKDecodeError e_conv;
8227         e_conv.inner = (void*)(e & (~1));
8228         e_conv.is_owned = (e & 1) || (e == 0);
8229         e_conv = DecodeError_clone(&e_conv);
8230         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
8231         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
8232         return (uint64_t)ret_conv;
8233 }
8234
8235 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
8236         if ((_res & 1) != 0) return;
8237         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8238         FREE((void*)_res);
8239         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
8240 }
8241
8242 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
8243         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
8244         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
8245         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
8246         return (uint64_t)ret_conv;
8247 }
8248
8249 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
8250         LDKStaticPaymentOutputDescriptor o_conv;
8251         o_conv.inner = (void*)(o & (~1));
8252         o_conv.is_owned = (o & 1) || (o == 0);
8253         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
8254         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
8255         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
8256         return (uint64_t)ret_conv;
8257 }
8258
8259 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
8260         LDKDecodeError e_conv;
8261         e_conv.inner = (void*)(e & (~1));
8262         e_conv.is_owned = (e & 1) || (e == 0);
8263         e_conv = DecodeError_clone(&e_conv);
8264         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
8265         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
8266         return (uint64_t)ret_conv;
8267 }
8268
8269 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
8270         if ((_res & 1) != 0) return;
8271         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8272         FREE((void*)_res);
8273         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
8274 }
8275
8276 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
8277         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
8278         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
8279         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
8280         return (uint64_t)ret_conv;
8281 }
8282
8283 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
8284         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
8285         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
8286         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8287         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
8288         return (uint64_t)ret_conv;
8289 }
8290
8291 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
8292         LDKDecodeError e_conv;
8293         e_conv.inner = (void*)(e & (~1));
8294         e_conv.is_owned = (e & 1) || (e == 0);
8295         e_conv = DecodeError_clone(&e_conv);
8296         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8297         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
8298         return (uint64_t)ret_conv;
8299 }
8300
8301 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
8302         if ((_res & 1) != 0) return;
8303         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8304         FREE((void*)_res);
8305         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
8306 }
8307
8308 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
8309         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
8310         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8311         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
8312         return (uint64_t)ret_conv;
8313 }
8314
8315 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_ok() {
8316         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
8317         *ret_conv = CResult_NoneNoneZ_ok();
8318         return (uint64_t)ret_conv;
8319 }
8320
8321 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_err() {
8322         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
8323         *ret_conv = CResult_NoneNoneZ_err();
8324         return (uint64_t)ret_conv;
8325 }
8326
8327 void  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
8328         if ((_res & 1) != 0) return;
8329         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)_res) & ~1);
8330         FREE((void*)_res);
8331         CResult_NoneNoneZ_free(_res_conv);
8332 }
8333
8334 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
8335         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
8336         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
8337         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
8338         return (uint64_t)ret_conv;
8339 }
8340
8341 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
8342         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
8343         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8344         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
8345         return (uint64_t)ret_ref;
8346 }
8347
8348 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
8349         LDKSignature a_ref;
8350         CHECK(*((uint32_t*)a) == 64);
8351         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
8352         LDKCVec_SignatureZ b_constr;
8353         b_constr.datalen = *((uint32_t*)b);
8354         if (b_constr.datalen > 0)
8355                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8356         else
8357                 b_constr.data = NULL;
8358         int8_tArray* b_vals = (int8_tArray*)(b + 4);
8359         for (size_t m = 0; m < b_constr.datalen; m++) {
8360                 int8_tArray b_conv_12 = b_vals[m];
8361                 LDKSignature b_conv_12_ref;
8362                 CHECK(*((uint32_t*)b_conv_12) == 64);
8363                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
8364                 b_constr.data[m] = b_conv_12_ref;
8365         }
8366         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8367         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
8368         return (uint64_t)ret_ref;
8369 }
8370
8371 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
8372         if ((_res & 1) != 0) return;
8373         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
8374         FREE((void*)_res);
8375         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
8376 }
8377
8378 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
8379         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
8380         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
8381         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8382         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
8383         return (uint64_t)ret_conv;
8384 }
8385
8386 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
8387         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8388         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
8389         return (uint64_t)ret_conv;
8390 }
8391
8392 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
8393         if ((_res & 1) != 0) return;
8394         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
8395         FREE((void*)_res);
8396         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
8397 }
8398
8399 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
8400         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
8401         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8402         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
8403         return (uint64_t)ret_conv;
8404 }
8405
8406 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
8407         LDKSignature o_ref;
8408         CHECK(*((uint32_t*)o) == 64);
8409         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
8410         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8411         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
8412         return (uint64_t)ret_conv;
8413 }
8414
8415 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
8416         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8417         *ret_conv = CResult_SignatureNoneZ_err();
8418         return (uint64_t)ret_conv;
8419 }
8420
8421 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
8422         if ((_res & 1) != 0) return;
8423         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
8424         FREE((void*)_res);
8425         CResult_SignatureNoneZ_free(_res_conv);
8426 }
8427
8428 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
8429         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
8430         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8431         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
8432         return (uint64_t)ret_conv;
8433 }
8434
8435 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
8436         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
8437         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8438         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
8439         return (uint64_t)ret_conv;
8440 }
8441
8442 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
8443         LDKDecodeError e_conv;
8444         e_conv.inner = (void*)(e & (~1));
8445         e_conv.is_owned = (e & 1) || (e == 0);
8446         e_conv = DecodeError_clone(&e_conv);
8447         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8448         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
8449         return (uint64_t)ret_conv;
8450 }
8451
8452 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
8453         if ((_res & 1) != 0) return;
8454         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
8455         FREE((void*)_res);
8456         CResult_SignDecodeErrorZ_free(_res_conv);
8457 }
8458
8459 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
8460         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
8461         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8462         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
8463         return (uint64_t)ret_conv;
8464 }
8465
8466 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
8467         LDKCVec_u8Z _res_ref;
8468         _res_ref.datalen = *((uint32_t*)_res);
8469         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
8470         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
8471         CVec_u8Z_free(_res_ref);
8472 }
8473
8474 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray arg) {
8475         LDKRecoverableSignature arg_ref;
8476         CHECK(*((uint32_t*)arg) == 68);
8477         memcpy(arg_ref.serialized_form, (uint8_t*)(arg + 4), 68);
8478         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
8479         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
8480         return (uint64_t)ret_conv;
8481 }
8482
8483 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_err() {
8484         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
8485         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
8486         return (uint64_t)ret_conv;
8487 }
8488
8489 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
8490         if ((_res & 1) != 0) return;
8491         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
8492         FREE((void*)_res);
8493         CResult_RecoverableSignatureNoneZ_free(_res_conv);
8494 }
8495
8496 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
8497         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
8498         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
8499         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
8500         return (uint64_t)ret_conv;
8501 }
8502
8503 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
8504         LDKCVec_CVec_u8ZZ _res_constr;
8505         _res_constr.datalen = *((uint32_t*)_res);
8506         if (_res_constr.datalen > 0)
8507                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8508         else
8509                 _res_constr.data = NULL;
8510         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8511         for (size_t m = 0; m < _res_constr.datalen; m++) {
8512                 int8_tArray _res_conv_12 = _res_vals[m];
8513                 LDKCVec_u8Z _res_conv_12_ref;
8514                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
8515                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
8516                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
8517                 _res_constr.data[m] = _res_conv_12_ref;
8518         }
8519         CVec_CVec_u8ZZ_free(_res_constr);
8520 }
8521
8522 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
8523         LDKCVec_CVec_u8ZZ o_constr;
8524         o_constr.datalen = *((uint32_t*)o);
8525         if (o_constr.datalen > 0)
8526                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8527         else
8528                 o_constr.data = NULL;
8529         int8_tArray* o_vals = (int8_tArray*)(o + 4);
8530         for (size_t m = 0; m < o_constr.datalen; m++) {
8531                 int8_tArray o_conv_12 = o_vals[m];
8532                 LDKCVec_u8Z o_conv_12_ref;
8533                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
8534                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
8535                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
8536                 o_constr.data[m] = o_conv_12_ref;
8537         }
8538         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8539         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
8540         return (uint64_t)ret_conv;
8541 }
8542
8543 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
8544         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8545         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
8546         return (uint64_t)ret_conv;
8547 }
8548
8549 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
8550         if ((_res & 1) != 0) return;
8551         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
8552         FREE((void*)_res);
8553         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
8554 }
8555
8556 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
8557         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
8558         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8559         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
8560         return (uint64_t)ret_conv;
8561 }
8562
8563 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
8564         LDKInMemorySigner o_conv;
8565         o_conv.inner = (void*)(o & (~1));
8566         o_conv.is_owned = (o & 1) || (o == 0);
8567         o_conv = InMemorySigner_clone(&o_conv);
8568         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8569         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
8570         return (uint64_t)ret_conv;
8571 }
8572
8573 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
8574         LDKDecodeError e_conv;
8575         e_conv.inner = (void*)(e & (~1));
8576         e_conv.is_owned = (e & 1) || (e == 0);
8577         e_conv = DecodeError_clone(&e_conv);
8578         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8579         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
8580         return (uint64_t)ret_conv;
8581 }
8582
8583 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
8584         if ((_res & 1) != 0) return;
8585         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
8586         FREE((void*)_res);
8587         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
8588 }
8589
8590 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
8591         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
8592         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8593         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
8594         return (uint64_t)ret_conv;
8595 }
8596
8597 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
8598         LDKCVec_TxOutZ _res_constr;
8599         _res_constr.datalen = *((uint32_t*)_res);
8600         if (_res_constr.datalen > 0)
8601                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
8602         else
8603                 _res_constr.data = NULL;
8604         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8605         for (size_t h = 0; h < _res_constr.datalen; h++) {
8606                 uint32_t _res_conv_7 = _res_vals[h];
8607                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
8608                 FREE((void*)_res_conv_7);
8609                 _res_constr.data[h] = _res_conv_7_conv;
8610         }
8611         CVec_TxOutZ_free(_res_constr);
8612 }
8613
8614 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
8615         LDKTransaction o_ref;
8616         o_ref.datalen = *((uint32_t*)o);
8617         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
8618         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
8619         o_ref.data_is_owned = true;
8620         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8621         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
8622         return (uint64_t)ret_conv;
8623 }
8624
8625 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
8626         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8627         *ret_conv = CResult_TransactionNoneZ_err();
8628         return (uint64_t)ret_conv;
8629 }
8630
8631 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
8632         if ((_res & 1) != 0) return;
8633         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
8634         FREE((void*)_res);
8635         CResult_TransactionNoneZ_free(_res_conv);
8636 }
8637
8638 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
8639         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
8640         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8641         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
8642         return (uint64_t)ret_conv;
8643 }
8644
8645 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
8646         LDKThirtyTwoBytes a_ref;
8647         CHECK(*((uint32_t*)a) == 32);
8648         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8649         LDKChannelMonitor b_conv;
8650         b_conv.inner = (void*)(b & (~1));
8651         b_conv.is_owned = (b & 1) || (b == 0);
8652         b_conv = ChannelMonitor_clone(&b_conv);
8653         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8654         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
8655         return (uint64_t)ret_ref;
8656 }
8657
8658 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
8659         if ((_res & 1) != 0) return;
8660         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
8661         FREE((void*)_res);
8662         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
8663 }
8664
8665 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMonitorZZ_free(uint32_tArray _res) {
8666         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
8667         _res_constr.datalen = *((uint32_t*)_res);
8668         if (_res_constr.datalen > 0)
8669                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
8670         else
8671                 _res_constr.data = NULL;
8672         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8673         for (size_t m = 0; m < _res_constr.datalen; m++) {
8674                 uint32_t _res_conv_38 = _res_vals[m];
8675                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_38) & ~1);
8676                 FREE((void*)_res_conv_38);
8677                 _res_constr.data[m] = _res_conv_38_conv;
8678         }
8679         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
8680 }
8681
8682 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(uint32_tArray o) {
8683         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
8684         o_constr.datalen = *((uint32_t*)o);
8685         if (o_constr.datalen > 0)
8686                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
8687         else
8688                 o_constr.data = NULL;
8689         uint32_t* o_vals = (uint32_t*)(o + 4);
8690         for (size_t m = 0; m < o_constr.datalen; m++) {
8691                 uint32_t o_conv_38 = o_vals[m];
8692                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_38) & ~1);
8693                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
8694                 o_constr.data[m] = o_conv_38_conv;
8695         }
8696         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
8697         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
8698         return (uint64_t)ret_conv;
8699 }
8700
8701 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(uint32_t e) {
8702         LDKIOError e_conv = LDKIOError_from_js(e);
8703         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
8704         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
8705         return (uint64_t)ret_conv;
8706 }
8707
8708 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
8709         if ((_res & 1) != 0) return;
8710         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
8711         FREE((void*)_res);
8712         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
8713 }
8714
8715 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) {
8716         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
8717         *ret_copy = COption_u16Z_some(o);
8718         uint64_t ret_ref = (uint64_t)ret_copy;
8719         return ret_ref;
8720 }
8721
8722 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_none() {
8723         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
8724         *ret_copy = COption_u16Z_none();
8725         uint64_t ret_ref = (uint64_t)ret_copy;
8726         return ret_ref;
8727 }
8728
8729 void  __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) {
8730         if ((_res & 1) != 0) return;
8731         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
8732         FREE((void*)_res);
8733         COption_u16Z_free(_res_conv);
8734 }
8735
8736 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_clone(uint32_t orig) {
8737         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
8738         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
8739         *ret_copy = COption_u16Z_clone(orig_conv);
8740         uint64_t ret_ref = (uint64_t)ret_copy;
8741         return ret_ref;
8742 }
8743
8744 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
8745         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8746         *ret_conv = CResult_NoneAPIErrorZ_ok();
8747         return (uint64_t)ret_conv;
8748 }
8749
8750 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
8751         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
8752         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
8753         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8754         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
8755         return (uint64_t)ret_conv;
8756 }
8757
8758 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
8759         if ((_res & 1) != 0) return;
8760         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
8761         FREE((void*)_res);
8762         CResult_NoneAPIErrorZ_free(_res_conv);
8763 }
8764
8765 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
8766         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
8767         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8768         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
8769         return (uint64_t)ret_conv;
8770 }
8771
8772 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
8773         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
8774         _res_constr.datalen = *((uint32_t*)_res);
8775         if (_res_constr.datalen > 0)
8776                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
8777         else
8778                 _res_constr.data = NULL;
8779         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8780         for (size_t w = 0; w < _res_constr.datalen; w++) {
8781                 uint32_t _res_conv_22 = _res_vals[w];
8782                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
8783                 FREE((void*)_res_conv_22);
8784                 _res_constr.data[w] = _res_conv_22_conv;
8785         }
8786         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
8787 }
8788
8789 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
8790         LDKCVec_APIErrorZ _res_constr;
8791         _res_constr.datalen = *((uint32_t*)_res);
8792         if (_res_constr.datalen > 0)
8793                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
8794         else
8795                 _res_constr.data = NULL;
8796         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8797         for (size_t k = 0; k < _res_constr.datalen; k++) {
8798                 uint32_t _res_conv_10 = _res_vals[k];
8799                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
8800                 FREE((void*)_res_conv_10);
8801                 _res_constr.data[k] = _res_conv_10_conv;
8802         }
8803         CVec_APIErrorZ_free(_res_constr);
8804 }
8805
8806 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
8807         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8808         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
8809         return (uint64_t)ret_conv;
8810 }
8811
8812 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
8813         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
8814         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
8815         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8816         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
8817         return (uint64_t)ret_conv;
8818 }
8819
8820 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
8821         if ((_res & 1) != 0) return;
8822         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
8823         FREE((void*)_res);
8824         CResult_NonePaymentSendFailureZ_free(_res_conv);
8825 }
8826
8827 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
8828         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
8829         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8830         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
8831         return (uint64_t)ret_conv;
8832 }
8833
8834 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_ok(int8_tArray o) {
8835         LDKThirtyTwoBytes o_ref;
8836         CHECK(*((uint32_t*)o) == 32);
8837         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
8838         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
8839         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
8840         return (uint64_t)ret_conv;
8841 }
8842
8843 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_err(uint32_t e) {
8844         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
8845         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
8846         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
8847         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
8848         return (uint64_t)ret_conv;
8849 }
8850
8851 void  __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_free(uint32_t _res) {
8852         if ((_res & 1) != 0) return;
8853         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
8854         FREE((void*)_res);
8855         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
8856 }
8857
8858 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_clone(uint32_t orig) {
8859         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)(orig & ~1);
8860         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
8861         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
8862         return (uint64_t)ret_conv;
8863 }
8864
8865 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
8866         LDKCVec_NetAddressZ _res_constr;
8867         _res_constr.datalen = *((uint32_t*)_res);
8868         if (_res_constr.datalen > 0)
8869                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
8870         else
8871                 _res_constr.data = NULL;
8872         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8873         for (size_t m = 0; m < _res_constr.datalen; m++) {
8874                 uint32_t _res_conv_12 = _res_vals[m];
8875                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
8876                 FREE((void*)_res_conv_12);
8877                 _res_constr.data[m] = _res_conv_12_conv;
8878         }
8879         CVec_NetAddressZ_free(_res_constr);
8880 }
8881
8882 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
8883         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
8884         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
8885         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
8886         return (uint64_t)ret_ref;
8887 }
8888
8889 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
8890         LDKThirtyTwoBytes a_ref;
8891         CHECK(*((uint32_t*)a) == 32);
8892         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8893         LDKThirtyTwoBytes b_ref;
8894         CHECK(*((uint32_t*)b) == 32);
8895         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
8896         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
8897         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
8898         return (uint64_t)ret_ref;
8899 }
8900
8901 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
8902         if ((_res & 1) != 0) return;
8903         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
8904         FREE((void*)_res);
8905         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
8906 }
8907
8908 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
8909         LDKThirtyTwoBytes o_ref;
8910         CHECK(*((uint32_t*)o) == 32);
8911         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
8912         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8913         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
8914         return (uint64_t)ret_conv;
8915 }
8916
8917 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
8918         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
8919         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
8920         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8921         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
8922         return (uint64_t)ret_conv;
8923 }
8924
8925 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
8926         if ((_res & 1) != 0) return;
8927         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
8928         FREE((void*)_res);
8929         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
8930 }
8931
8932 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
8933         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
8934         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8935         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
8936         return (uint64_t)ret_conv;
8937 }
8938
8939 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
8940         LDKCVec_ChannelMonitorZ _res_constr;
8941         _res_constr.datalen = *((uint32_t*)_res);
8942         if (_res_constr.datalen > 0)
8943                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
8944         else
8945                 _res_constr.data = NULL;
8946         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8947         for (size_t q = 0; q < _res_constr.datalen; q++) {
8948                 uint32_t _res_conv_16 = _res_vals[q];
8949                 LDKChannelMonitor _res_conv_16_conv;
8950                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8951                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8952                 _res_constr.data[q] = _res_conv_16_conv;
8953         }
8954         CVec_ChannelMonitorZ_free(_res_constr);
8955 }
8956
8957 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
8958         LDKThirtyTwoBytes a_ref;
8959         CHECK(*((uint32_t*)a) == 32);
8960         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8961         LDKChannelManager b_conv;
8962         b_conv.inner = (void*)(b & (~1));
8963         b_conv.is_owned = (b & 1) || (b == 0);
8964         // Warning: we need a move here but no clone is available for LDKChannelManager
8965         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
8966         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
8967         return (uint64_t)ret_ref;
8968 }
8969
8970 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
8971         if ((_res & 1) != 0) return;
8972         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
8973         FREE((void*)_res);
8974         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
8975 }
8976
8977 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
8978         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
8979         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
8980         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8981         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
8982         return (uint64_t)ret_conv;
8983 }
8984
8985 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
8986         LDKDecodeError e_conv;
8987         e_conv.inner = (void*)(e & (~1));
8988         e_conv.is_owned = (e & 1) || (e == 0);
8989         e_conv = DecodeError_clone(&e_conv);
8990         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8991         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
8992         return (uint64_t)ret_conv;
8993 }
8994
8995 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
8996         if ((_res & 1) != 0) return;
8997         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8998         FREE((void*)_res);
8999         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
9000 }
9001
9002 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
9003         LDKChannelConfig o_conv;
9004         o_conv.inner = (void*)(o & (~1));
9005         o_conv.is_owned = (o & 1) || (o == 0);
9006         o_conv = ChannelConfig_clone(&o_conv);
9007         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9008         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
9009         return (uint64_t)ret_conv;
9010 }
9011
9012 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
9013         LDKDecodeError e_conv;
9014         e_conv.inner = (void*)(e & (~1));
9015         e_conv.is_owned = (e & 1) || (e == 0);
9016         e_conv = DecodeError_clone(&e_conv);
9017         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9018         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
9019         return (uint64_t)ret_conv;
9020 }
9021
9022 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
9023         if ((_res & 1) != 0) return;
9024         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
9025         FREE((void*)_res);
9026         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
9027 }
9028
9029 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
9030         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
9031         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9032         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
9033         return (uint64_t)ret_conv;
9034 }
9035
9036 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
9037         LDKOutPoint o_conv;
9038         o_conv.inner = (void*)(o & (~1));
9039         o_conv.is_owned = (o & 1) || (o == 0);
9040         o_conv = OutPoint_clone(&o_conv);
9041         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9042         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
9043         return (uint64_t)ret_conv;
9044 }
9045
9046 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
9047         LDKDecodeError e_conv;
9048         e_conv.inner = (void*)(e & (~1));
9049         e_conv.is_owned = (e & 1) || (e == 0);
9050         e_conv = DecodeError_clone(&e_conv);
9051         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9052         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
9053         return (uint64_t)ret_conv;
9054 }
9055
9056 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
9057         if ((_res & 1) != 0) return;
9058         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
9059         FREE((void*)_res);
9060         CResult_OutPointDecodeErrorZ_free(_res_conv);
9061 }
9062
9063 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
9064         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
9065         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9066         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
9067         return (uint64_t)ret_conv;
9068 }
9069
9070 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_some(uint32_t o) {
9071         LDKType o_conv = *(LDKType*)(((uint64_t)o) & ~1);
9072         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9073         *ret_copy = COption_TypeZ_some(o_conv);
9074         uint64_t ret_ref = (uint64_t)ret_copy;
9075         return ret_ref;
9076 }
9077
9078 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_none() {
9079         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9080         *ret_copy = COption_TypeZ_none();
9081         uint64_t ret_ref = (uint64_t)ret_copy;
9082         return ret_ref;
9083 }
9084
9085 void  __attribute__((visibility("default"))) TS_COption_TypeZ_free(uint32_t _res) {
9086         if ((_res & 1) != 0) return;
9087         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(((uint64_t)_res) & ~1);
9088         FREE((void*)_res);
9089         COption_TypeZ_free(_res_conv);
9090 }
9091
9092 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_clone(uint32_t orig) {
9093         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
9094         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9095         *ret_copy = COption_TypeZ_clone(orig_conv);
9096         uint64_t ret_ref = (uint64_t)ret_copy;
9097         return ret_ref;
9098 }
9099
9100 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
9101         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(((uint64_t)o) & ~1);
9102         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
9103         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9104         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
9105         return (uint64_t)ret_conv;
9106 }
9107
9108 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
9109         LDKDecodeError e_conv;
9110         e_conv.inner = (void*)(e & (~1));
9111         e_conv.is_owned = (e & 1) || (e == 0);
9112         e_conv = DecodeError_clone(&e_conv);
9113         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9114         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
9115         return (uint64_t)ret_conv;
9116 }
9117
9118 void  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
9119         if ((_res & 1) != 0) return;
9120         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9121         FREE((void*)_res);
9122         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
9123 }
9124
9125 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
9126         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
9127         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9128         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
9129         return (uint64_t)ret_conv;
9130 }
9131
9132 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
9133         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
9134         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
9135         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
9136         return (uint64_t)ret_conv;
9137 }
9138
9139 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err() {
9140         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
9141         *ret_conv = CResult_SiPrefixNoneZ_err();
9142         return (uint64_t)ret_conv;
9143 }
9144
9145 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
9146         if ((_res & 1) != 0) return;
9147         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
9148         FREE((void*)_res);
9149         CResult_SiPrefixNoneZ_free(_res_conv);
9150 }
9151
9152 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
9153         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
9154         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
9155         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
9156         return (uint64_t)ret_conv;
9157 }
9158
9159 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
9160         LDKInvoice o_conv;
9161         o_conv.inner = (void*)(o & (~1));
9162         o_conv.is_owned = (o & 1) || (o == 0);
9163         o_conv = Invoice_clone(&o_conv);
9164         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
9165         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
9166         return (uint64_t)ret_conv;
9167 }
9168
9169 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
9170         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
9171         *ret_conv = CResult_InvoiceNoneZ_err();
9172         return (uint64_t)ret_conv;
9173 }
9174
9175 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
9176         if ((_res & 1) != 0) return;
9177         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
9178         FREE((void*)_res);
9179         CResult_InvoiceNoneZ_free(_res_conv);
9180 }
9181
9182 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
9183         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
9184         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
9185         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
9186         return (uint64_t)ret_conv;
9187 }
9188
9189 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
9190         LDKSignedRawInvoice o_conv;
9191         o_conv.inner = (void*)(o & (~1));
9192         o_conv.is_owned = (o & 1) || (o == 0);
9193         o_conv = SignedRawInvoice_clone(&o_conv);
9194         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
9195         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
9196         return (uint64_t)ret_conv;
9197 }
9198
9199 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
9200         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
9201         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
9202         return (uint64_t)ret_conv;
9203 }
9204
9205 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
9206         if ((_res & 1) != 0) return;
9207         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
9208         FREE((void*)_res);
9209         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
9210 }
9211
9212 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
9213         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
9214         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
9215         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
9216         return (uint64_t)ret_conv;
9217 }
9218
9219 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
9220         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
9221         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
9222         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
9223         return (uint64_t)ret_ref;
9224 }
9225
9226 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
9227         LDKRawInvoice a_conv;
9228         a_conv.inner = (void*)(a & (~1));
9229         a_conv.is_owned = (a & 1) || (a == 0);
9230         a_conv = RawInvoice_clone(&a_conv);
9231         LDKThirtyTwoBytes b_ref;
9232         CHECK(*((uint32_t*)b) == 32);
9233         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
9234         LDKInvoiceSignature c_conv;
9235         c_conv.inner = (void*)(c & (~1));
9236         c_conv.is_owned = (c & 1) || (c == 0);
9237         c_conv = InvoiceSignature_clone(&c_conv);
9238         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
9239         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
9240         return (uint64_t)ret_ref;
9241 }
9242
9243 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
9244         if ((_res & 1) != 0) return;
9245         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
9246         FREE((void*)_res);
9247         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
9248 }
9249
9250 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
9251         LDKPayeePubKey o_conv;
9252         o_conv.inner = (void*)(o & (~1));
9253         o_conv.is_owned = (o & 1) || (o == 0);
9254         o_conv = PayeePubKey_clone(&o_conv);
9255         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
9256         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
9257         return (uint64_t)ret_conv;
9258 }
9259
9260 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
9261         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9262         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
9263         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
9264         return (uint64_t)ret_conv;
9265 }
9266
9267 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
9268         if ((_res & 1) != 0) return;
9269         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
9270         FREE((void*)_res);
9271         CResult_PayeePubKeyErrorZ_free(_res_conv);
9272 }
9273
9274 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
9275         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
9276         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
9277         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
9278         return (uint64_t)ret_conv;
9279 }
9280
9281 void  __attribute__((visibility("default"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
9282         LDKCVec_PrivateRouteZ _res_constr;
9283         _res_constr.datalen = *((uint32_t*)_res);
9284         if (_res_constr.datalen > 0)
9285                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
9286         else
9287                 _res_constr.data = NULL;
9288         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9289         for (size_t o = 0; o < _res_constr.datalen; o++) {
9290                 uint32_t _res_conv_14 = _res_vals[o];
9291                 LDKPrivateRoute _res_conv_14_conv;
9292                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
9293                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
9294                 _res_constr.data[o] = _res_conv_14_conv;
9295         }
9296         CVec_PrivateRouteZ_free(_res_constr);
9297 }
9298
9299 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
9300         LDKPositiveTimestamp o_conv;
9301         o_conv.inner = (void*)(o & (~1));
9302         o_conv.is_owned = (o & 1) || (o == 0);
9303         o_conv = PositiveTimestamp_clone(&o_conv);
9304         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
9305         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
9306         return (uint64_t)ret_conv;
9307 }
9308
9309 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
9310         LDKCreationError e_conv = LDKCreationError_from_js(e);
9311         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
9312         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
9313         return (uint64_t)ret_conv;
9314 }
9315
9316 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
9317         if ((_res & 1) != 0) return;
9318         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
9319         FREE((void*)_res);
9320         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
9321 }
9322
9323 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
9324         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
9325         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
9326         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
9327         return (uint64_t)ret_conv;
9328 }
9329
9330 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_ok() {
9331         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
9332         *ret_conv = CResult_NoneSemanticErrorZ_ok();
9333         return (uint64_t)ret_conv;
9334 }
9335
9336 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
9337         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
9338         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
9339         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
9340         return (uint64_t)ret_conv;
9341 }
9342
9343 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
9344         if ((_res & 1) != 0) return;
9345         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
9346         FREE((void*)_res);
9347         CResult_NoneSemanticErrorZ_free(_res_conv);
9348 }
9349
9350 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
9351         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
9352         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
9353         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
9354         return (uint64_t)ret_conv;
9355 }
9356
9357 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
9358         LDKInvoice o_conv;
9359         o_conv.inner = (void*)(o & (~1));
9360         o_conv.is_owned = (o & 1) || (o == 0);
9361         o_conv = Invoice_clone(&o_conv);
9362         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
9363         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
9364         return (uint64_t)ret_conv;
9365 }
9366
9367 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
9368         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
9369         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
9370         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
9371         return (uint64_t)ret_conv;
9372 }
9373
9374 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
9375         if ((_res & 1) != 0) return;
9376         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
9377         FREE((void*)_res);
9378         CResult_InvoiceSemanticErrorZ_free(_res_conv);
9379 }
9380
9381 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
9382         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
9383         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
9384         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
9385         return (uint64_t)ret_conv;
9386 }
9387
9388 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
9389         LDKDescription o_conv;
9390         o_conv.inner = (void*)(o & (~1));
9391         o_conv.is_owned = (o & 1) || (o == 0);
9392         o_conv = Description_clone(&o_conv);
9393         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
9394         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
9395         return (uint64_t)ret_conv;
9396 }
9397
9398 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
9399         LDKCreationError e_conv = LDKCreationError_from_js(e);
9400         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
9401         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
9402         return (uint64_t)ret_conv;
9403 }
9404
9405 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
9406         if ((_res & 1) != 0) return;
9407         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
9408         FREE((void*)_res);
9409         CResult_DescriptionCreationErrorZ_free(_res_conv);
9410 }
9411
9412 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
9413         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
9414         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
9415         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
9416         return (uint64_t)ret_conv;
9417 }
9418
9419 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_ok(uint32_t o) {
9420         LDKExpiryTime o_conv;
9421         o_conv.inner = (void*)(o & (~1));
9422         o_conv.is_owned = (o & 1) || (o == 0);
9423         o_conv = ExpiryTime_clone(&o_conv);
9424         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
9425         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
9426         return (uint64_t)ret_conv;
9427 }
9428
9429 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_err(uint32_t e) {
9430         LDKCreationError e_conv = LDKCreationError_from_js(e);
9431         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
9432         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
9433         return (uint64_t)ret_conv;
9434 }
9435
9436 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
9437         if ((_res & 1) != 0) return;
9438         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
9439         FREE((void*)_res);
9440         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
9441 }
9442
9443 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone(uint32_t orig) {
9444         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
9445         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
9446         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
9447         return (uint64_t)ret_conv;
9448 }
9449
9450 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
9451         LDKPrivateRoute o_conv;
9452         o_conv.inner = (void*)(o & (~1));
9453         o_conv.is_owned = (o & 1) || (o == 0);
9454         o_conv = PrivateRoute_clone(&o_conv);
9455         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
9456         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
9457         return (uint64_t)ret_conv;
9458 }
9459
9460 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
9461         LDKCreationError e_conv = LDKCreationError_from_js(e);
9462         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
9463         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
9464         return (uint64_t)ret_conv;
9465 }
9466
9467 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
9468         if ((_res & 1) != 0) return;
9469         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
9470         FREE((void*)_res);
9471         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
9472 }
9473
9474 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
9475         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
9476         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
9477         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
9478         return (uint64_t)ret_conv;
9479 }
9480
9481 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_ok(jstring o) {
9482         LDKStr o_conv = str_ref_to_owned_c(o);
9483         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
9484         *ret_conv = CResult_StringErrorZ_ok(o_conv);
9485         return (uint64_t)ret_conv;
9486 }
9487
9488 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uint32_t e) {
9489         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9490         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
9491         *ret_conv = CResult_StringErrorZ_err(e_conv);
9492         return (uint64_t)ret_conv;
9493 }
9494
9495 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
9496         if ((_res & 1) != 0) return;
9497         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
9498         FREE((void*)_res);
9499         CResult_StringErrorZ_free(_res_conv);
9500 }
9501
9502 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
9503         LDKChannelMonitorUpdate o_conv;
9504         o_conv.inner = (void*)(o & (~1));
9505         o_conv.is_owned = (o & 1) || (o == 0);
9506         o_conv = ChannelMonitorUpdate_clone(&o_conv);
9507         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
9508         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
9509         return (uint64_t)ret_conv;
9510 }
9511
9512 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
9513         LDKDecodeError e_conv;
9514         e_conv.inner = (void*)(e & (~1));
9515         e_conv.is_owned = (e & 1) || (e == 0);
9516         e_conv = DecodeError_clone(&e_conv);
9517         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
9518         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
9519         return (uint64_t)ret_conv;
9520 }
9521
9522 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
9523         if ((_res & 1) != 0) return;
9524         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9525         FREE((void*)_res);
9526         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
9527 }
9528
9529 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
9530         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
9531         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
9532         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
9533         return (uint64_t)ret_conv;
9534 }
9535
9536 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
9537         LDKHTLCUpdate o_conv;
9538         o_conv.inner = (void*)(o & (~1));
9539         o_conv.is_owned = (o & 1) || (o == 0);
9540         o_conv = HTLCUpdate_clone(&o_conv);
9541         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
9542         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
9543         return (uint64_t)ret_conv;
9544 }
9545
9546 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
9547         LDKDecodeError e_conv;
9548         e_conv.inner = (void*)(e & (~1));
9549         e_conv.is_owned = (e & 1) || (e == 0);
9550         e_conv = DecodeError_clone(&e_conv);
9551         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
9552         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
9553         return (uint64_t)ret_conv;
9554 }
9555
9556 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
9557         if ((_res & 1) != 0) return;
9558         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9559         FREE((void*)_res);
9560         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
9561 }
9562
9563 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
9564         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
9565         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
9566         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
9567         return (uint64_t)ret_conv;
9568 }
9569
9570 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
9571         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
9572         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
9573         return (uint64_t)ret_conv;
9574 }
9575
9576 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
9577         LDKMonitorUpdateError e_conv;
9578         e_conv.inner = (void*)(e & (~1));
9579         e_conv.is_owned = (e & 1) || (e == 0);
9580         e_conv = MonitorUpdateError_clone(&e_conv);
9581         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
9582         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
9583         return (uint64_t)ret_conv;
9584 }
9585
9586 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
9587         if ((_res & 1) != 0) return;
9588         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
9589         FREE((void*)_res);
9590         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
9591 }
9592
9593 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
9594         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
9595         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
9596         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
9597         return (uint64_t)ret_conv;
9598 }
9599
9600 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
9601         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
9602         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
9603         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
9604         return (uint64_t)ret_ref;
9605 }
9606
9607 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
9608         LDKOutPoint a_conv;
9609         a_conv.inner = (void*)(a & (~1));
9610         a_conv.is_owned = (a & 1) || (a == 0);
9611         a_conv = OutPoint_clone(&a_conv);
9612         LDKCVec_u8Z b_ref;
9613         b_ref.datalen = *((uint32_t*)b);
9614         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
9615         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
9616         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
9617         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
9618         return (uint64_t)ret_ref;
9619 }
9620
9621 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
9622         if ((_res & 1) != 0) return;
9623         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
9624         FREE((void*)_res);
9625         C2Tuple_OutPointScriptZ_free(_res_conv);
9626 }
9627
9628 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
9629         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
9630         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
9631         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
9632         return (uint64_t)ret_ref;
9633 }
9634
9635 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
9636         LDKCVec_u8Z b_ref;
9637         b_ref.datalen = *((uint32_t*)b);
9638         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
9639         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
9640         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
9641         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
9642         return (uint64_t)ret_ref;
9643 }
9644
9645 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
9646         if ((_res & 1) != 0) return;
9647         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
9648         FREE((void*)_res);
9649         C2Tuple_u32ScriptZ_free(_res_conv);
9650 }
9651
9652 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
9653         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
9654         _res_constr.datalen = *((uint32_t*)_res);
9655         if (_res_constr.datalen > 0)
9656                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
9657         else
9658                 _res_constr.data = NULL;
9659         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9660         for (size_t e = 0; e < _res_constr.datalen; e++) {
9661                 uint32_t _res_conv_30 = _res_vals[e];
9662                 LDKC2Tuple_u32ScriptZ _res_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_30) & ~1);
9663                 FREE((void*)_res_conv_30);
9664                 _res_constr.data[e] = _res_conv_30_conv;
9665         }
9666         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
9667 }
9668
9669 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
9670         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
9671         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
9672         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
9673         return (uint64_t)ret_ref;
9674 }
9675
9676 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
9677         LDKThirtyTwoBytes a_ref;
9678         CHECK(*((uint32_t*)a) == 32);
9679         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9680         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
9681         b_constr.datalen = *((uint32_t*)b);
9682         if (b_constr.datalen > 0)
9683                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
9684         else
9685                 b_constr.data = NULL;
9686         uint32_t* b_vals = (uint32_t*)(b + 4);
9687         for (size_t e = 0; e < b_constr.datalen; e++) {
9688                 uint32_t b_conv_30 = b_vals[e];
9689                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
9690                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
9691                 b_constr.data[e] = b_conv_30_conv;
9692         }
9693         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
9694         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
9695         return (uint64_t)ret_ref;
9696 }
9697
9698 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
9699         if ((_res & 1) != 0) return;
9700         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
9701         FREE((void*)_res);
9702         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
9703 }
9704
9705 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
9706         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
9707         _res_constr.datalen = *((uint32_t*)_res);
9708         if (_res_constr.datalen > 0)
9709                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
9710         else
9711                 _res_constr.data = NULL;
9712         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9713         for (size_t c = 0; c < _res_constr.datalen; c++) {
9714                 uint32_t _res_conv_54 = _res_vals[c];
9715                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_54_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_54) & ~1);
9716                 FREE((void*)_res_conv_54);
9717                 _res_constr.data[c] = _res_conv_54_conv;
9718         }
9719         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
9720 }
9721
9722 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
9723         LDKCVec_EventZ _res_constr;
9724         _res_constr.datalen = *((uint32_t*)_res);
9725         if (_res_constr.datalen > 0)
9726                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
9727         else
9728                 _res_constr.data = NULL;
9729         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9730         for (size_t h = 0; h < _res_constr.datalen; h++) {
9731                 uint32_t _res_conv_7 = _res_vals[h];
9732                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
9733                 FREE((void*)_res_conv_7);
9734                 _res_constr.data[h] = _res_conv_7_conv;
9735         }
9736         CVec_EventZ_free(_res_constr);
9737 }
9738
9739 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
9740         LDKCVec_TransactionZ _res_constr;
9741         _res_constr.datalen = *((uint32_t*)_res);
9742         if (_res_constr.datalen > 0)
9743                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
9744         else
9745                 _res_constr.data = NULL;
9746         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
9747         for (size_t m = 0; m < _res_constr.datalen; m++) {
9748                 int8_tArray _res_conv_12 = _res_vals[m];
9749                 LDKTransaction _res_conv_12_ref;
9750                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
9751                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
9752                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
9753                 _res_conv_12_ref.data_is_owned = true;
9754                 _res_constr.data[m] = _res_conv_12_ref;
9755         }
9756         CVec_TransactionZ_free(_res_constr);
9757 }
9758
9759 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
9760         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
9761         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
9762         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
9763         return (uint64_t)ret_ref;
9764 }
9765
9766 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
9767         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
9768         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
9769         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
9770         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
9771         return (uint64_t)ret_ref;
9772 }
9773
9774 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
9775         if ((_res & 1) != 0) return;
9776         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
9777         FREE((void*)_res);
9778         C2Tuple_u32TxOutZ_free(_res_conv);
9779 }
9780
9781 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
9782         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
9783         _res_constr.datalen = *((uint32_t*)_res);
9784         if (_res_constr.datalen > 0)
9785                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
9786         else
9787                 _res_constr.data = NULL;
9788         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9789         for (size_t z = 0; z < _res_constr.datalen; z++) {
9790                 uint32_t _res_conv_25 = _res_vals[z];
9791                 LDKC2Tuple_u32TxOutZ _res_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_25) & ~1);
9792                 FREE((void*)_res_conv_25);
9793                 _res_constr.data[z] = _res_conv_25_conv;
9794         }
9795         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
9796 }
9797
9798 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
9799         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
9800         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
9801         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
9802         return (uint64_t)ret_ref;
9803 }
9804
9805 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
9806         LDKThirtyTwoBytes a_ref;
9807         CHECK(*((uint32_t*)a) == 32);
9808         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9809         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
9810         b_constr.datalen = *((uint32_t*)b);
9811         if (b_constr.datalen > 0)
9812                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
9813         else
9814                 b_constr.data = NULL;
9815         uint32_t* b_vals = (uint32_t*)(b + 4);
9816         for (size_t z = 0; z < b_constr.datalen; z++) {
9817                 uint32_t b_conv_25 = b_vals[z];
9818                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
9819                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
9820                 b_constr.data[z] = b_conv_25_conv;
9821         }
9822         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
9823         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
9824         return (uint64_t)ret_ref;
9825 }
9826
9827 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
9828         if ((_res & 1) != 0) return;
9829         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
9830         FREE((void*)_res);
9831         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
9832 }
9833
9834 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
9835         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
9836         _res_constr.datalen = *((uint32_t*)_res);
9837         if (_res_constr.datalen > 0)
9838                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
9839         else
9840                 _res_constr.data = NULL;
9841         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9842         for (size_t x = 0; x < _res_constr.datalen; x++) {
9843                 uint32_t _res_conv_49 = _res_vals[x];
9844                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_49) & ~1);
9845                 FREE((void*)_res_conv_49);
9846                 _res_constr.data[x] = _res_conv_49_conv;
9847         }
9848         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
9849 }
9850
9851 void  __attribute__((visibility("default"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
9852         LDKCVec_BalanceZ _res_constr;
9853         _res_constr.datalen = *((uint32_t*)_res);
9854         if (_res_constr.datalen > 0)
9855                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
9856         else
9857                 _res_constr.data = NULL;
9858         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9859         for (size_t j = 0; j < _res_constr.datalen; j++) {
9860                 uint32_t _res_conv_9 = _res_vals[j];
9861                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(((uint64_t)_res_conv_9) & ~1);
9862                 FREE((void*)_res_conv_9);
9863                 _res_constr.data[j] = _res_conv_9_conv;
9864         }
9865         CVec_BalanceZ_free(_res_constr);
9866 }
9867
9868 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
9869         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
9870         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
9871         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
9872         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
9873         return (uint64_t)ret_conv;
9874 }
9875
9876 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
9877         LDKDecodeError e_conv;
9878         e_conv.inner = (void*)(e & (~1));
9879         e_conv.is_owned = (e & 1) || (e == 0);
9880         e_conv = DecodeError_clone(&e_conv);
9881         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
9882         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
9883         return (uint64_t)ret_conv;
9884 }
9885
9886 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
9887         if ((_res & 1) != 0) return;
9888         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9889         FREE((void*)_res);
9890         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
9891 }
9892
9893 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
9894         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9895         *ret_conv = CResult_NoneLightningErrorZ_ok();
9896         return (uint64_t)ret_conv;
9897 }
9898
9899 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
9900         LDKLightningError e_conv;
9901         e_conv.inner = (void*)(e & (~1));
9902         e_conv.is_owned = (e & 1) || (e == 0);
9903         e_conv = LightningError_clone(&e_conv);
9904         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9905         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
9906         return (uint64_t)ret_conv;
9907 }
9908
9909 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
9910         if ((_res & 1) != 0) return;
9911         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
9912         FREE((void*)_res);
9913         CResult_NoneLightningErrorZ_free(_res_conv);
9914 }
9915
9916 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
9917         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
9918         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9919         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
9920         return (uint64_t)ret_conv;
9921 }
9922
9923 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
9924         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
9925         LDKC2Tuple_PublicKeyTypeZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
9926         *ret_ref = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
9927         return (uint64_t)ret_ref;
9928 }
9929
9930 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
9931         LDKPublicKey a_ref;
9932         CHECK(*((uint32_t*)a) == 33);
9933         memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33);
9934         LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1);
9935         LDKC2Tuple_PublicKeyTypeZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
9936         *ret_ref = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
9937         return (uint64_t)ret_ref;
9938 }
9939
9940 void  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
9941         if ((_res & 1) != 0) return;
9942         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res) & ~1);
9943         FREE((void*)_res);
9944         C2Tuple_PublicKeyTypeZ_free(_res_conv);
9945 }
9946
9947 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
9948         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
9949         _res_constr.datalen = *((uint32_t*)_res);
9950         if (_res_constr.datalen > 0)
9951                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9952         else
9953                 _res_constr.data = NULL;
9954         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9955         for (size_t c = 0; c < _res_constr.datalen; c++) {
9956                 uint32_t _res_conv_28 = _res_vals[c];
9957                 LDKC2Tuple_PublicKeyTypeZ _res_conv_28_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_28) & ~1);
9958                 FREE((void*)_res_conv_28);
9959                 _res_constr.data[c] = _res_conv_28_conv;
9960         }
9961         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
9962 }
9963
9964 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
9965         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9966         *ret_conv = CResult_boolLightningErrorZ_ok(o);
9967         return (uint64_t)ret_conv;
9968 }
9969
9970 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
9971         LDKLightningError e_conv;
9972         e_conv.inner = (void*)(e & (~1));
9973         e_conv.is_owned = (e & 1) || (e == 0);
9974         e_conv = LightningError_clone(&e_conv);
9975         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9976         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
9977         return (uint64_t)ret_conv;
9978 }
9979
9980 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
9981         if ((_res & 1) != 0) return;
9982         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
9983         FREE((void*)_res);
9984         CResult_boolLightningErrorZ_free(_res_conv);
9985 }
9986
9987 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
9988         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
9989         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9990         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
9991         return (uint64_t)ret_conv;
9992 }
9993
9994 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
9995         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
9996         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9997         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
9998         return (uint64_t)ret_ref;
9999 }
10000
10001 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
10002         LDKChannelAnnouncement a_conv;
10003         a_conv.inner = (void*)(a & (~1));
10004         a_conv.is_owned = (a & 1) || (a == 0);
10005         a_conv = ChannelAnnouncement_clone(&a_conv);
10006         LDKChannelUpdate b_conv;
10007         b_conv.inner = (void*)(b & (~1));
10008         b_conv.is_owned = (b & 1) || (b == 0);
10009         b_conv = ChannelUpdate_clone(&b_conv);
10010         LDKChannelUpdate c_conv;
10011         c_conv.inner = (void*)(c & (~1));
10012         c_conv.is_owned = (c & 1) || (c == 0);
10013         c_conv = ChannelUpdate_clone(&c_conv);
10014         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
10015         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
10016         return (uint64_t)ret_ref;
10017 }
10018
10019 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
10020         if ((_res & 1) != 0) return;
10021         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
10022         FREE((void*)_res);
10023         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
10024 }
10025
10026 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
10027         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
10028         _res_constr.datalen = *((uint32_t*)_res);
10029         if (_res_constr.datalen > 0)
10030                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
10031         else
10032                 _res_constr.data = NULL;
10033         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10034         for (size_t l = 0; l < _res_constr.datalen; l++) {
10035                 uint32_t _res_conv_63 = _res_vals[l];
10036                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
10037                 FREE((void*)_res_conv_63);
10038                 _res_constr.data[l] = _res_conv_63_conv;
10039         }
10040         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
10041 }
10042
10043 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
10044         LDKCVec_NodeAnnouncementZ _res_constr;
10045         _res_constr.datalen = *((uint32_t*)_res);
10046         if (_res_constr.datalen > 0)
10047                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
10048         else
10049                 _res_constr.data = NULL;
10050         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10051         for (size_t s = 0; s < _res_constr.datalen; s++) {
10052                 uint32_t _res_conv_18 = _res_vals[s];
10053                 LDKNodeAnnouncement _res_conv_18_conv;
10054                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
10055                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
10056                 _res_constr.data[s] = _res_conv_18_conv;
10057         }
10058         CVec_NodeAnnouncementZ_free(_res_constr);
10059 }
10060
10061 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
10062         LDKCVec_PublicKeyZ _res_constr;
10063         _res_constr.datalen = *((uint32_t*)_res);
10064         if (_res_constr.datalen > 0)
10065                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
10066         else
10067                 _res_constr.data = NULL;
10068         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
10069         for (size_t m = 0; m < _res_constr.datalen; m++) {
10070                 int8_tArray _res_conv_12 = _res_vals[m];
10071                 LDKPublicKey _res_conv_12_ref;
10072                 CHECK(*((uint32_t*)_res_conv_12) == 33);
10073                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
10074                 _res_constr.data[m] = _res_conv_12_ref;
10075         }
10076         CVec_PublicKeyZ_free(_res_constr);
10077 }
10078
10079 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
10080         LDKCVec_u8Z o_ref;
10081         o_ref.datalen = *((uint32_t*)o);
10082         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
10083         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
10084         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
10085         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
10086         return (uint64_t)ret_conv;
10087 }
10088
10089 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
10090         LDKPeerHandleError e_conv;
10091         e_conv.inner = (void*)(e & (~1));
10092         e_conv.is_owned = (e & 1) || (e == 0);
10093         e_conv = PeerHandleError_clone(&e_conv);
10094         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
10095         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
10096         return (uint64_t)ret_conv;
10097 }
10098
10099 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
10100         if ((_res & 1) != 0) return;
10101         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
10102         FREE((void*)_res);
10103         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
10104 }
10105
10106 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
10107         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
10108         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
10109         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
10110         return (uint64_t)ret_conv;
10111 }
10112
10113 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
10114         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
10115         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
10116         return (uint64_t)ret_conv;
10117 }
10118
10119 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
10120         LDKPeerHandleError e_conv;
10121         e_conv.inner = (void*)(e & (~1));
10122         e_conv.is_owned = (e & 1) || (e == 0);
10123         e_conv = PeerHandleError_clone(&e_conv);
10124         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
10125         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
10126         return (uint64_t)ret_conv;
10127 }
10128
10129 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
10130         if ((_res & 1) != 0) return;
10131         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
10132         FREE((void*)_res);
10133         CResult_NonePeerHandleErrorZ_free(_res_conv);
10134 }
10135
10136 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
10137         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
10138         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
10139         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
10140         return (uint64_t)ret_conv;
10141 }
10142
10143 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
10144         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
10145         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
10146         return (uint64_t)ret_conv;
10147 }
10148
10149 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
10150         LDKPeerHandleError e_conv;
10151         e_conv.inner = (void*)(e & (~1));
10152         e_conv.is_owned = (e & 1) || (e == 0);
10153         e_conv = PeerHandleError_clone(&e_conv);
10154         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
10155         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
10156         return (uint64_t)ret_conv;
10157 }
10158
10159 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
10160         if ((_res & 1) != 0) return;
10161         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
10162         FREE((void*)_res);
10163         CResult_boolPeerHandleErrorZ_free(_res_conv);
10164 }
10165
10166 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
10167         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
10168         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
10169         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
10170         return (uint64_t)ret_conv;
10171 }
10172
10173 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_some(uint32_t o) {
10174         LDKAccess o_conv = *(LDKAccess*)(((uint64_t)o) & ~1);
10175         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
10176         *ret_copy = COption_AccessZ_some(o_conv);
10177         uint64_t ret_ref = (uint64_t)ret_copy;
10178         return ret_ref;
10179 }
10180
10181 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_none() {
10182         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
10183         *ret_copy = COption_AccessZ_none();
10184         uint64_t ret_ref = (uint64_t)ret_copy;
10185         return ret_ref;
10186 }
10187
10188 void  __attribute__((visibility("default"))) TS_COption_AccessZ_free(uint32_t _res) {
10189         if ((_res & 1) != 0) return;
10190         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(((uint64_t)_res) & ~1);
10191         FREE((void*)_res);
10192         COption_AccessZ_free(_res_conv);
10193 }
10194
10195 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
10196         LDKDirectionalChannelInfo o_conv;
10197         o_conv.inner = (void*)(o & (~1));
10198         o_conv.is_owned = (o & 1) || (o == 0);
10199         o_conv = DirectionalChannelInfo_clone(&o_conv);
10200         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
10201         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
10202         return (uint64_t)ret_conv;
10203 }
10204
10205 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
10206         LDKDecodeError e_conv;
10207         e_conv.inner = (void*)(e & (~1));
10208         e_conv.is_owned = (e & 1) || (e == 0);
10209         e_conv = DecodeError_clone(&e_conv);
10210         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
10211         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
10212         return (uint64_t)ret_conv;
10213 }
10214
10215 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
10216         if ((_res & 1) != 0) return;
10217         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
10218         FREE((void*)_res);
10219         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
10220 }
10221
10222 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
10223         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
10224         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
10225         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
10226         return (uint64_t)ret_conv;
10227 }
10228
10229 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
10230         LDKChannelInfo o_conv;
10231         o_conv.inner = (void*)(o & (~1));
10232         o_conv.is_owned = (o & 1) || (o == 0);
10233         o_conv = ChannelInfo_clone(&o_conv);
10234         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
10235         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
10236         return (uint64_t)ret_conv;
10237 }
10238
10239 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
10240         LDKDecodeError e_conv;
10241         e_conv.inner = (void*)(e & (~1));
10242         e_conv.is_owned = (e & 1) || (e == 0);
10243         e_conv = DecodeError_clone(&e_conv);
10244         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
10245         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
10246         return (uint64_t)ret_conv;
10247 }
10248
10249 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
10250         if ((_res & 1) != 0) return;
10251         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
10252         FREE((void*)_res);
10253         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
10254 }
10255
10256 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
10257         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
10258         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
10259         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
10260         return (uint64_t)ret_conv;
10261 }
10262
10263 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
10264         LDKRoutingFees o_conv;
10265         o_conv.inner = (void*)(o & (~1));
10266         o_conv.is_owned = (o & 1) || (o == 0);
10267         o_conv = RoutingFees_clone(&o_conv);
10268         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
10269         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
10270         return (uint64_t)ret_conv;
10271 }
10272
10273 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
10274         LDKDecodeError e_conv;
10275         e_conv.inner = (void*)(e & (~1));
10276         e_conv.is_owned = (e & 1) || (e == 0);
10277         e_conv = DecodeError_clone(&e_conv);
10278         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
10279         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
10280         return (uint64_t)ret_conv;
10281 }
10282
10283 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
10284         if ((_res & 1) != 0) return;
10285         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10286         FREE((void*)_res);
10287         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
10288 }
10289
10290 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
10291         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
10292         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
10293         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
10294         return (uint64_t)ret_conv;
10295 }
10296
10297 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
10298         LDKNodeAnnouncementInfo o_conv;
10299         o_conv.inner = (void*)(o & (~1));
10300         o_conv.is_owned = (o & 1) || (o == 0);
10301         o_conv = NodeAnnouncementInfo_clone(&o_conv);
10302         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
10303         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
10304         return (uint64_t)ret_conv;
10305 }
10306
10307 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
10308         LDKDecodeError e_conv;
10309         e_conv.inner = (void*)(e & (~1));
10310         e_conv.is_owned = (e & 1) || (e == 0);
10311         e_conv = DecodeError_clone(&e_conv);
10312         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
10313         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
10314         return (uint64_t)ret_conv;
10315 }
10316
10317 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
10318         if ((_res & 1) != 0) return;
10319         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
10320         FREE((void*)_res);
10321         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
10322 }
10323
10324 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
10325         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
10326         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
10327         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
10328         return (uint64_t)ret_conv;
10329 }
10330
10331 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
10332         LDKCVec_u64Z _res_constr;
10333         _res_constr.datalen = *((uint32_t*)_res);
10334         if (_res_constr.datalen > 0)
10335                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
10336         else
10337                 _res_constr.data = NULL;
10338         int64_t* _res_vals = (int64_t*)(_res + 4);
10339         for (size_t i = 0; i < _res_constr.datalen; i++) {
10340                 int64_t _res_conv_8 = _res_vals[i];
10341                 _res_constr.data[i] = _res_conv_8;
10342         }
10343         CVec_u64Z_free(_res_constr);
10344 }
10345
10346 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
10347         LDKNodeInfo o_conv;
10348         o_conv.inner = (void*)(o & (~1));
10349         o_conv.is_owned = (o & 1) || (o == 0);
10350         o_conv = NodeInfo_clone(&o_conv);
10351         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
10352         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
10353         return (uint64_t)ret_conv;
10354 }
10355
10356 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
10357         LDKDecodeError e_conv;
10358         e_conv.inner = (void*)(e & (~1));
10359         e_conv.is_owned = (e & 1) || (e == 0);
10360         e_conv = DecodeError_clone(&e_conv);
10361         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
10362         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
10363         return (uint64_t)ret_conv;
10364 }
10365
10366 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
10367         if ((_res & 1) != 0) return;
10368         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
10369         FREE((void*)_res);
10370         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
10371 }
10372
10373 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
10374         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
10375         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
10376         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
10377         return (uint64_t)ret_conv;
10378 }
10379
10380 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
10381         LDKNetworkGraph o_conv;
10382         o_conv.inner = (void*)(o & (~1));
10383         o_conv.is_owned = (o & 1) || (o == 0);
10384         // Warning: we need a move here but no clone is available for LDKNetworkGraph
10385         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
10386         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
10387         return (uint64_t)ret_conv;
10388 }
10389
10390 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
10391         LDKDecodeError e_conv;
10392         e_conv.inner = (void*)(e & (~1));
10393         e_conv.is_owned = (e & 1) || (e == 0);
10394         e_conv = DecodeError_clone(&e_conv);
10395         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
10396         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
10397         return (uint64_t)ret_conv;
10398 }
10399
10400 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
10401         if ((_res & 1) != 0) return;
10402         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
10403         FREE((void*)_res);
10404         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
10405 }
10406
10407 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
10408         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
10409         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
10410         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
10411         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
10412         return (uint64_t)ret_conv;
10413 }
10414
10415 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
10416         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
10417         *ret_conv = CResult_NetAddressu8Z_err(e);
10418         return (uint64_t)ret_conv;
10419 }
10420
10421 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
10422         if ((_res & 1) != 0) return;
10423         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
10424         FREE((void*)_res);
10425         CResult_NetAddressu8Z_free(_res_conv);
10426 }
10427
10428 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
10429         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
10430         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
10431         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
10432         return (uint64_t)ret_conv;
10433 }
10434
10435 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
10436         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
10437         o_conv = CResult_NetAddressu8Z_clone((LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1));
10438         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
10439         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
10440         return (uint64_t)ret_conv;
10441 }
10442
10443 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
10444         LDKDecodeError e_conv;
10445         e_conv.inner = (void*)(e & (~1));
10446         e_conv.is_owned = (e & 1) || (e == 0);
10447         e_conv = DecodeError_clone(&e_conv);
10448         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
10449         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
10450         return (uint64_t)ret_conv;
10451 }
10452
10453 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
10454         if ((_res & 1) != 0) return;
10455         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10456         FREE((void*)_res);
10457         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
10458 }
10459
10460 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
10461         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
10462         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
10463         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
10464         return (uint64_t)ret_conv;
10465 }
10466
10467 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
10468         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
10469         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
10470         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
10471         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
10472         return (uint64_t)ret_conv;
10473 }
10474
10475 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
10476         LDKDecodeError e_conv;
10477         e_conv.inner = (void*)(e & (~1));
10478         e_conv.is_owned = (e & 1) || (e == 0);
10479         e_conv = DecodeError_clone(&e_conv);
10480         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
10481         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
10482         return (uint64_t)ret_conv;
10483 }
10484
10485 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
10486         if ((_res & 1) != 0) return;
10487         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
10488         FREE((void*)_res);
10489         CResult_NetAddressDecodeErrorZ_free(_res_conv);
10490 }
10491
10492 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
10493         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
10494         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
10495         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
10496         return (uint64_t)ret_conv;
10497 }
10498
10499 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
10500         LDKCVec_UpdateAddHTLCZ _res_constr;
10501         _res_constr.datalen = *((uint32_t*)_res);
10502         if (_res_constr.datalen > 0)
10503                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
10504         else
10505                 _res_constr.data = NULL;
10506         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10507         for (size_t p = 0; p < _res_constr.datalen; p++) {
10508                 uint32_t _res_conv_15 = _res_vals[p];
10509                 LDKUpdateAddHTLC _res_conv_15_conv;
10510                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
10511                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
10512                 _res_constr.data[p] = _res_conv_15_conv;
10513         }
10514         CVec_UpdateAddHTLCZ_free(_res_constr);
10515 }
10516
10517 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
10518         LDKCVec_UpdateFulfillHTLCZ _res_constr;
10519         _res_constr.datalen = *((uint32_t*)_res);
10520         if (_res_constr.datalen > 0)
10521                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
10522         else
10523                 _res_constr.data = NULL;
10524         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10525         for (size_t t = 0; t < _res_constr.datalen; t++) {
10526                 uint32_t _res_conv_19 = _res_vals[t];
10527                 LDKUpdateFulfillHTLC _res_conv_19_conv;
10528                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
10529                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
10530                 _res_constr.data[t] = _res_conv_19_conv;
10531         }
10532         CVec_UpdateFulfillHTLCZ_free(_res_constr);
10533 }
10534
10535 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
10536         LDKCVec_UpdateFailHTLCZ _res_constr;
10537         _res_constr.datalen = *((uint32_t*)_res);
10538         if (_res_constr.datalen > 0)
10539                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
10540         else
10541                 _res_constr.data = NULL;
10542         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10543         for (size_t q = 0; q < _res_constr.datalen; q++) {
10544                 uint32_t _res_conv_16 = _res_vals[q];
10545                 LDKUpdateFailHTLC _res_conv_16_conv;
10546                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10547                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10548                 _res_constr.data[q] = _res_conv_16_conv;
10549         }
10550         CVec_UpdateFailHTLCZ_free(_res_constr);
10551 }
10552
10553 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
10554         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
10555         _res_constr.datalen = *((uint32_t*)_res);
10556         if (_res_constr.datalen > 0)
10557                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
10558         else
10559                 _res_constr.data = NULL;
10560         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10561         for (size_t z = 0; z < _res_constr.datalen; z++) {
10562                 uint32_t _res_conv_25 = _res_vals[z];
10563                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
10564                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
10565                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
10566                 _res_constr.data[z] = _res_conv_25_conv;
10567         }
10568         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
10569 }
10570
10571 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
10572         LDKAcceptChannel o_conv;
10573         o_conv.inner = (void*)(o & (~1));
10574         o_conv.is_owned = (o & 1) || (o == 0);
10575         o_conv = AcceptChannel_clone(&o_conv);
10576         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
10577         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
10578         return (uint64_t)ret_conv;
10579 }
10580
10581 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
10582         LDKDecodeError e_conv;
10583         e_conv.inner = (void*)(e & (~1));
10584         e_conv.is_owned = (e & 1) || (e == 0);
10585         e_conv = DecodeError_clone(&e_conv);
10586         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
10587         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
10588         return (uint64_t)ret_conv;
10589 }
10590
10591 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
10592         if ((_res & 1) != 0) return;
10593         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
10594         FREE((void*)_res);
10595         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
10596 }
10597
10598 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
10599         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
10600         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
10601         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
10602         return (uint64_t)ret_conv;
10603 }
10604
10605 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
10606         LDKAnnouncementSignatures o_conv;
10607         o_conv.inner = (void*)(o & (~1));
10608         o_conv.is_owned = (o & 1) || (o == 0);
10609         o_conv = AnnouncementSignatures_clone(&o_conv);
10610         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
10611         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
10612         return (uint64_t)ret_conv;
10613 }
10614
10615 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
10616         LDKDecodeError e_conv;
10617         e_conv.inner = (void*)(e & (~1));
10618         e_conv.is_owned = (e & 1) || (e == 0);
10619         e_conv = DecodeError_clone(&e_conv);
10620         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
10621         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
10622         return (uint64_t)ret_conv;
10623 }
10624
10625 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
10626         if ((_res & 1) != 0) return;
10627         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10628         FREE((void*)_res);
10629         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
10630 }
10631
10632 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
10633         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
10634         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
10635         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
10636         return (uint64_t)ret_conv;
10637 }
10638
10639 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
10640         LDKChannelReestablish o_conv;
10641         o_conv.inner = (void*)(o & (~1));
10642         o_conv.is_owned = (o & 1) || (o == 0);
10643         o_conv = ChannelReestablish_clone(&o_conv);
10644         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
10645         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
10646         return (uint64_t)ret_conv;
10647 }
10648
10649 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
10650         LDKDecodeError e_conv;
10651         e_conv.inner = (void*)(e & (~1));
10652         e_conv.is_owned = (e & 1) || (e == 0);
10653         e_conv = DecodeError_clone(&e_conv);
10654         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
10655         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
10656         return (uint64_t)ret_conv;
10657 }
10658
10659 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
10660         if ((_res & 1) != 0) return;
10661         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
10662         FREE((void*)_res);
10663         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
10664 }
10665
10666 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
10667         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
10668         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
10669         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
10670         return (uint64_t)ret_conv;
10671 }
10672
10673 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
10674         LDKClosingSigned o_conv;
10675         o_conv.inner = (void*)(o & (~1));
10676         o_conv.is_owned = (o & 1) || (o == 0);
10677         o_conv = ClosingSigned_clone(&o_conv);
10678         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
10679         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
10680         return (uint64_t)ret_conv;
10681 }
10682
10683 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
10684         LDKDecodeError e_conv;
10685         e_conv.inner = (void*)(e & (~1));
10686         e_conv.is_owned = (e & 1) || (e == 0);
10687         e_conv = DecodeError_clone(&e_conv);
10688         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
10689         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
10690         return (uint64_t)ret_conv;
10691 }
10692
10693 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
10694         if ((_res & 1) != 0) return;
10695         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
10696         FREE((void*)_res);
10697         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
10698 }
10699
10700 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
10701         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
10702         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
10703         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
10704         return (uint64_t)ret_conv;
10705 }
10706
10707 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
10708         LDKClosingSignedFeeRange o_conv;
10709         o_conv.inner = (void*)(o & (~1));
10710         o_conv.is_owned = (o & 1) || (o == 0);
10711         o_conv = ClosingSignedFeeRange_clone(&o_conv);
10712         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
10713         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
10714         return (uint64_t)ret_conv;
10715 }
10716
10717 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
10718         LDKDecodeError e_conv;
10719         e_conv.inner = (void*)(e & (~1));
10720         e_conv.is_owned = (e & 1) || (e == 0);
10721         e_conv = DecodeError_clone(&e_conv);
10722         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
10723         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
10724         return (uint64_t)ret_conv;
10725 }
10726
10727 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
10728         if ((_res & 1) != 0) return;
10729         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10730         FREE((void*)_res);
10731         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
10732 }
10733
10734 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
10735         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
10736         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
10737         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
10738         return (uint64_t)ret_conv;
10739 }
10740
10741 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
10742         LDKCommitmentSigned o_conv;
10743         o_conv.inner = (void*)(o & (~1));
10744         o_conv.is_owned = (o & 1) || (o == 0);
10745         o_conv = CommitmentSigned_clone(&o_conv);
10746         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
10747         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
10748         return (uint64_t)ret_conv;
10749 }
10750
10751 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
10752         LDKDecodeError e_conv;
10753         e_conv.inner = (void*)(e & (~1));
10754         e_conv.is_owned = (e & 1) || (e == 0);
10755         e_conv = DecodeError_clone(&e_conv);
10756         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
10757         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
10758         return (uint64_t)ret_conv;
10759 }
10760
10761 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
10762         if ((_res & 1) != 0) return;
10763         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
10764         FREE((void*)_res);
10765         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
10766 }
10767
10768 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
10769         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
10770         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
10771         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
10772         return (uint64_t)ret_conv;
10773 }
10774
10775 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
10776         LDKFundingCreated o_conv;
10777         o_conv.inner = (void*)(o & (~1));
10778         o_conv.is_owned = (o & 1) || (o == 0);
10779         o_conv = FundingCreated_clone(&o_conv);
10780         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
10781         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
10782         return (uint64_t)ret_conv;
10783 }
10784
10785 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
10786         LDKDecodeError e_conv;
10787         e_conv.inner = (void*)(e & (~1));
10788         e_conv.is_owned = (e & 1) || (e == 0);
10789         e_conv = DecodeError_clone(&e_conv);
10790         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
10791         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
10792         return (uint64_t)ret_conv;
10793 }
10794
10795 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
10796         if ((_res & 1) != 0) return;
10797         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
10798         FREE((void*)_res);
10799         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
10800 }
10801
10802 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
10803         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
10804         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
10805         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
10806         return (uint64_t)ret_conv;
10807 }
10808
10809 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
10810         LDKFundingSigned o_conv;
10811         o_conv.inner = (void*)(o & (~1));
10812         o_conv.is_owned = (o & 1) || (o == 0);
10813         o_conv = FundingSigned_clone(&o_conv);
10814         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
10815         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
10816         return (uint64_t)ret_conv;
10817 }
10818
10819 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
10820         LDKDecodeError e_conv;
10821         e_conv.inner = (void*)(e & (~1));
10822         e_conv.is_owned = (e & 1) || (e == 0);
10823         e_conv = DecodeError_clone(&e_conv);
10824         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
10825         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
10826         return (uint64_t)ret_conv;
10827 }
10828
10829 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
10830         if ((_res & 1) != 0) return;
10831         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
10832         FREE((void*)_res);
10833         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
10834 }
10835
10836 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
10837         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
10838         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
10839         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
10840         return (uint64_t)ret_conv;
10841 }
10842
10843 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
10844         LDKFundingLocked o_conv;
10845         o_conv.inner = (void*)(o & (~1));
10846         o_conv.is_owned = (o & 1) || (o == 0);
10847         o_conv = FundingLocked_clone(&o_conv);
10848         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
10849         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
10850         return (uint64_t)ret_conv;
10851 }
10852
10853 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
10854         LDKDecodeError e_conv;
10855         e_conv.inner = (void*)(e & (~1));
10856         e_conv.is_owned = (e & 1) || (e == 0);
10857         e_conv = DecodeError_clone(&e_conv);
10858         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
10859         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
10860         return (uint64_t)ret_conv;
10861 }
10862
10863 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
10864         if ((_res & 1) != 0) return;
10865         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
10866         FREE((void*)_res);
10867         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
10868 }
10869
10870 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
10871         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
10872         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
10873         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
10874         return (uint64_t)ret_conv;
10875 }
10876
10877 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
10878         LDKInit o_conv;
10879         o_conv.inner = (void*)(o & (~1));
10880         o_conv.is_owned = (o & 1) || (o == 0);
10881         o_conv = Init_clone(&o_conv);
10882         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
10883         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
10884         return (uint64_t)ret_conv;
10885 }
10886
10887 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
10888         LDKDecodeError e_conv;
10889         e_conv.inner = (void*)(e & (~1));
10890         e_conv.is_owned = (e & 1) || (e == 0);
10891         e_conv = DecodeError_clone(&e_conv);
10892         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
10893         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
10894         return (uint64_t)ret_conv;
10895 }
10896
10897 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
10898         if ((_res & 1) != 0) return;
10899         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
10900         FREE((void*)_res);
10901         CResult_InitDecodeErrorZ_free(_res_conv);
10902 }
10903
10904 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
10905         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
10906         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
10907         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
10908         return (uint64_t)ret_conv;
10909 }
10910
10911 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
10912         LDKOpenChannel o_conv;
10913         o_conv.inner = (void*)(o & (~1));
10914         o_conv.is_owned = (o & 1) || (o == 0);
10915         o_conv = OpenChannel_clone(&o_conv);
10916         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
10917         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
10918         return (uint64_t)ret_conv;
10919 }
10920
10921 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
10922         LDKDecodeError e_conv;
10923         e_conv.inner = (void*)(e & (~1));
10924         e_conv.is_owned = (e & 1) || (e == 0);
10925         e_conv = DecodeError_clone(&e_conv);
10926         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
10927         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
10928         return (uint64_t)ret_conv;
10929 }
10930
10931 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
10932         if ((_res & 1) != 0) return;
10933         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
10934         FREE((void*)_res);
10935         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
10936 }
10937
10938 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
10939         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
10940         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
10941         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
10942         return (uint64_t)ret_conv;
10943 }
10944
10945 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
10946         LDKRevokeAndACK o_conv;
10947         o_conv.inner = (void*)(o & (~1));
10948         o_conv.is_owned = (o & 1) || (o == 0);
10949         o_conv = RevokeAndACK_clone(&o_conv);
10950         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
10951         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
10952         return (uint64_t)ret_conv;
10953 }
10954
10955 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
10956         LDKDecodeError e_conv;
10957         e_conv.inner = (void*)(e & (~1));
10958         e_conv.is_owned = (e & 1) || (e == 0);
10959         e_conv = DecodeError_clone(&e_conv);
10960         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
10961         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
10962         return (uint64_t)ret_conv;
10963 }
10964
10965 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
10966         if ((_res & 1) != 0) return;
10967         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
10968         FREE((void*)_res);
10969         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
10970 }
10971
10972 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
10973         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
10974         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
10975         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
10976         return (uint64_t)ret_conv;
10977 }
10978
10979 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
10980         LDKShutdown o_conv;
10981         o_conv.inner = (void*)(o & (~1));
10982         o_conv.is_owned = (o & 1) || (o == 0);
10983         o_conv = Shutdown_clone(&o_conv);
10984         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
10985         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
10986         return (uint64_t)ret_conv;
10987 }
10988
10989 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
10990         LDKDecodeError e_conv;
10991         e_conv.inner = (void*)(e & (~1));
10992         e_conv.is_owned = (e & 1) || (e == 0);
10993         e_conv = DecodeError_clone(&e_conv);
10994         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
10995         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
10996         return (uint64_t)ret_conv;
10997 }
10998
10999 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
11000         if ((_res & 1) != 0) return;
11001         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
11002         FREE((void*)_res);
11003         CResult_ShutdownDecodeErrorZ_free(_res_conv);
11004 }
11005
11006 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
11007         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
11008         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
11009         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
11010         return (uint64_t)ret_conv;
11011 }
11012
11013 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
11014         LDKUpdateFailHTLC o_conv;
11015         o_conv.inner = (void*)(o & (~1));
11016         o_conv.is_owned = (o & 1) || (o == 0);
11017         o_conv = UpdateFailHTLC_clone(&o_conv);
11018         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
11019         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
11020         return (uint64_t)ret_conv;
11021 }
11022
11023 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
11024         LDKDecodeError e_conv;
11025         e_conv.inner = (void*)(e & (~1));
11026         e_conv.is_owned = (e & 1) || (e == 0);
11027         e_conv = DecodeError_clone(&e_conv);
11028         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
11029         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
11030         return (uint64_t)ret_conv;
11031 }
11032
11033 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
11034         if ((_res & 1) != 0) return;
11035         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
11036         FREE((void*)_res);
11037         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
11038 }
11039
11040 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
11041         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
11042         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
11043         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
11044         return (uint64_t)ret_conv;
11045 }
11046
11047 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
11048         LDKUpdateFailMalformedHTLC o_conv;
11049         o_conv.inner = (void*)(o & (~1));
11050         o_conv.is_owned = (o & 1) || (o == 0);
11051         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
11052         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
11053         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
11054         return (uint64_t)ret_conv;
11055 }
11056
11057 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
11058         LDKDecodeError e_conv;
11059         e_conv.inner = (void*)(e & (~1));
11060         e_conv.is_owned = (e & 1) || (e == 0);
11061         e_conv = DecodeError_clone(&e_conv);
11062         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
11063         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
11064         return (uint64_t)ret_conv;
11065 }
11066
11067 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
11068         if ((_res & 1) != 0) return;
11069         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
11070         FREE((void*)_res);
11071         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
11072 }
11073
11074 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
11075         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
11076         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
11077         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
11078         return (uint64_t)ret_conv;
11079 }
11080
11081 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
11082         LDKUpdateFee o_conv;
11083         o_conv.inner = (void*)(o & (~1));
11084         o_conv.is_owned = (o & 1) || (o == 0);
11085         o_conv = UpdateFee_clone(&o_conv);
11086         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
11087         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
11088         return (uint64_t)ret_conv;
11089 }
11090
11091 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
11092         LDKDecodeError e_conv;
11093         e_conv.inner = (void*)(e & (~1));
11094         e_conv.is_owned = (e & 1) || (e == 0);
11095         e_conv = DecodeError_clone(&e_conv);
11096         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
11097         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
11098         return (uint64_t)ret_conv;
11099 }
11100
11101 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
11102         if ((_res & 1) != 0) return;
11103         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
11104         FREE((void*)_res);
11105         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
11106 }
11107
11108 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
11109         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
11110         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
11111         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
11112         return (uint64_t)ret_conv;
11113 }
11114
11115 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
11116         LDKUpdateFulfillHTLC o_conv;
11117         o_conv.inner = (void*)(o & (~1));
11118         o_conv.is_owned = (o & 1) || (o == 0);
11119         o_conv = UpdateFulfillHTLC_clone(&o_conv);
11120         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
11121         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
11122         return (uint64_t)ret_conv;
11123 }
11124
11125 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
11126         LDKDecodeError e_conv;
11127         e_conv.inner = (void*)(e & (~1));
11128         e_conv.is_owned = (e & 1) || (e == 0);
11129         e_conv = DecodeError_clone(&e_conv);
11130         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
11131         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
11132         return (uint64_t)ret_conv;
11133 }
11134
11135 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
11136         if ((_res & 1) != 0) return;
11137         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
11138         FREE((void*)_res);
11139         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
11140 }
11141
11142 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
11143         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
11144         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
11145         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
11146         return (uint64_t)ret_conv;
11147 }
11148
11149 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
11150         LDKUpdateAddHTLC o_conv;
11151         o_conv.inner = (void*)(o & (~1));
11152         o_conv.is_owned = (o & 1) || (o == 0);
11153         o_conv = UpdateAddHTLC_clone(&o_conv);
11154         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
11155         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
11156         return (uint64_t)ret_conv;
11157 }
11158
11159 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
11160         LDKDecodeError e_conv;
11161         e_conv.inner = (void*)(e & (~1));
11162         e_conv.is_owned = (e & 1) || (e == 0);
11163         e_conv = DecodeError_clone(&e_conv);
11164         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
11165         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
11166         return (uint64_t)ret_conv;
11167 }
11168
11169 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
11170         if ((_res & 1) != 0) return;
11171         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
11172         FREE((void*)_res);
11173         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
11174 }
11175
11176 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
11177         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
11178         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
11179         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
11180         return (uint64_t)ret_conv;
11181 }
11182
11183 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
11184         LDKPing o_conv;
11185         o_conv.inner = (void*)(o & (~1));
11186         o_conv.is_owned = (o & 1) || (o == 0);
11187         o_conv = Ping_clone(&o_conv);
11188         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
11189         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
11190         return (uint64_t)ret_conv;
11191 }
11192
11193 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
11194         LDKDecodeError e_conv;
11195         e_conv.inner = (void*)(e & (~1));
11196         e_conv.is_owned = (e & 1) || (e == 0);
11197         e_conv = DecodeError_clone(&e_conv);
11198         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
11199         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
11200         return (uint64_t)ret_conv;
11201 }
11202
11203 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
11204         if ((_res & 1) != 0) return;
11205         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
11206         FREE((void*)_res);
11207         CResult_PingDecodeErrorZ_free(_res_conv);
11208 }
11209
11210 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
11211         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
11212         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
11213         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
11214         return (uint64_t)ret_conv;
11215 }
11216
11217 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
11218         LDKPong o_conv;
11219         o_conv.inner = (void*)(o & (~1));
11220         o_conv.is_owned = (o & 1) || (o == 0);
11221         o_conv = Pong_clone(&o_conv);
11222         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
11223         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
11224         return (uint64_t)ret_conv;
11225 }
11226
11227 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
11228         LDKDecodeError e_conv;
11229         e_conv.inner = (void*)(e & (~1));
11230         e_conv.is_owned = (e & 1) || (e == 0);
11231         e_conv = DecodeError_clone(&e_conv);
11232         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
11233         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
11234         return (uint64_t)ret_conv;
11235 }
11236
11237 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
11238         if ((_res & 1) != 0) return;
11239         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
11240         FREE((void*)_res);
11241         CResult_PongDecodeErrorZ_free(_res_conv);
11242 }
11243
11244 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
11245         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
11246         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
11247         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
11248         return (uint64_t)ret_conv;
11249 }
11250
11251 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
11252         LDKUnsignedChannelAnnouncement o_conv;
11253         o_conv.inner = (void*)(o & (~1));
11254         o_conv.is_owned = (o & 1) || (o == 0);
11255         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
11256         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
11257         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
11258         return (uint64_t)ret_conv;
11259 }
11260
11261 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
11262         LDKDecodeError e_conv;
11263         e_conv.inner = (void*)(e & (~1));
11264         e_conv.is_owned = (e & 1) || (e == 0);
11265         e_conv = DecodeError_clone(&e_conv);
11266         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
11267         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
11268         return (uint64_t)ret_conv;
11269 }
11270
11271 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
11272         if ((_res & 1) != 0) return;
11273         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
11274         FREE((void*)_res);
11275         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
11276 }
11277
11278 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
11279         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
11280         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
11281         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
11282         return (uint64_t)ret_conv;
11283 }
11284
11285 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
11286         LDKChannelAnnouncement o_conv;
11287         o_conv.inner = (void*)(o & (~1));
11288         o_conv.is_owned = (o & 1) || (o == 0);
11289         o_conv = ChannelAnnouncement_clone(&o_conv);
11290         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
11291         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
11292         return (uint64_t)ret_conv;
11293 }
11294
11295 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
11296         LDKDecodeError e_conv;
11297         e_conv.inner = (void*)(e & (~1));
11298         e_conv.is_owned = (e & 1) || (e == 0);
11299         e_conv = DecodeError_clone(&e_conv);
11300         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
11301         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
11302         return (uint64_t)ret_conv;
11303 }
11304
11305 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
11306         if ((_res & 1) != 0) return;
11307         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
11308         FREE((void*)_res);
11309         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
11310 }
11311
11312 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
11313         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
11314         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
11315         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
11316         return (uint64_t)ret_conv;
11317 }
11318
11319 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
11320         LDKUnsignedChannelUpdate o_conv;
11321         o_conv.inner = (void*)(o & (~1));
11322         o_conv.is_owned = (o & 1) || (o == 0);
11323         o_conv = UnsignedChannelUpdate_clone(&o_conv);
11324         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
11325         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
11326         return (uint64_t)ret_conv;
11327 }
11328
11329 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
11330         LDKDecodeError e_conv;
11331         e_conv.inner = (void*)(e & (~1));
11332         e_conv.is_owned = (e & 1) || (e == 0);
11333         e_conv = DecodeError_clone(&e_conv);
11334         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
11335         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
11336         return (uint64_t)ret_conv;
11337 }
11338
11339 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
11340         if ((_res & 1) != 0) return;
11341         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11342         FREE((void*)_res);
11343         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
11344 }
11345
11346 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
11347         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
11348         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
11349         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
11350         return (uint64_t)ret_conv;
11351 }
11352
11353 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
11354         LDKChannelUpdate o_conv;
11355         o_conv.inner = (void*)(o & (~1));
11356         o_conv.is_owned = (o & 1) || (o == 0);
11357         o_conv = ChannelUpdate_clone(&o_conv);
11358         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
11359         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
11360         return (uint64_t)ret_conv;
11361 }
11362
11363 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
11364         LDKDecodeError e_conv;
11365         e_conv.inner = (void*)(e & (~1));
11366         e_conv.is_owned = (e & 1) || (e == 0);
11367         e_conv = DecodeError_clone(&e_conv);
11368         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
11369         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
11370         return (uint64_t)ret_conv;
11371 }
11372
11373 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
11374         if ((_res & 1) != 0) return;
11375         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11376         FREE((void*)_res);
11377         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
11378 }
11379
11380 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
11381         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
11382         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
11383         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
11384         return (uint64_t)ret_conv;
11385 }
11386
11387 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
11388         LDKErrorMessage o_conv;
11389         o_conv.inner = (void*)(o & (~1));
11390         o_conv.is_owned = (o & 1) || (o == 0);
11391         o_conv = ErrorMessage_clone(&o_conv);
11392         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
11393         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
11394         return (uint64_t)ret_conv;
11395 }
11396
11397 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
11398         LDKDecodeError e_conv;
11399         e_conv.inner = (void*)(e & (~1));
11400         e_conv.is_owned = (e & 1) || (e == 0);
11401         e_conv = DecodeError_clone(&e_conv);
11402         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
11403         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
11404         return (uint64_t)ret_conv;
11405 }
11406
11407 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
11408         if ((_res & 1) != 0) return;
11409         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
11410         FREE((void*)_res);
11411         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
11412 }
11413
11414 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
11415         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
11416         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
11417         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
11418         return (uint64_t)ret_conv;
11419 }
11420
11421 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
11422         LDKUnsignedNodeAnnouncement o_conv;
11423         o_conv.inner = (void*)(o & (~1));
11424         o_conv.is_owned = (o & 1) || (o == 0);
11425         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
11426         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
11427         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
11428         return (uint64_t)ret_conv;
11429 }
11430
11431 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
11432         LDKDecodeError e_conv;
11433         e_conv.inner = (void*)(e & (~1));
11434         e_conv.is_owned = (e & 1) || (e == 0);
11435         e_conv = DecodeError_clone(&e_conv);
11436         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
11437         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
11438         return (uint64_t)ret_conv;
11439 }
11440
11441 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
11442         if ((_res & 1) != 0) return;
11443         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
11444         FREE((void*)_res);
11445         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
11446 }
11447
11448 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
11449         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
11450         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
11451         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
11452         return (uint64_t)ret_conv;
11453 }
11454
11455 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
11456         LDKNodeAnnouncement o_conv;
11457         o_conv.inner = (void*)(o & (~1));
11458         o_conv.is_owned = (o & 1) || (o == 0);
11459         o_conv = NodeAnnouncement_clone(&o_conv);
11460         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
11461         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
11462         return (uint64_t)ret_conv;
11463 }
11464
11465 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
11466         LDKDecodeError e_conv;
11467         e_conv.inner = (void*)(e & (~1));
11468         e_conv.is_owned = (e & 1) || (e == 0);
11469         e_conv = DecodeError_clone(&e_conv);
11470         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
11471         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
11472         return (uint64_t)ret_conv;
11473 }
11474
11475 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
11476         if ((_res & 1) != 0) return;
11477         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
11478         FREE((void*)_res);
11479         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
11480 }
11481
11482 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
11483         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
11484         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
11485         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
11486         return (uint64_t)ret_conv;
11487 }
11488
11489 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
11490         LDKQueryShortChannelIds o_conv;
11491         o_conv.inner = (void*)(o & (~1));
11492         o_conv.is_owned = (o & 1) || (o == 0);
11493         o_conv = QueryShortChannelIds_clone(&o_conv);
11494         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
11495         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
11496         return (uint64_t)ret_conv;
11497 }
11498
11499 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
11500         LDKDecodeError e_conv;
11501         e_conv.inner = (void*)(e & (~1));
11502         e_conv.is_owned = (e & 1) || (e == 0);
11503         e_conv = DecodeError_clone(&e_conv);
11504         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
11505         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
11506         return (uint64_t)ret_conv;
11507 }
11508
11509 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
11510         if ((_res & 1) != 0) return;
11511         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
11512         FREE((void*)_res);
11513         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
11514 }
11515
11516 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
11517         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
11518         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
11519         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
11520         return (uint64_t)ret_conv;
11521 }
11522
11523 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
11524         LDKReplyShortChannelIdsEnd o_conv;
11525         o_conv.inner = (void*)(o & (~1));
11526         o_conv.is_owned = (o & 1) || (o == 0);
11527         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
11528         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
11529         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
11530         return (uint64_t)ret_conv;
11531 }
11532
11533 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
11534         LDKDecodeError e_conv;
11535         e_conv.inner = (void*)(e & (~1));
11536         e_conv.is_owned = (e & 1) || (e == 0);
11537         e_conv = DecodeError_clone(&e_conv);
11538         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
11539         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
11540         return (uint64_t)ret_conv;
11541 }
11542
11543 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
11544         if ((_res & 1) != 0) return;
11545         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
11546         FREE((void*)_res);
11547         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
11548 }
11549
11550 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
11551         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
11552         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
11553         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
11554         return (uint64_t)ret_conv;
11555 }
11556
11557 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
11558         LDKQueryChannelRange o_conv;
11559         o_conv.inner = (void*)(o & (~1));
11560         o_conv.is_owned = (o & 1) || (o == 0);
11561         o_conv = QueryChannelRange_clone(&o_conv);
11562         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
11563         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
11564         return (uint64_t)ret_conv;
11565 }
11566
11567 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
11568         LDKDecodeError e_conv;
11569         e_conv.inner = (void*)(e & (~1));
11570         e_conv.is_owned = (e & 1) || (e == 0);
11571         e_conv = DecodeError_clone(&e_conv);
11572         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
11573         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
11574         return (uint64_t)ret_conv;
11575 }
11576
11577 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
11578         if ((_res & 1) != 0) return;
11579         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
11580         FREE((void*)_res);
11581         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
11582 }
11583
11584 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
11585         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
11586         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
11587         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
11588         return (uint64_t)ret_conv;
11589 }
11590
11591 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
11592         LDKReplyChannelRange o_conv;
11593         o_conv.inner = (void*)(o & (~1));
11594         o_conv.is_owned = (o & 1) || (o == 0);
11595         o_conv = ReplyChannelRange_clone(&o_conv);
11596         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
11597         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
11598         return (uint64_t)ret_conv;
11599 }
11600
11601 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
11602         LDKDecodeError e_conv;
11603         e_conv.inner = (void*)(e & (~1));
11604         e_conv.is_owned = (e & 1) || (e == 0);
11605         e_conv = DecodeError_clone(&e_conv);
11606         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
11607         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
11608         return (uint64_t)ret_conv;
11609 }
11610
11611 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
11612         if ((_res & 1) != 0) return;
11613         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
11614         FREE((void*)_res);
11615         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
11616 }
11617
11618 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
11619         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
11620         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
11621         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
11622         return (uint64_t)ret_conv;
11623 }
11624
11625 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
11626         LDKGossipTimestampFilter o_conv;
11627         o_conv.inner = (void*)(o & (~1));
11628         o_conv.is_owned = (o & 1) || (o == 0);
11629         o_conv = GossipTimestampFilter_clone(&o_conv);
11630         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
11631         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
11632         return (uint64_t)ret_conv;
11633 }
11634
11635 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
11636         LDKDecodeError e_conv;
11637         e_conv.inner = (void*)(e & (~1));
11638         e_conv.is_owned = (e & 1) || (e == 0);
11639         e_conv = DecodeError_clone(&e_conv);
11640         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
11641         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
11642         return (uint64_t)ret_conv;
11643 }
11644
11645 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
11646         if ((_res & 1) != 0) return;
11647         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
11648         FREE((void*)_res);
11649         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
11650 }
11651
11652 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
11653         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
11654         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
11655         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
11656         return (uint64_t)ret_conv;
11657 }
11658
11659 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
11660         LDKInvoice o_conv;
11661         o_conv.inner = (void*)(o & (~1));
11662         o_conv.is_owned = (o & 1) || (o == 0);
11663         o_conv = Invoice_clone(&o_conv);
11664         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
11665         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
11666         return (uint64_t)ret_conv;
11667 }
11668
11669 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
11670         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
11671         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
11672         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
11673         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
11674         return (uint64_t)ret_conv;
11675 }
11676
11677 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
11678         if ((_res & 1) != 0) return;
11679         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
11680         FREE((void*)_res);
11681         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
11682 }
11683
11684 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
11685         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
11686         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
11687         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
11688         return (uint64_t)ret_conv;
11689 }
11690
11691 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_some(uint32_t o) {
11692         LDKFilter o_conv = *(LDKFilter*)(((uint64_t)o) & ~1);
11693         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
11694         *ret_copy = COption_FilterZ_some(o_conv);
11695         uint64_t ret_ref = (uint64_t)ret_copy;
11696         return ret_ref;
11697 }
11698
11699 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_none() {
11700         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
11701         *ret_copy = COption_FilterZ_none();
11702         uint64_t ret_ref = (uint64_t)ret_copy;
11703         return ret_ref;
11704 }
11705
11706 void  __attribute__((visibility("default"))) TS_COption_FilterZ_free(uint32_t _res) {
11707         if ((_res & 1) != 0) return;
11708         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(((uint64_t)_res) & ~1);
11709         FREE((void*)_res);
11710         COption_FilterZ_free(_res_conv);
11711 }
11712
11713 void  __attribute__((visibility("default"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
11714         if ((this_ptr & 1) != 0) return;
11715         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1);
11716         FREE((void*)this_ptr);
11717         PaymentPurpose_free(this_ptr_conv);
11718 }
11719
11720 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_clone(uint32_t orig) {
11721         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
11722         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
11723         *ret_copy = PaymentPurpose_clone(orig_conv);
11724         uint64_t ret_ref = (uint64_t)ret_copy;
11725         return ret_ref;
11726 }
11727
11728 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret, int64_t user_payment_id) {
11729         LDKThirtyTwoBytes payment_preimage_ref;
11730         CHECK(*((uint32_t*)payment_preimage) == 32);
11731         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
11732         LDKThirtyTwoBytes payment_secret_ref;
11733         CHECK(*((uint32_t*)payment_secret) == 32);
11734         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11735         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
11736         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
11737         uint64_t ret_ref = (uint64_t)ret_copy;
11738         return ret_ref;
11739 }
11740
11741 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
11742         LDKThirtyTwoBytes a_ref;
11743         CHECK(*((uint32_t*)a) == 32);
11744         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
11745         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
11746         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
11747         uint64_t ret_ref = (uint64_t)ret_copy;
11748         return ret_ref;
11749 }
11750
11751 void  __attribute__((visibility("default"))) TS_ClosureReason_free(uint32_t this_ptr) {
11752         if ((this_ptr & 1) != 0) return;
11753         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(((uint64_t)this_ptr) & ~1);
11754         FREE((void*)this_ptr);
11755         ClosureReason_free(this_ptr_conv);
11756 }
11757
11758 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_clone(uint32_t orig) {
11759         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
11760         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11761         *ret_copy = ClosureReason_clone(orig_conv);
11762         uint64_t ret_ref = (uint64_t)ret_copy;
11763         return ret_ref;
11764 }
11765
11766 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
11767         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
11768         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11769         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
11770         uint64_t ret_ref = (uint64_t)ret_copy;
11771         return ret_ref;
11772 }
11773
11774 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_holder_force_closed() {
11775         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11776         *ret_copy = ClosureReason_holder_force_closed();
11777         uint64_t ret_ref = (uint64_t)ret_copy;
11778         return ret_ref;
11779 }
11780
11781 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_cooperative_closure() {
11782         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11783         *ret_copy = ClosureReason_cooperative_closure();
11784         uint64_t ret_ref = (uint64_t)ret_copy;
11785         return ret_ref;
11786 }
11787
11788 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_commitment_tx_confirmed() {
11789         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11790         *ret_copy = ClosureReason_commitment_tx_confirmed();
11791         uint64_t ret_ref = (uint64_t)ret_copy;
11792         return ret_ref;
11793 }
11794
11795 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_processing_error(jstring err) {
11796         LDKStr err_conv = str_ref_to_owned_c(err);
11797         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11798         *ret_copy = ClosureReason_processing_error(err_conv);
11799         uint64_t ret_ref = (uint64_t)ret_copy;
11800         return ret_ref;
11801 }
11802
11803 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_disconnected_peer() {
11804         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11805         *ret_copy = ClosureReason_disconnected_peer();
11806         uint64_t ret_ref = (uint64_t)ret_copy;
11807         return ret_ref;
11808 }
11809
11810 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_outdated_channel_manager() {
11811         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11812         *ret_copy = ClosureReason_outdated_channel_manager();
11813         uint64_t ret_ref = (uint64_t)ret_copy;
11814         return ret_ref;
11815 }
11816
11817 int8_tArray  __attribute__((visibility("default"))) TS_ClosureReason_write(uint32_t obj) {
11818         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
11819         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
11820         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11821         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11822         CVec_u8Z_free(ret_var);
11823         return ret_arr;
11824 }
11825
11826 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
11827         if ((this_ptr & 1) != 0) return;
11828         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
11829         FREE((void*)this_ptr);
11830         Event_free(this_ptr_conv);
11831 }
11832
11833 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
11834         LDKEvent* orig_conv = (LDKEvent*)orig;
11835         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11836         *ret_copy = Event_clone(orig_conv);
11837         uint64_t ret_ref = (uint64_t)ret_copy;
11838         return ret_ref;
11839 }
11840
11841 uint32_t  __attribute__((visibility("default"))) TS_Event_funding_generation_ready(int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
11842         LDKThirtyTwoBytes temporary_channel_id_ref;
11843         CHECK(*((uint32_t*)temporary_channel_id) == 32);
11844         memcpy(temporary_channel_id_ref.data, (uint8_t*)(temporary_channel_id + 4), 32);
11845         LDKCVec_u8Z output_script_ref;
11846         output_script_ref.datalen = *((uint32_t*)output_script);
11847         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
11848         memcpy(output_script_ref.data, (uint8_t*)(output_script + 4), output_script_ref.datalen);
11849         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11850         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
11851         uint64_t ret_ref = (uint64_t)ret_copy;
11852         return ret_ref;
11853 }
11854
11855 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
11856         LDKThirtyTwoBytes payment_hash_ref;
11857         CHECK(*((uint32_t*)payment_hash) == 32);
11858         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
11859         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1);
11860         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
11861         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11862         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
11863         uint64_t ret_ref = (uint64_t)ret_copy;
11864         return ret_ref;
11865 }
11866
11867 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArray payment_preimage) {
11868         LDKThirtyTwoBytes payment_preimage_ref;
11869         CHECK(*((uint32_t*)payment_preimage) == 32);
11870         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
11871         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11872         *ret_copy = Event_payment_sent(payment_preimage_ref);
11873         uint64_t ret_ref = (uint64_t)ret_copy;
11874         return ret_ref;
11875 }
11876
11877 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_path_failed(int8_tArray payment_hash, jboolean rejected_by_dest, uint32_t network_update, jboolean all_paths_failed, uint32_tArray path) {
11878         LDKThirtyTwoBytes payment_hash_ref;
11879         CHECK(*((uint32_t*)payment_hash) == 32);
11880         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
11881         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1);
11882         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
11883         LDKCVec_RouteHopZ path_constr;
11884         path_constr.datalen = *((uint32_t*)path);
11885         if (path_constr.datalen > 0)
11886                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11887         else
11888                 path_constr.data = NULL;
11889         uint32_t* path_vals = (uint32_t*)(path + 4);
11890         for (size_t k = 0; k < path_constr.datalen; k++) {
11891                 uint32_t path_conv_10 = path_vals[k];
11892                 LDKRouteHop path_conv_10_conv;
11893                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
11894                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
11895                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
11896                 path_constr.data[k] = path_conv_10_conv;
11897         }
11898         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11899         *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr);
11900         uint64_t ret_ref = (uint64_t)ret_copy;
11901         return ret_ref;
11902 }
11903
11904 uint32_t  __attribute__((visibility("default"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
11905         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11906         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
11907         uint64_t ret_ref = (uint64_t)ret_copy;
11908         return ret_ref;
11909 }
11910
11911 uint32_t  __attribute__((visibility("default"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
11912         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
11913         outputs_constr.datalen = *((uint32_t*)outputs);
11914         if (outputs_constr.datalen > 0)
11915                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
11916         else
11917                 outputs_constr.data = NULL;
11918         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
11919         for (size_t b = 0; b < outputs_constr.datalen; b++) {
11920                 uint32_t outputs_conv_27 = outputs_vals[b];
11921                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
11922                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
11923                 outputs_constr.data[b] = outputs_conv_27_conv;
11924         }
11925         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11926         *ret_copy = Event_spendable_outputs(outputs_constr);
11927         uint64_t ret_ref = (uint64_t)ret_copy;
11928         return ret_ref;
11929 }
11930
11931 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
11932         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1);
11933         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
11934         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11935         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
11936         uint64_t ret_ref = (uint64_t)ret_copy;
11937         return ret_ref;
11938 }
11939
11940 uint32_t  __attribute__((visibility("default"))) TS_Event_channel_closed(int8_tArray channel_id, uint32_t reason) {
11941         LDKThirtyTwoBytes channel_id_ref;
11942         CHECK(*((uint32_t*)channel_id) == 32);
11943         memcpy(channel_id_ref.data, (uint8_t*)(channel_id + 4), 32);
11944         LDKClosureReason reason_conv = *(LDKClosureReason*)(((uint64_t)reason) & ~1);
11945         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
11946         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11947         *ret_copy = Event_channel_closed(channel_id_ref, reason_conv);
11948         uint64_t ret_ref = (uint64_t)ret_copy;
11949         return ret_ref;
11950 }
11951
11952 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
11953         LDKEvent* obj_conv = (LDKEvent*)obj;
11954         LDKCVec_u8Z ret_var = Event_write(obj_conv);
11955         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11956         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11957         CVec_u8Z_free(ret_var);
11958         return ret_arr;
11959 }
11960
11961 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
11962         if ((this_ptr & 1) != 0) return;
11963         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
11964         FREE((void*)this_ptr);
11965         MessageSendEvent_free(this_ptr_conv);
11966 }
11967
11968 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
11969         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
11970         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11971         *ret_copy = MessageSendEvent_clone(orig_conv);
11972         uint64_t ret_ref = (uint64_t)ret_copy;
11973         return ret_ref;
11974 }
11975
11976 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
11977         LDKPublicKey node_id_ref;
11978         CHECK(*((uint32_t*)node_id) == 33);
11979         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11980         LDKAcceptChannel msg_conv;
11981         msg_conv.inner = (void*)(msg & (~1));
11982         msg_conv.is_owned = (msg & 1) || (msg == 0);
11983         msg_conv = AcceptChannel_clone(&msg_conv);
11984         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11985         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
11986         uint64_t ret_ref = (uint64_t)ret_copy;
11987         return ret_ref;
11988 }
11989
11990 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
11991         LDKPublicKey node_id_ref;
11992         CHECK(*((uint32_t*)node_id) == 33);
11993         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11994         LDKOpenChannel msg_conv;
11995         msg_conv.inner = (void*)(msg & (~1));
11996         msg_conv.is_owned = (msg & 1) || (msg == 0);
11997         msg_conv = OpenChannel_clone(&msg_conv);
11998         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11999         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
12000         uint64_t ret_ref = (uint64_t)ret_copy;
12001         return ret_ref;
12002 }
12003
12004 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
12005         LDKPublicKey node_id_ref;
12006         CHECK(*((uint32_t*)node_id) == 33);
12007         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12008         LDKFundingCreated msg_conv;
12009         msg_conv.inner = (void*)(msg & (~1));
12010         msg_conv.is_owned = (msg & 1) || (msg == 0);
12011         msg_conv = FundingCreated_clone(&msg_conv);
12012         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12013         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
12014         uint64_t ret_ref = (uint64_t)ret_copy;
12015         return ret_ref;
12016 }
12017
12018 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
12019         LDKPublicKey node_id_ref;
12020         CHECK(*((uint32_t*)node_id) == 33);
12021         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12022         LDKFundingSigned msg_conv;
12023         msg_conv.inner = (void*)(msg & (~1));
12024         msg_conv.is_owned = (msg & 1) || (msg == 0);
12025         msg_conv = FundingSigned_clone(&msg_conv);
12026         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12027         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
12028         uint64_t ret_ref = (uint64_t)ret_copy;
12029         return ret_ref;
12030 }
12031
12032 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
12033         LDKPublicKey node_id_ref;
12034         CHECK(*((uint32_t*)node_id) == 33);
12035         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12036         LDKFundingLocked msg_conv;
12037         msg_conv.inner = (void*)(msg & (~1));
12038         msg_conv.is_owned = (msg & 1) || (msg == 0);
12039         msg_conv = FundingLocked_clone(&msg_conv);
12040         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12041         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
12042         uint64_t ret_ref = (uint64_t)ret_copy;
12043         return ret_ref;
12044 }
12045
12046 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
12047         LDKPublicKey node_id_ref;
12048         CHECK(*((uint32_t*)node_id) == 33);
12049         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12050         LDKAnnouncementSignatures msg_conv;
12051         msg_conv.inner = (void*)(msg & (~1));
12052         msg_conv.is_owned = (msg & 1) || (msg == 0);
12053         msg_conv = AnnouncementSignatures_clone(&msg_conv);
12054         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12055         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
12056         uint64_t ret_ref = (uint64_t)ret_copy;
12057         return ret_ref;
12058 }
12059
12060 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
12061         LDKPublicKey node_id_ref;
12062         CHECK(*((uint32_t*)node_id) == 33);
12063         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12064         LDKCommitmentUpdate updates_conv;
12065         updates_conv.inner = (void*)(updates & (~1));
12066         updates_conv.is_owned = (updates & 1) || (updates == 0);
12067         updates_conv = CommitmentUpdate_clone(&updates_conv);
12068         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12069         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
12070         uint64_t ret_ref = (uint64_t)ret_copy;
12071         return ret_ref;
12072 }
12073
12074 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
12075         LDKPublicKey node_id_ref;
12076         CHECK(*((uint32_t*)node_id) == 33);
12077         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12078         LDKRevokeAndACK msg_conv;
12079         msg_conv.inner = (void*)(msg & (~1));
12080         msg_conv.is_owned = (msg & 1) || (msg == 0);
12081         msg_conv = RevokeAndACK_clone(&msg_conv);
12082         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12083         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
12084         uint64_t ret_ref = (uint64_t)ret_copy;
12085         return ret_ref;
12086 }
12087
12088 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
12089         LDKPublicKey node_id_ref;
12090         CHECK(*((uint32_t*)node_id) == 33);
12091         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12092         LDKClosingSigned msg_conv;
12093         msg_conv.inner = (void*)(msg & (~1));
12094         msg_conv.is_owned = (msg & 1) || (msg == 0);
12095         msg_conv = ClosingSigned_clone(&msg_conv);
12096         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12097         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
12098         uint64_t ret_ref = (uint64_t)ret_copy;
12099         return ret_ref;
12100 }
12101
12102 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
12103         LDKPublicKey node_id_ref;
12104         CHECK(*((uint32_t*)node_id) == 33);
12105         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12106         LDKShutdown msg_conv;
12107         msg_conv.inner = (void*)(msg & (~1));
12108         msg_conv.is_owned = (msg & 1) || (msg == 0);
12109         msg_conv = Shutdown_clone(&msg_conv);
12110         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12111         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
12112         uint64_t ret_ref = (uint64_t)ret_copy;
12113         return ret_ref;
12114 }
12115
12116 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
12117         LDKPublicKey node_id_ref;
12118         CHECK(*((uint32_t*)node_id) == 33);
12119         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12120         LDKChannelReestablish msg_conv;
12121         msg_conv.inner = (void*)(msg & (~1));
12122         msg_conv.is_owned = (msg & 1) || (msg == 0);
12123         msg_conv = ChannelReestablish_clone(&msg_conv);
12124         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12125         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
12126         uint64_t ret_ref = (uint64_t)ret_copy;
12127         return ret_ref;
12128 }
12129
12130 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
12131         LDKChannelAnnouncement msg_conv;
12132         msg_conv.inner = (void*)(msg & (~1));
12133         msg_conv.is_owned = (msg & 1) || (msg == 0);
12134         msg_conv = ChannelAnnouncement_clone(&msg_conv);
12135         LDKChannelUpdate update_msg_conv;
12136         update_msg_conv.inner = (void*)(update_msg & (~1));
12137         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
12138         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
12139         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12140         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
12141         uint64_t ret_ref = (uint64_t)ret_copy;
12142         return ret_ref;
12143 }
12144
12145 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
12146         LDKNodeAnnouncement msg_conv;
12147         msg_conv.inner = (void*)(msg & (~1));
12148         msg_conv.is_owned = (msg & 1) || (msg == 0);
12149         msg_conv = NodeAnnouncement_clone(&msg_conv);
12150         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12151         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
12152         uint64_t ret_ref = (uint64_t)ret_copy;
12153         return ret_ref;
12154 }
12155
12156 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
12157         LDKChannelUpdate msg_conv;
12158         msg_conv.inner = (void*)(msg & (~1));
12159         msg_conv.is_owned = (msg & 1) || (msg == 0);
12160         msg_conv = ChannelUpdate_clone(&msg_conv);
12161         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12162         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
12163         uint64_t ret_ref = (uint64_t)ret_copy;
12164         return ret_ref;
12165 }
12166
12167 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
12168         LDKPublicKey node_id_ref;
12169         CHECK(*((uint32_t*)node_id) == 33);
12170         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12171         LDKChannelUpdate msg_conv;
12172         msg_conv.inner = (void*)(msg & (~1));
12173         msg_conv.is_owned = (msg & 1) || (msg == 0);
12174         msg_conv = ChannelUpdate_clone(&msg_conv);
12175         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12176         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
12177         uint64_t ret_ref = (uint64_t)ret_copy;
12178         return ret_ref;
12179 }
12180
12181 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
12182         LDKPublicKey node_id_ref;
12183         CHECK(*((uint32_t*)node_id) == 33);
12184         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12185         LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1);
12186         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
12187         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12188         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
12189         uint64_t ret_ref = (uint64_t)ret_copy;
12190         return ret_ref;
12191 }
12192
12193 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
12194         LDKPublicKey node_id_ref;
12195         CHECK(*((uint32_t*)node_id) == 33);
12196         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12197         LDKQueryChannelRange msg_conv;
12198         msg_conv.inner = (void*)(msg & (~1));
12199         msg_conv.is_owned = (msg & 1) || (msg == 0);
12200         msg_conv = QueryChannelRange_clone(&msg_conv);
12201         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12202         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
12203         uint64_t ret_ref = (uint64_t)ret_copy;
12204         return ret_ref;
12205 }
12206
12207 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
12208         LDKPublicKey node_id_ref;
12209         CHECK(*((uint32_t*)node_id) == 33);
12210         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12211         LDKQueryShortChannelIds msg_conv;
12212         msg_conv.inner = (void*)(msg & (~1));
12213         msg_conv.is_owned = (msg & 1) || (msg == 0);
12214         msg_conv = QueryShortChannelIds_clone(&msg_conv);
12215         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12216         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
12217         uint64_t ret_ref = (uint64_t)ret_copy;
12218         return ret_ref;
12219 }
12220
12221 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
12222         LDKPublicKey node_id_ref;
12223         CHECK(*((uint32_t*)node_id) == 33);
12224         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12225         LDKReplyChannelRange msg_conv;
12226         msg_conv.inner = (void*)(msg & (~1));
12227         msg_conv.is_owned = (msg & 1) || (msg == 0);
12228         msg_conv = ReplyChannelRange_clone(&msg_conv);
12229         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12230         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
12231         uint64_t ret_ref = (uint64_t)ret_copy;
12232         return ret_ref;
12233 }
12234
12235 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
12236         if ((this_ptr & 1) != 0) return;
12237         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
12238         FREE((void*)this_ptr);
12239         MessageSendEventsProvider_free(this_ptr_conv);
12240 }
12241
12242 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
12243         if ((this_ptr & 1) != 0) return;
12244         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
12245         FREE((void*)this_ptr);
12246         EventsProvider_free(this_ptr_conv);
12247 }
12248
12249 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
12250         if ((this_ptr & 1) != 0) return;
12251         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
12252         FREE((void*)this_ptr);
12253         EventHandler_free(this_ptr_conv);
12254 }
12255
12256 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
12257         if ((this_ptr & 1) != 0) return;
12258         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
12259         FREE((void*)this_ptr);
12260         APIError_free(this_ptr_conv);
12261 }
12262
12263 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
12264         LDKAPIError* orig_conv = (LDKAPIError*)orig;
12265         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12266         *ret_copy = APIError_clone(orig_conv);
12267         uint64_t ret_ref = (uint64_t)ret_copy;
12268         return ret_ref;
12269 }
12270
12271 uint32_t  __attribute__((visibility("default"))) TS_APIError_apimisuse_error(jstring err) {
12272         LDKStr err_conv = str_ref_to_owned_c(err);
12273         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12274         *ret_copy = APIError_apimisuse_error(err_conv);
12275         uint64_t ret_ref = (uint64_t)ret_copy;
12276         return ret_ref;
12277 }
12278
12279 uint32_t  __attribute__((visibility("default"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
12280         LDKStr err_conv = str_ref_to_owned_c(err);
12281         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12282         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
12283         uint64_t ret_ref = (uint64_t)ret_copy;
12284         return ret_ref;
12285 }
12286
12287 uint32_t  __attribute__((visibility("default"))) TS_APIError_route_error(jstring err) {
12288         LDKStr err_conv = str_ref_to_owned_c(err);
12289         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12290         *ret_copy = APIError_route_error(err_conv);
12291         uint64_t ret_ref = (uint64_t)ret_copy;
12292         return ret_ref;
12293 }
12294
12295 uint32_t  __attribute__((visibility("default"))) TS_APIError_channel_unavailable(jstring err) {
12296         LDKStr err_conv = str_ref_to_owned_c(err);
12297         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12298         *ret_copy = APIError_channel_unavailable(err_conv);
12299         uint64_t ret_ref = (uint64_t)ret_copy;
12300         return ret_ref;
12301 }
12302
12303 uint32_t  __attribute__((visibility("default"))) TS_APIError_monitor_update_failed() {
12304         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12305         *ret_copy = APIError_monitor_update_failed();
12306         uint64_t ret_ref = (uint64_t)ret_copy;
12307         return ret_ref;
12308 }
12309
12310 uint32_t  __attribute__((visibility("default"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
12311         LDKShutdownScript script_conv;
12312         script_conv.inner = (void*)(script & (~1));
12313         script_conv.is_owned = (script & 1) || (script == 0);
12314         script_conv = ShutdownScript_clone(&script_conv);
12315         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12316         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
12317         uint64_t ret_ref = (uint64_t)ret_copy;
12318         return ret_ref;
12319 }
12320
12321 uint32_t  __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_tArray sk) {
12322         LDKu8slice msg_ref;
12323         msg_ref.datalen = *((uint32_t*)msg);
12324         msg_ref.data = (int8_t*)(msg + 4);
12325         unsigned char sk_arr[32];
12326         CHECK(*((uint32_t*)sk) == 32);
12327         memcpy(sk_arr, (uint8_t*)(sk + 4), 32);
12328         unsigned char (*sk_ref)[32] = &sk_arr;
12329         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
12330         *ret_conv = sign(msg_ref, sk_ref);
12331         return (uint64_t)ret_conv;
12332 }
12333
12334 uint32_t  __attribute__((visibility("default"))) TS_recover_pk(int8_tArray msg, jstring sig) {
12335         LDKu8slice msg_ref;
12336         msg_ref.datalen = *((uint32_t*)msg);
12337         msg_ref.data = (int8_t*)(msg + 4);
12338         LDKStr sig_conv = str_ref_to_owned_c(sig);
12339         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
12340         *ret_conv = recover_pk(msg_ref, sig_conv);
12341         return (uint64_t)ret_conv;
12342 }
12343
12344 jboolean  __attribute__((visibility("default"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
12345         LDKu8slice msg_ref;
12346         msg_ref.datalen = *((uint32_t*)msg);
12347         msg_ref.data = (int8_t*)(msg + 4);
12348         LDKStr sig_conv = str_ref_to_owned_c(sig);
12349         LDKPublicKey pk_ref;
12350         CHECK(*((uint32_t*)pk) == 33);
12351         memcpy(pk_ref.compressed_form, (uint8_t*)(pk + 4), 33);
12352         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
12353         return ret_val;
12354 }
12355
12356 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
12357         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
12358         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
12359         return ret_conv;
12360 }
12361
12362 uint32_t  __attribute__((visibility("default"))) TS_Level_trace() {
12363         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
12364         return ret_conv;
12365 }
12366
12367 uint32_t  __attribute__((visibility("default"))) TS_Level_debug() {
12368         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
12369         return ret_conv;
12370 }
12371
12372 uint32_t  __attribute__((visibility("default"))) TS_Level_info() {
12373         uint32_t ret_conv = LDKLevel_to_js(Level_info());
12374         return ret_conv;
12375 }
12376
12377 uint32_t  __attribute__((visibility("default"))) TS_Level_warn() {
12378         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
12379         return ret_conv;
12380 }
12381
12382 uint32_t  __attribute__((visibility("default"))) TS_Level_error() {
12383         uint32_t ret_conv = LDKLevel_to_js(Level_error());
12384         return ret_conv;
12385 }
12386
12387 jboolean  __attribute__((visibility("default"))) TS_Level_eq(uint32_t a, uint32_t b) {
12388         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
12389         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
12390         jboolean ret_val = Level_eq(a_conv, b_conv);
12391         return ret_val;
12392 }
12393
12394 int64_t  __attribute__((visibility("default"))) TS_Level_hash(uint32_t o) {
12395         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
12396         int64_t ret_val = Level_hash(o_conv);
12397         return ret_val;
12398 }
12399
12400 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
12401         uint32_t ret_conv = LDKLevel_to_js(Level_max());
12402         return ret_conv;
12403 }
12404
12405 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
12406         if ((this_ptr & 1) != 0) return;
12407         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
12408         FREE((void*)this_ptr);
12409         Logger_free(this_ptr_conv);
12410 }
12411
12412 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
12413         LDKChannelHandshakeConfig this_obj_conv;
12414         this_obj_conv.inner = (void*)(this_obj & (~1));
12415         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12416         ChannelHandshakeConfig_free(this_obj_conv);
12417 }
12418
12419 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
12420         LDKChannelHandshakeConfig this_ptr_conv;
12421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12422         this_ptr_conv.is_owned = false;
12423         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
12424         return ret_val;
12425 }
12426
12427 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
12428         LDKChannelHandshakeConfig this_ptr_conv;
12429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12430         this_ptr_conv.is_owned = false;
12431         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
12432 }
12433
12434 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
12435         LDKChannelHandshakeConfig this_ptr_conv;
12436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12437         this_ptr_conv.is_owned = false;
12438         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
12439         return ret_val;
12440 }
12441
12442 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
12443         LDKChannelHandshakeConfig this_ptr_conv;
12444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12445         this_ptr_conv.is_owned = false;
12446         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
12447 }
12448
12449 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
12450         LDKChannelHandshakeConfig this_ptr_conv;
12451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12452         this_ptr_conv.is_owned = false;
12453         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
12454         return ret_val;
12455 }
12456
12457 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
12458         LDKChannelHandshakeConfig this_ptr_conv;
12459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12460         this_ptr_conv.is_owned = false;
12461         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
12462 }
12463
12464 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) {
12465         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
12466         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12467         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12468         uint64_t ret_ref = (uint64_t)ret_var.inner;
12469         if (ret_var.is_owned) {
12470                 ret_ref |= 1;
12471         }
12472         return ret_ref;
12473 }
12474
12475 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
12476         LDKChannelHandshakeConfig orig_conv;
12477         orig_conv.inner = (void*)(orig & (~1));
12478         orig_conv.is_owned = false;
12479         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
12480         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12481         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12482         uint64_t ret_ref = (uint64_t)ret_var.inner;
12483         if (ret_var.is_owned) {
12484                 ret_ref |= 1;
12485         }
12486         return ret_ref;
12487 }
12488
12489 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
12490         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
12491         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12492         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12493         uint64_t ret_ref = (uint64_t)ret_var.inner;
12494         if (ret_var.is_owned) {
12495                 ret_ref |= 1;
12496         }
12497         return ret_ref;
12498 }
12499
12500 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
12501         LDKChannelHandshakeLimits this_obj_conv;
12502         this_obj_conv.inner = (void*)(this_obj & (~1));
12503         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12504         ChannelHandshakeLimits_free(this_obj_conv);
12505 }
12506
12507 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
12508         LDKChannelHandshakeLimits this_ptr_conv;
12509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12510         this_ptr_conv.is_owned = false;
12511         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
12512         return ret_val;
12513 }
12514
12515 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
12516         LDKChannelHandshakeLimits this_ptr_conv;
12517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12518         this_ptr_conv.is_owned = false;
12519         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
12520 }
12521
12522 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
12523         LDKChannelHandshakeLimits this_ptr_conv;
12524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12525         this_ptr_conv.is_owned = false;
12526         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
12527         return ret_val;
12528 }
12529
12530 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
12531         LDKChannelHandshakeLimits this_ptr_conv;
12532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12533         this_ptr_conv.is_owned = false;
12534         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
12535 }
12536
12537 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
12538         LDKChannelHandshakeLimits this_ptr_conv;
12539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12540         this_ptr_conv.is_owned = false;
12541         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
12542         return ret_val;
12543 }
12544
12545 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
12546         LDKChannelHandshakeLimits this_ptr_conv;
12547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12548         this_ptr_conv.is_owned = false;
12549         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
12550 }
12551
12552 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
12553         LDKChannelHandshakeLimits this_ptr_conv;
12554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12555         this_ptr_conv.is_owned = false;
12556         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
12557         return ret_val;
12558 }
12559
12560 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
12561         LDKChannelHandshakeLimits this_ptr_conv;
12562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12563         this_ptr_conv.is_owned = false;
12564         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
12565 }
12566
12567 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
12568         LDKChannelHandshakeLimits this_ptr_conv;
12569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12570         this_ptr_conv.is_owned = false;
12571         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
12572         return ret_val;
12573 }
12574
12575 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
12576         LDKChannelHandshakeLimits this_ptr_conv;
12577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12578         this_ptr_conv.is_owned = false;
12579         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
12580 }
12581
12582 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
12583         LDKChannelHandshakeLimits this_ptr_conv;
12584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12585         this_ptr_conv.is_owned = false;
12586         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
12587         return ret_val;
12588 }
12589
12590 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
12591         LDKChannelHandshakeLimits this_ptr_conv;
12592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12593         this_ptr_conv.is_owned = false;
12594         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
12595 }
12596
12597 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
12598         LDKChannelHandshakeLimits this_ptr_conv;
12599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12600         this_ptr_conv.is_owned = false;
12601         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
12602         return ret_val;
12603 }
12604
12605 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
12606         LDKChannelHandshakeLimits this_ptr_conv;
12607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12608         this_ptr_conv.is_owned = false;
12609         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
12610 }
12611
12612 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
12613         LDKChannelHandshakeLimits this_ptr_conv;
12614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12615         this_ptr_conv.is_owned = false;
12616         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
12617         return ret_val;
12618 }
12619
12620 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
12621         LDKChannelHandshakeLimits this_ptr_conv;
12622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12623         this_ptr_conv.is_owned = false;
12624         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
12625 }
12626
12627 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) {
12628         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);
12629         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12630         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12631         uint64_t ret_ref = (uint64_t)ret_var.inner;
12632         if (ret_var.is_owned) {
12633                 ret_ref |= 1;
12634         }
12635         return ret_ref;
12636 }
12637
12638 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
12639         LDKChannelHandshakeLimits orig_conv;
12640         orig_conv.inner = (void*)(orig & (~1));
12641         orig_conv.is_owned = false;
12642         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
12643         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12644         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12645         uint64_t ret_ref = (uint64_t)ret_var.inner;
12646         if (ret_var.is_owned) {
12647                 ret_ref |= 1;
12648         }
12649         return ret_ref;
12650 }
12651
12652 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
12653         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
12654         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12655         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12656         uint64_t ret_ref = (uint64_t)ret_var.inner;
12657         if (ret_var.is_owned) {
12658                 ret_ref |= 1;
12659         }
12660         return ret_ref;
12661 }
12662
12663 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
12664         LDKChannelConfig this_obj_conv;
12665         this_obj_conv.inner = (void*)(this_obj & (~1));
12666         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12667         ChannelConfig_free(this_obj_conv);
12668 }
12669
12670 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
12671         LDKChannelConfig this_ptr_conv;
12672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12673         this_ptr_conv.is_owned = false;
12674         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
12675         return ret_val;
12676 }
12677
12678 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
12679         LDKChannelConfig this_ptr_conv;
12680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12681         this_ptr_conv.is_owned = false;
12682         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
12683 }
12684
12685 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
12686         LDKChannelConfig this_ptr_conv;
12687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12688         this_ptr_conv.is_owned = false;
12689         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
12690         return ret_val;
12691 }
12692
12693 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint32_t this_ptr, int32_t val) {
12694         LDKChannelConfig this_ptr_conv;
12695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12696         this_ptr_conv.is_owned = false;
12697         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
12698 }
12699
12700 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
12701         LDKChannelConfig this_ptr_conv;
12702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12703         this_ptr_conv.is_owned = false;
12704         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
12705         return ret_val;
12706 }
12707
12708 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
12709         LDKChannelConfig this_ptr_conv;
12710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12711         this_ptr_conv.is_owned = false;
12712         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
12713 }
12714
12715 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
12716         LDKChannelConfig this_ptr_conv;
12717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12718         this_ptr_conv.is_owned = false;
12719         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
12720         return ret_val;
12721 }
12722
12723 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
12724         LDKChannelConfig this_ptr_conv;
12725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12726         this_ptr_conv.is_owned = false;
12727         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
12728 }
12729
12730 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
12731         LDKChannelConfig this_ptr_conv;
12732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12733         this_ptr_conv.is_owned = false;
12734         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
12735         return ret_val;
12736 }
12737
12738 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
12739         LDKChannelConfig this_ptr_conv;
12740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12741         this_ptr_conv.is_owned = false;
12742         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
12743 }
12744
12745 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_max_dust_htlc_exposure_msat(uint32_t this_ptr) {
12746         LDKChannelConfig this_ptr_conv;
12747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12748         this_ptr_conv.is_owned = false;
12749         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
12750         return ret_val;
12751 }
12752
12753 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_max_dust_htlc_exposure_msat(uint32_t this_ptr, int64_t val) {
12754         LDKChannelConfig this_ptr_conv;
12755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12756         this_ptr_conv.is_owned = false;
12757         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
12758 }
12759
12760 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr) {
12761         LDKChannelConfig this_ptr_conv;
12762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12763         this_ptr_conv.is_owned = false;
12764         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
12765         return ret_val;
12766 }
12767
12768 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
12769         LDKChannelConfig this_ptr_conv;
12770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12771         this_ptr_conv.is_owned = false;
12772         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
12773 }
12774
12775 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
12776         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
12777         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12778         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12779         uint64_t ret_ref = (uint64_t)ret_var.inner;
12780         if (ret_var.is_owned) {
12781                 ret_ref |= 1;
12782         }
12783         return ret_ref;
12784 }
12785
12786 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
12787         LDKChannelConfig orig_conv;
12788         orig_conv.inner = (void*)(orig & (~1));
12789         orig_conv.is_owned = false;
12790         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
12791         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12792         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12793         uint64_t ret_ref = (uint64_t)ret_var.inner;
12794         if (ret_var.is_owned) {
12795                 ret_ref |= 1;
12796         }
12797         return ret_ref;
12798 }
12799
12800 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
12801         LDKChannelConfig ret_var = ChannelConfig_default();
12802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12804         uint64_t ret_ref = (uint64_t)ret_var.inner;
12805         if (ret_var.is_owned) {
12806                 ret_ref |= 1;
12807         }
12808         return ret_ref;
12809 }
12810
12811 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
12812         LDKChannelConfig obj_conv;
12813         obj_conv.inner = (void*)(obj & (~1));
12814         obj_conv.is_owned = false;
12815         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
12816         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12817         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12818         CVec_u8Z_free(ret_var);
12819         return ret_arr;
12820 }
12821
12822 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
12823         LDKu8slice ser_ref;
12824         ser_ref.datalen = *((uint32_t*)ser);
12825         ser_ref.data = (int8_t*)(ser + 4);
12826         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12827         *ret_conv = ChannelConfig_read(ser_ref);
12828         return (uint64_t)ret_conv;
12829 }
12830
12831 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
12832         LDKUserConfig this_obj_conv;
12833         this_obj_conv.inner = (void*)(this_obj & (~1));
12834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12835         UserConfig_free(this_obj_conv);
12836 }
12837
12838 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
12839         LDKUserConfig this_ptr_conv;
12840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12841         this_ptr_conv.is_owned = false;
12842         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
12843         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12844         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12845         uint64_t ret_ref = (uint64_t)ret_var.inner;
12846         if (ret_var.is_owned) {
12847                 ret_ref |= 1;
12848         }
12849         return ret_ref;
12850 }
12851
12852 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
12853         LDKUserConfig this_ptr_conv;
12854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12855         this_ptr_conv.is_owned = false;
12856         LDKChannelHandshakeConfig val_conv;
12857         val_conv.inner = (void*)(val & (~1));
12858         val_conv.is_owned = (val & 1) || (val == 0);
12859         val_conv = ChannelHandshakeConfig_clone(&val_conv);
12860         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
12861 }
12862
12863 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
12864         LDKUserConfig this_ptr_conv;
12865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12866         this_ptr_conv.is_owned = false;
12867         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
12868         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12869         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12870         uint64_t ret_ref = (uint64_t)ret_var.inner;
12871         if (ret_var.is_owned) {
12872                 ret_ref |= 1;
12873         }
12874         return ret_ref;
12875 }
12876
12877 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
12878         LDKUserConfig this_ptr_conv;
12879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12880         this_ptr_conv.is_owned = false;
12881         LDKChannelHandshakeLimits val_conv;
12882         val_conv.inner = (void*)(val & (~1));
12883         val_conv.is_owned = (val & 1) || (val == 0);
12884         val_conv = ChannelHandshakeLimits_clone(&val_conv);
12885         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
12886 }
12887
12888 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
12889         LDKUserConfig this_ptr_conv;
12890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12891         this_ptr_conv.is_owned = false;
12892         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
12893         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12894         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12895         uint64_t ret_ref = (uint64_t)ret_var.inner;
12896         if (ret_var.is_owned) {
12897                 ret_ref |= 1;
12898         }
12899         return ret_ref;
12900 }
12901
12902 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
12903         LDKUserConfig this_ptr_conv;
12904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12905         this_ptr_conv.is_owned = false;
12906         LDKChannelConfig val_conv;
12907         val_conv.inner = (void*)(val & (~1));
12908         val_conv.is_owned = (val & 1) || (val == 0);
12909         val_conv = ChannelConfig_clone(&val_conv);
12910         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
12911 }
12912
12913 jboolean  __attribute__((visibility("default"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
12914         LDKUserConfig this_ptr_conv;
12915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12916         this_ptr_conv.is_owned = false;
12917         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
12918         return ret_val;
12919 }
12920
12921 void  __attribute__((visibility("default"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint32_t this_ptr, jboolean val) {
12922         LDKUserConfig this_ptr_conv;
12923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12924         this_ptr_conv.is_owned = false;
12925         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
12926 }
12927
12928 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_channel_config_arg, uint32_t peer_channel_config_limits_arg, uint32_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg) {
12929         LDKChannelHandshakeConfig own_channel_config_arg_conv;
12930         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
12931         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
12932         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
12933         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
12934         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
12935         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
12936         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
12937         LDKChannelConfig channel_options_arg_conv;
12938         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
12939         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
12940         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
12941         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg);
12942         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12943         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12944         uint64_t ret_ref = (uint64_t)ret_var.inner;
12945         if (ret_var.is_owned) {
12946                 ret_ref |= 1;
12947         }
12948         return ret_ref;
12949 }
12950
12951 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
12952         LDKUserConfig orig_conv;
12953         orig_conv.inner = (void*)(orig & (~1));
12954         orig_conv.is_owned = false;
12955         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
12956         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12957         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12958         uint64_t ret_ref = (uint64_t)ret_var.inner;
12959         if (ret_var.is_owned) {
12960                 ret_ref |= 1;
12961         }
12962         return ret_ref;
12963 }
12964
12965 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
12966         LDKUserConfig ret_var = UserConfig_default();
12967         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12968         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12969         uint64_t ret_ref = (uint64_t)ret_var.inner;
12970         if (ret_var.is_owned) {
12971                 ret_ref |= 1;
12972         }
12973         return ret_ref;
12974 }
12975
12976 void  __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) {
12977         LDKBestBlock this_obj_conv;
12978         this_obj_conv.inner = (void*)(this_obj & (~1));
12979         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12980         BestBlock_free(this_obj_conv);
12981 }
12982
12983 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) {
12984         LDKBestBlock orig_conv;
12985         orig_conv.inner = (void*)(orig & (~1));
12986         orig_conv.is_owned = false;
12987         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
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 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
12998         LDKNetwork network_conv = LDKNetwork_from_js(network);
12999         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
13000         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13001         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13002         uint64_t ret_ref = (uint64_t)ret_var.inner;
13003         if (ret_var.is_owned) {
13004                 ret_ref |= 1;
13005         }
13006         return ret_ref;
13007 }
13008
13009 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
13010         LDKThirtyTwoBytes block_hash_ref;
13011         CHECK(*((uint32_t*)block_hash) == 32);
13012         memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
13013         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
13014         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13015         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13016         uint64_t ret_ref = (uint64_t)ret_var.inner;
13017         if (ret_var.is_owned) {
13018                 ret_ref |= 1;
13019         }
13020         return ret_ref;
13021 }
13022
13023 int8_tArray  __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) {
13024         LDKBestBlock this_arg_conv;
13025         this_arg_conv.inner = (void*)(this_arg & (~1));
13026         this_arg_conv.is_owned = false;
13027         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13028         memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32);
13029         return ret_arr;
13030 }
13031
13032 int32_t  __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) {
13033         LDKBestBlock this_arg_conv;
13034         this_arg_conv.inner = (void*)(this_arg & (~1));
13035         this_arg_conv.is_owned = false;
13036         int32_t ret_val = BestBlock_height(&this_arg_conv);
13037         return ret_val;
13038 }
13039
13040 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
13041         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
13042         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
13043         return ret_conv;
13044 }
13045
13046 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_chain() {
13047         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
13048         return ret_conv;
13049 }
13050
13051 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_tx() {
13052         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
13053         return ret_conv;
13054 }
13055
13056 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
13057         if ((this_ptr & 1) != 0) return;
13058         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
13059         FREE((void*)this_ptr);
13060         Access_free(this_ptr_conv);
13061 }
13062
13063 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
13064         if ((this_ptr & 1) != 0) return;
13065         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
13066         FREE((void*)this_ptr);
13067         Listen_free(this_ptr_conv);
13068 }
13069
13070 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
13071         if ((this_ptr & 1) != 0) return;
13072         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
13073         FREE((void*)this_ptr);
13074         Confirm_free(this_ptr_conv);
13075 }
13076
13077 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
13078         if ((this_ptr & 1) != 0) return;
13079         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
13080         FREE((void*)this_ptr);
13081         Watch_free(this_ptr_conv);
13082 }
13083
13084 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
13085         if ((this_ptr & 1) != 0) return;
13086         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
13087         FREE((void*)this_ptr);
13088         Filter_free(this_ptr_conv);
13089 }
13090
13091 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
13092         LDKWatchedOutput this_obj_conv;
13093         this_obj_conv.inner = (void*)(this_obj & (~1));
13094         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13095         WatchedOutput_free(this_obj_conv);
13096 }
13097
13098 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
13099         LDKWatchedOutput this_ptr_conv;
13100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13101         this_ptr_conv.is_owned = false;
13102         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13103         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
13104         return ret_arr;
13105 }
13106
13107 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
13108         LDKWatchedOutput this_ptr_conv;
13109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13110         this_ptr_conv.is_owned = false;
13111         LDKThirtyTwoBytes val_ref;
13112         CHECK(*((uint32_t*)val) == 32);
13113         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13114         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
13115 }
13116
13117 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
13118         LDKWatchedOutput this_ptr_conv;
13119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13120         this_ptr_conv.is_owned = false;
13121         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
13122         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13123         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13124         uint64_t ret_ref = (uint64_t)ret_var.inner;
13125         if (ret_var.is_owned) {
13126                 ret_ref |= 1;
13127         }
13128         return ret_ref;
13129 }
13130
13131 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
13132         LDKWatchedOutput this_ptr_conv;
13133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13134         this_ptr_conv.is_owned = false;
13135         LDKOutPoint val_conv;
13136         val_conv.inner = (void*)(val & (~1));
13137         val_conv.is_owned = (val & 1) || (val == 0);
13138         val_conv = OutPoint_clone(&val_conv);
13139         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
13140 }
13141
13142 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
13143         LDKWatchedOutput this_ptr_conv;
13144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13145         this_ptr_conv.is_owned = false;
13146         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
13147         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13148         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13149         return ret_arr;
13150 }
13151
13152 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
13153         LDKWatchedOutput this_ptr_conv;
13154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13155         this_ptr_conv.is_owned = false;
13156         LDKCVec_u8Z val_ref;
13157         val_ref.datalen = *((uint32_t*)val);
13158         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13159         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
13160         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
13161 }
13162
13163 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
13164         LDKThirtyTwoBytes block_hash_arg_ref;
13165         CHECK(*((uint32_t*)block_hash_arg) == 32);
13166         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
13167         LDKOutPoint outpoint_arg_conv;
13168         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
13169         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
13170         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
13171         LDKCVec_u8Z script_pubkey_arg_ref;
13172         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
13173         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13174         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
13175         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
13176         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13177         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13178         uint64_t ret_ref = (uint64_t)ret_var.inner;
13179         if (ret_var.is_owned) {
13180                 ret_ref |= 1;
13181         }
13182         return ret_ref;
13183 }
13184
13185 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t orig) {
13186         LDKWatchedOutput orig_conv;
13187         orig_conv.inner = (void*)(orig & (~1));
13188         orig_conv.is_owned = false;
13189         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
13190         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13191         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13192         uint64_t ret_ref = (uint64_t)ret_var.inner;
13193         if (ret_var.is_owned) {
13194                 ret_ref |= 1;
13195         }
13196         return ret_ref;
13197 }
13198
13199 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o) {
13200         LDKWatchedOutput o_conv;
13201         o_conv.inner = (void*)(o & (~1));
13202         o_conv.is_owned = false;
13203         int64_t ret_val = WatchedOutput_hash(&o_conv);
13204         return ret_val;
13205 }
13206
13207 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
13208         if ((this_ptr & 1) != 0) return;
13209         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
13210         FREE((void*)this_ptr);
13211         BroadcasterInterface_free(this_ptr_conv);
13212 }
13213
13214 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
13215         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
13216         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
13217         return ret_conv;
13218 }
13219
13220 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_background() {
13221         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
13222         return ret_conv;
13223 }
13224
13225 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_normal() {
13226         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
13227         return ret_conv;
13228 }
13229
13230 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_high_priority() {
13231         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
13232         return ret_conv;
13233 }
13234
13235 jboolean  __attribute__((visibility("default"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
13236         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
13237         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
13238         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
13239         return ret_val;
13240 }
13241
13242 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
13243         if ((this_ptr & 1) != 0) return;
13244         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
13245         FREE((void*)this_ptr);
13246         FeeEstimator_free(this_ptr_conv);
13247 }
13248
13249 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
13250         LDKChainMonitor this_obj_conv;
13251         this_obj_conv.inner = (void*)(this_obj & (~1));
13252         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13253         ChainMonitor_free(this_obj_conv);
13254 }
13255
13256 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
13257         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1);
13258         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
13259         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
13260                 // Manually implement clone for Java trait instances
13261         }
13262         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13263         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13264         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
13265         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
13266         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
13267         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13268         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13269         uint64_t ret_ref = (uint64_t)ret_var.inner;
13270         if (ret_var.is_owned) {
13271                 ret_ref |= 1;
13272         }
13273         return ret_ref;
13274 }
13275
13276 uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
13277         LDKChainMonitor this_arg_conv;
13278         this_arg_conv.inner = (void*)(this_arg & (~1));
13279         this_arg_conv.is_owned = false;
13280         LDKCVec_ChannelDetailsZ ignored_channels_constr;
13281         ignored_channels_constr.datalen = *((uint32_t*)ignored_channels);
13282         if (ignored_channels_constr.datalen > 0)
13283                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13284         else
13285                 ignored_channels_constr.data = NULL;
13286         uint32_t* ignored_channels_vals = (uint32_t*)(ignored_channels + 4);
13287         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
13288                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
13289                 LDKChannelDetails ignored_channels_conv_16_conv;
13290                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
13291                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
13292                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
13293                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
13294         }
13295         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
13296         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13297         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13298         for (size_t j = 0; j < ret_var.datalen; j++) {
13299                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13300                 *ret_conv_9_copy = Balance_clone(&ret_var.data[j]);
13301                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
13302                 ret_arr_ptr[j] = ret_conv_9_ref;
13303         }
13304         FREE(ret_var.data);
13305         return ret_arr;
13306 }
13307
13308 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
13309         LDKChainMonitor this_arg_conv;
13310         this_arg_conv.inner = (void*)(this_arg & (~1));
13311         this_arg_conv.is_owned = false;
13312         LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
13313         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
13314         return (uint64_t)ret_ret;
13315 }
13316
13317 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
13318         LDKChainMonitor this_arg_conv;
13319         this_arg_conv.inner = (void*)(this_arg & (~1));
13320         this_arg_conv.is_owned = false;
13321         LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
13322         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
13323         return (uint64_t)ret_ret;
13324 }
13325
13326 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
13327         LDKChainMonitor this_arg_conv;
13328         this_arg_conv.inner = (void*)(this_arg & (~1));
13329         this_arg_conv.is_owned = false;
13330         LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch");
13331         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
13332         return (uint64_t)ret_ret;
13333 }
13334
13335 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
13336         LDKChainMonitor this_arg_conv;
13337         this_arg_conv.inner = (void*)(this_arg & (~1));
13338         this_arg_conv.is_owned = false;
13339         LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
13340         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
13341         return (uint64_t)ret_ret;
13342 }
13343
13344 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
13345         LDKChannelMonitorUpdate this_obj_conv;
13346         this_obj_conv.inner = (void*)(this_obj & (~1));
13347         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13348         ChannelMonitorUpdate_free(this_obj_conv);
13349 }
13350
13351 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
13352         LDKChannelMonitorUpdate this_ptr_conv;
13353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13354         this_ptr_conv.is_owned = false;
13355         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
13356         return ret_val;
13357 }
13358
13359 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
13360         LDKChannelMonitorUpdate this_ptr_conv;
13361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13362         this_ptr_conv.is_owned = false;
13363         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
13364 }
13365
13366 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
13367         LDKChannelMonitorUpdate orig_conv;
13368         orig_conv.inner = (void*)(orig & (~1));
13369         orig_conv.is_owned = false;
13370         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
13371         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13372         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13373         uint64_t ret_ref = (uint64_t)ret_var.inner;
13374         if (ret_var.is_owned) {
13375                 ret_ref |= 1;
13376         }
13377         return ret_ref;
13378 }
13379
13380 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
13381         LDKChannelMonitorUpdate obj_conv;
13382         obj_conv.inner = (void*)(obj & (~1));
13383         obj_conv.is_owned = false;
13384         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
13385         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13386         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13387         CVec_u8Z_free(ret_var);
13388         return ret_arr;
13389 }
13390
13391 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
13392         LDKu8slice ser_ref;
13393         ser_ref.datalen = *((uint32_t*)ser);
13394         ser_ref.data = (int8_t*)(ser + 4);
13395         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
13396         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
13397         return (uint64_t)ret_conv;
13398 }
13399
13400 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
13401         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
13402         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
13403         return ret_conv;
13404 }
13405
13406 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
13407         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
13408         return ret_conv;
13409 }
13410
13411 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
13412         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
13413         return ret_conv;
13414 }
13415
13416 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
13417         LDKMonitorUpdateError this_obj_conv;
13418         this_obj_conv.inner = (void*)(this_obj & (~1));
13419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13420         MonitorUpdateError_free(this_obj_conv);
13421 }
13422
13423 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
13424         LDKMonitorUpdateError orig_conv;
13425         orig_conv.inner = (void*)(orig & (~1));
13426         orig_conv.is_owned = false;
13427         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
13428         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13429         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13430         uint64_t ret_ref = (uint64_t)ret_var.inner;
13431         if (ret_var.is_owned) {
13432                 ret_ref |= 1;
13433         }
13434         return ret_ref;
13435 }
13436
13437 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
13438         if ((this_ptr & 1) != 0) return;
13439         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
13440         FREE((void*)this_ptr);
13441         MonitorEvent_free(this_ptr_conv);
13442 }
13443
13444 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
13445         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
13446         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
13447         *ret_copy = MonitorEvent_clone(orig_conv);
13448         uint64_t ret_ref = (uint64_t)ret_copy;
13449         return ret_ref;
13450 }
13451
13452 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_htlcevent(uint32_t a) {
13453         LDKHTLCUpdate a_conv;
13454         a_conv.inner = (void*)(a & (~1));
13455         a_conv.is_owned = (a & 1) || (a == 0);
13456         a_conv = HTLCUpdate_clone(&a_conv);
13457         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
13458         *ret_copy = MonitorEvent_htlcevent(a_conv);
13459         uint64_t ret_ref = (uint64_t)ret_copy;
13460         return ret_ref;
13461 }
13462
13463 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
13464         LDKOutPoint a_conv;
13465         a_conv.inner = (void*)(a & (~1));
13466         a_conv.is_owned = (a & 1) || (a == 0);
13467         a_conv = OutPoint_clone(&a_conv);
13468         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
13469         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
13470         uint64_t ret_ref = (uint64_t)ret_copy;
13471         return ret_ref;
13472 }
13473
13474 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
13475         LDKHTLCUpdate this_obj_conv;
13476         this_obj_conv.inner = (void*)(this_obj & (~1));
13477         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13478         HTLCUpdate_free(this_obj_conv);
13479 }
13480
13481 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
13482         LDKHTLCUpdate orig_conv;
13483         orig_conv.inner = (void*)(orig & (~1));
13484         orig_conv.is_owned = false;
13485         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
13486         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13487         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13488         uint64_t ret_ref = (uint64_t)ret_var.inner;
13489         if (ret_var.is_owned) {
13490                 ret_ref |= 1;
13491         }
13492         return ret_ref;
13493 }
13494
13495 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
13496         LDKHTLCUpdate obj_conv;
13497         obj_conv.inner = (void*)(obj & (~1));
13498         obj_conv.is_owned = false;
13499         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
13500         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13501         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13502         CVec_u8Z_free(ret_var);
13503         return ret_arr;
13504 }
13505
13506 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
13507         LDKu8slice ser_ref;
13508         ser_ref.datalen = *((uint32_t*)ser);
13509         ser_ref.data = (int8_t*)(ser + 4);
13510         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13511         *ret_conv = HTLCUpdate_read(ser_ref);
13512         return (uint64_t)ret_conv;
13513 }
13514
13515 void  __attribute__((visibility("default"))) TS_Balance_free(uint32_t this_ptr) {
13516         if ((this_ptr & 1) != 0) return;
13517         LDKBalance this_ptr_conv = *(LDKBalance*)(((uint64_t)this_ptr) & ~1);
13518         FREE((void*)this_ptr);
13519         Balance_free(this_ptr_conv);
13520 }
13521
13522 uint32_t  __attribute__((visibility("default"))) TS_Balance_clone(uint32_t orig) {
13523         LDKBalance* orig_conv = (LDKBalance*)orig;
13524         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13525         *ret_copy = Balance_clone(orig_conv);
13526         uint64_t ret_ref = (uint64_t)ret_copy;
13527         return ret_ref;
13528 }
13529
13530 uint32_t  __attribute__((visibility("default"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
13531         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13532         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
13533         uint64_t ret_ref = (uint64_t)ret_copy;
13534         return ret_ref;
13535 }
13536
13537 uint32_t  __attribute__((visibility("default"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
13538         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13539         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
13540         uint64_t ret_ref = (uint64_t)ret_copy;
13541         return ret_ref;
13542 }
13543
13544 uint32_t  __attribute__((visibility("default"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
13545         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13546         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
13547         uint64_t ret_ref = (uint64_t)ret_copy;
13548         return ret_ref;
13549 }
13550
13551 uint32_t  __attribute__((visibility("default"))) TS_Balance_maybe_claimable_htlcawaiting_timeout(int64_t claimable_amount_satoshis, int32_t claimable_height) {
13552         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13553         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
13554         uint64_t ret_ref = (uint64_t)ret_copy;
13555         return ret_ref;
13556 }
13557
13558 jboolean  __attribute__((visibility("default"))) TS_Balance_eq(uint32_t a, uint32_t b) {
13559         LDKBalance* a_conv = (LDKBalance*)a;
13560         LDKBalance* b_conv = (LDKBalance*)b;
13561         jboolean ret_val = Balance_eq(a_conv, b_conv);
13562         return ret_val;
13563 }
13564
13565 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
13566         LDKChannelMonitor this_obj_conv;
13567         this_obj_conv.inner = (void*)(this_obj & (~1));
13568         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13569         ChannelMonitor_free(this_obj_conv);
13570 }
13571
13572 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
13573         LDKChannelMonitor orig_conv;
13574         orig_conv.inner = (void*)(orig & (~1));
13575         orig_conv.is_owned = false;
13576         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
13577         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13578         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13579         uint64_t ret_ref = (uint64_t)ret_var.inner;
13580         if (ret_var.is_owned) {
13581                 ret_ref |= 1;
13582         }
13583         return ret_ref;
13584 }
13585
13586 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
13587         LDKChannelMonitor obj_conv;
13588         obj_conv.inner = (void*)(obj & (~1));
13589         obj_conv.is_owned = false;
13590         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
13591         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13592         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13593         CVec_u8Z_free(ret_var);
13594         return ret_arr;
13595 }
13596
13597 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) {
13598         LDKChannelMonitor this_arg_conv;
13599         this_arg_conv.inner = (void*)(this_arg & (~1));
13600         this_arg_conv.is_owned = false;
13601         LDKChannelMonitorUpdate updates_conv;
13602         updates_conv.inner = (void*)(updates & (~1));
13603         updates_conv.is_owned = false;
13604         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13605         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13606         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
13607         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
13608         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
13609         return (uint64_t)ret_conv;
13610 }
13611
13612 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
13613         LDKChannelMonitor this_arg_conv;
13614         this_arg_conv.inner = (void*)(this_arg & (~1));
13615         this_arg_conv.is_owned = false;
13616         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
13617         return ret_val;
13618 }
13619
13620 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
13621         LDKChannelMonitor this_arg_conv;
13622         this_arg_conv.inner = (void*)(this_arg & (~1));
13623         this_arg_conv.is_owned = false;
13624         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
13625         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
13626         return (uint64_t)ret_ref;
13627 }
13628
13629 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
13630         LDKChannelMonitor this_arg_conv;
13631         this_arg_conv.inner = (void*)(this_arg & (~1));
13632         this_arg_conv.is_owned = false;
13633         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
13634         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13635         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13636         for (size_t c = 0; c < ret_var.datalen; c++) {
13637                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_54_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
13638                 *ret_conv_54_ref = ret_var.data[c];
13639                 ret_arr_ptr[c] = (uint64_t)ret_conv_54_ref;
13640         }
13641         FREE(ret_var.data);
13642         return ret_arr;
13643 }
13644
13645 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
13646         LDKChannelMonitor this_arg_conv;
13647         this_arg_conv.inner = (void*)(this_arg & (~1));
13648         this_arg_conv.is_owned = false;
13649         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
13650         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
13651 }
13652
13653 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
13654         LDKChannelMonitor this_arg_conv;
13655         this_arg_conv.inner = (void*)(this_arg & (~1));
13656         this_arg_conv.is_owned = false;
13657         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
13658         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13659         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13660         for (size_t o = 0; o < ret_var.datalen; o++) {
13661                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
13662                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
13663                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
13664                 ret_arr_ptr[o] = ret_conv_14_ref;
13665         }
13666         FREE(ret_var.data);
13667         return ret_arr;
13668 }
13669
13670 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
13671         LDKChannelMonitor this_arg_conv;
13672         this_arg_conv.inner = (void*)(this_arg & (~1));
13673         this_arg_conv.is_owned = false;
13674         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
13675         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13676         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13677         for (size_t h = 0; h < ret_var.datalen; h++) {
13678                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13679                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
13680                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
13681                 ret_arr_ptr[h] = ret_conv_7_ref;
13682         }
13683         FREE(ret_var.data);
13684         return ret_arr;
13685 }
13686
13687 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
13688         LDKChannelMonitor this_arg_conv;
13689         this_arg_conv.inner = (void*)(this_arg & (~1));
13690         this_arg_conv.is_owned = false;
13691         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
13692         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
13693         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
13694         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
13695         for (size_t m = 0; m < ret_var.datalen; m++) {
13696                 LDKTransaction ret_conv_12_var = ret_var.data[m];
13697                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13698                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
13699                 Transaction_free(ret_conv_12_var);
13700                 ret_arr_ptr[m] = ret_conv_12_arr;
13701         }
13702         FREE(ret_var.data);
13703         return ret_arr;
13704 }
13705
13706 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) {
13707         LDKChannelMonitor this_arg_conv;
13708         this_arg_conv.inner = (void*)(this_arg & (~1));
13709         this_arg_conv.is_owned = false;
13710         unsigned char header_arr[80];
13711         CHECK(*((uint32_t*)header) == 80);
13712         memcpy(header_arr, (uint8_t*)(header + 4), 80);
13713         unsigned char (*header_ref)[80] = &header_arr;
13714         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
13715         txdata_constr.datalen = *((uint32_t*)txdata);
13716         if (txdata_constr.datalen > 0)
13717                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13718         else
13719                 txdata_constr.data = NULL;
13720         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
13721         for (size_t e = 0; e < txdata_constr.datalen; e++) {
13722                 uint32_t txdata_conv_30 = txdata_vals[e];
13723                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
13724                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
13725                 txdata_constr.data[e] = txdata_conv_30_conv;
13726         }
13727         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13728         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13729         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13730         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);
13731         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13732         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13733         for (size_t x = 0; x < ret_var.datalen; x++) {
13734                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
13735                 *ret_conv_49_ref = ret_var.data[x];
13736                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
13737         }
13738         FREE(ret_var.data);
13739         return ret_arr;
13740 }
13741
13742 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) {
13743         LDKChannelMonitor this_arg_conv;
13744         this_arg_conv.inner = (void*)(this_arg & (~1));
13745         this_arg_conv.is_owned = false;
13746         unsigned char header_arr[80];
13747         CHECK(*((uint32_t*)header) == 80);
13748         memcpy(header_arr, (uint8_t*)(header + 4), 80);
13749         unsigned char (*header_ref)[80] = &header_arr;
13750         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13751         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13752         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13753         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
13754 }
13755
13756 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) {
13757         LDKChannelMonitor this_arg_conv;
13758         this_arg_conv.inner = (void*)(this_arg & (~1));
13759         this_arg_conv.is_owned = false;
13760         unsigned char header_arr[80];
13761         CHECK(*((uint32_t*)header) == 80);
13762         memcpy(header_arr, (uint8_t*)(header + 4), 80);
13763         unsigned char (*header_ref)[80] = &header_arr;
13764         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
13765         txdata_constr.datalen = *((uint32_t*)txdata);
13766         if (txdata_constr.datalen > 0)
13767                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13768         else
13769                 txdata_constr.data = NULL;
13770         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
13771         for (size_t e = 0; e < txdata_constr.datalen; e++) {
13772                 uint32_t txdata_conv_30 = txdata_vals[e];
13773                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
13774                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
13775                 txdata_constr.data[e] = txdata_conv_30_conv;
13776         }
13777         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13778         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13779         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13780         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);
13781         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13782         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13783         for (size_t x = 0; x < ret_var.datalen; x++) {
13784                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
13785                 *ret_conv_49_ref = ret_var.data[x];
13786                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
13787         }
13788         FREE(ret_var.data);
13789         return ret_arr;
13790 }
13791
13792 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) {
13793         LDKChannelMonitor this_arg_conv;
13794         this_arg_conv.inner = (void*)(this_arg & (~1));
13795         this_arg_conv.is_owned = false;
13796         unsigned char txid_arr[32];
13797         CHECK(*((uint32_t*)txid) == 32);
13798         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
13799         unsigned char (*txid_ref)[32] = &txid_arr;
13800         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13801         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13802         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13803         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
13804 }
13805
13806 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) {
13807         LDKChannelMonitor this_arg_conv;
13808         this_arg_conv.inner = (void*)(this_arg & (~1));
13809         this_arg_conv.is_owned = false;
13810         unsigned char header_arr[80];
13811         CHECK(*((uint32_t*)header) == 80);
13812         memcpy(header_arr, (uint8_t*)(header + 4), 80);
13813         unsigned char (*header_ref)[80] = &header_arr;
13814         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13815         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13816         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13817         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
13818         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13819         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13820         for (size_t x = 0; x < ret_var.datalen; x++) {
13821                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
13822                 *ret_conv_49_ref = ret_var.data[x];
13823                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
13824         }
13825         FREE(ret_var.data);
13826         return ret_arr;
13827 }
13828
13829 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
13830         LDKChannelMonitor this_arg_conv;
13831         this_arg_conv.inner = (void*)(this_arg & (~1));
13832         this_arg_conv.is_owned = false;
13833         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
13834         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
13835         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
13836         for (size_t m = 0; m < ret_var.datalen; m++) {
13837                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13838                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
13839                 ret_arr_ptr[m] = ret_conv_12_arr;
13840         }
13841         FREE(ret_var.data);
13842         return ret_arr;
13843 }
13844
13845 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
13846         LDKChannelMonitor this_arg_conv;
13847         this_arg_conv.inner = (void*)(this_arg & (~1));
13848         this_arg_conv.is_owned = false;
13849         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
13850         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13851         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13852         uint64_t ret_ref = (uint64_t)ret_var.inner;
13853         if (ret_var.is_owned) {
13854                 ret_ref |= 1;
13855         }
13856         return ret_ref;
13857 }
13858
13859 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
13860         LDKChannelMonitor this_arg_conv;
13861         this_arg_conv.inner = (void*)(this_arg & (~1));
13862         this_arg_conv.is_owned = false;
13863         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
13864         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13865         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13866         for (size_t j = 0; j < ret_var.datalen; j++) {
13867                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13868                 *ret_conv_9_copy = Balance_clone(&ret_var.data[j]);
13869                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
13870                 ret_arr_ptr[j] = ret_conv_9_ref;
13871         }
13872         FREE(ret_var.data);
13873         return ret_arr;
13874 }
13875
13876 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
13877         if ((this_ptr & 1) != 0) return;
13878         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
13879         FREE((void*)this_ptr);
13880         Persist_free(this_ptr_conv);
13881 }
13882
13883 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
13884         LDKu8slice ser_ref;
13885         ser_ref.datalen = *((uint32_t*)ser);
13886         ser_ref.data = (int8_t*)(ser + 4);
13887         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
13888         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
13889         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
13890         return (uint64_t)ret_conv;
13891 }
13892
13893 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
13894         LDKOutPoint this_obj_conv;
13895         this_obj_conv.inner = (void*)(this_obj & (~1));
13896         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13897         OutPoint_free(this_obj_conv);
13898 }
13899
13900 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
13901         LDKOutPoint this_ptr_conv;
13902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13903         this_ptr_conv.is_owned = false;
13904         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13905         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
13906         return ret_arr;
13907 }
13908
13909 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
13910         LDKOutPoint this_ptr_conv;
13911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13912         this_ptr_conv.is_owned = false;
13913         LDKThirtyTwoBytes val_ref;
13914         CHECK(*((uint32_t*)val) == 32);
13915         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13916         OutPoint_set_txid(&this_ptr_conv, val_ref);
13917 }
13918
13919 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
13920         LDKOutPoint this_ptr_conv;
13921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13922         this_ptr_conv.is_owned = false;
13923         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
13924         return ret_val;
13925 }
13926
13927 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
13928         LDKOutPoint this_ptr_conv;
13929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13930         this_ptr_conv.is_owned = false;
13931         OutPoint_set_index(&this_ptr_conv, val);
13932 }
13933
13934 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
13935         LDKThirtyTwoBytes txid_arg_ref;
13936         CHECK(*((uint32_t*)txid_arg) == 32);
13937         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
13938         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
13939         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13940         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13941         uint64_t ret_ref = (uint64_t)ret_var.inner;
13942         if (ret_var.is_owned) {
13943                 ret_ref |= 1;
13944         }
13945         return ret_ref;
13946 }
13947
13948 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
13949         LDKOutPoint orig_conv;
13950         orig_conv.inner = (void*)(orig & (~1));
13951         orig_conv.is_owned = false;
13952         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
13953         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13954         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13955         uint64_t ret_ref = (uint64_t)ret_var.inner;
13956         if (ret_var.is_owned) {
13957                 ret_ref |= 1;
13958         }
13959         return ret_ref;
13960 }
13961
13962 jboolean  __attribute__((visibility("default"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
13963         LDKOutPoint a_conv;
13964         a_conv.inner = (void*)(a & (~1));
13965         a_conv.is_owned = false;
13966         LDKOutPoint b_conv;
13967         b_conv.inner = (void*)(b & (~1));
13968         b_conv.is_owned = false;
13969         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
13970         return ret_val;
13971 }
13972
13973 int64_t  __attribute__((visibility("default"))) TS_OutPoint_hash(uint32_t o) {
13974         LDKOutPoint o_conv;
13975         o_conv.inner = (void*)(o & (~1));
13976         o_conv.is_owned = false;
13977         int64_t ret_val = OutPoint_hash(&o_conv);
13978         return ret_val;
13979 }
13980
13981 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
13982         LDKOutPoint this_arg_conv;
13983         this_arg_conv.inner = (void*)(this_arg & (~1));
13984         this_arg_conv.is_owned = false;
13985         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13986         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
13987         return ret_arr;
13988 }
13989
13990 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
13991         LDKOutPoint obj_conv;
13992         obj_conv.inner = (void*)(obj & (~1));
13993         obj_conv.is_owned = false;
13994         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
13995         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13996         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13997         CVec_u8Z_free(ret_var);
13998         return ret_arr;
13999 }
14000
14001 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
14002         LDKu8slice ser_ref;
14003         ser_ref.datalen = *((uint32_t*)ser);
14004         ser_ref.data = (int8_t*)(ser + 4);
14005         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14006         *ret_conv = OutPoint_read(ser_ref);
14007         return (uint64_t)ret_conv;
14008 }
14009
14010 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
14011         LDKDelayedPaymentOutputDescriptor this_obj_conv;
14012         this_obj_conv.inner = (void*)(this_obj & (~1));
14013         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14014         DelayedPaymentOutputDescriptor_free(this_obj_conv);
14015 }
14016
14017 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
14018         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14020         this_ptr_conv.is_owned = false;
14021         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14022         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14023         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14024         uint64_t ret_ref = (uint64_t)ret_var.inner;
14025         if (ret_var.is_owned) {
14026                 ret_ref |= 1;
14027         }
14028         return ret_ref;
14029 }
14030
14031 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
14032         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14034         this_ptr_conv.is_owned = false;
14035         LDKOutPoint val_conv;
14036         val_conv.inner = (void*)(val & (~1));
14037         val_conv.is_owned = (val & 1) || (val == 0);
14038         val_conv = OutPoint_clone(&val_conv);
14039         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14040 }
14041
14042 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
14043         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14045         this_ptr_conv.is_owned = false;
14046         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14047         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14048         return ret_arr;
14049 }
14050
14051 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14052         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14054         this_ptr_conv.is_owned = false;
14055         LDKPublicKey val_ref;
14056         CHECK(*((uint32_t*)val) == 33);
14057         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14058         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
14059 }
14060
14061 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
14062         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14064         this_ptr_conv.is_owned = false;
14065         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
14066         return ret_val;
14067 }
14068
14069 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
14070         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14072         this_ptr_conv.is_owned = false;
14073         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
14074 }
14075
14076 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
14077         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14079         this_ptr_conv.is_owned = false;
14080         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14081         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
14082         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14083 }
14084
14085 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
14086         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14088         this_ptr_conv.is_owned = false;
14089         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14090         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
14091         return ret_arr;
14092 }
14093
14094 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
14095         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14097         this_ptr_conv.is_owned = false;
14098         LDKPublicKey val_ref;
14099         CHECK(*((uint32_t*)val) == 33);
14100         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14101         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
14102 }
14103
14104 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
14105         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14107         this_ptr_conv.is_owned = false;
14108         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14109         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
14110         return ret_arr;
14111 }
14112
14113 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
14114         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14116         this_ptr_conv.is_owned = false;
14117         LDKThirtyTwoBytes val_ref;
14118         CHECK(*((uint32_t*)val) == 32);
14119         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14120         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
14121 }
14122
14123 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
14124         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14126         this_ptr_conv.is_owned = false;
14127         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
14128         return ret_val;
14129 }
14130
14131 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
14132         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14134         this_ptr_conv.is_owned = false;
14135         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
14136 }
14137
14138 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) {
14139         LDKOutPoint outpoint_arg_conv;
14140         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14141         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14142         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14143         LDKPublicKey per_commitment_point_arg_ref;
14144         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
14145         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
14146         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
14147         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
14148         LDKPublicKey revocation_pubkey_arg_ref;
14149         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
14150         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
14151         LDKThirtyTwoBytes channel_keys_id_arg_ref;
14152         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
14153         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
14154         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);
14155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14157         uint64_t ret_ref = (uint64_t)ret_var.inner;
14158         if (ret_var.is_owned) {
14159                 ret_ref |= 1;
14160         }
14161         return ret_ref;
14162 }
14163
14164 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
14165         LDKDelayedPaymentOutputDescriptor orig_conv;
14166         orig_conv.inner = (void*)(orig & (~1));
14167         orig_conv.is_owned = false;
14168         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
14169         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14170         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14171         uint64_t ret_ref = (uint64_t)ret_var.inner;
14172         if (ret_var.is_owned) {
14173                 ret_ref |= 1;
14174         }
14175         return ret_ref;
14176 }
14177
14178 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
14179         LDKDelayedPaymentOutputDescriptor obj_conv;
14180         obj_conv.inner = (void*)(obj & (~1));
14181         obj_conv.is_owned = false;
14182         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
14183         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14184         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14185         CVec_u8Z_free(ret_var);
14186         return ret_arr;
14187 }
14188
14189 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
14190         LDKu8slice ser_ref;
14191         ser_ref.datalen = *((uint32_t*)ser);
14192         ser_ref.data = (int8_t*)(ser + 4);
14193         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14194         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
14195         return (uint64_t)ret_conv;
14196 }
14197
14198 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
14199         LDKStaticPaymentOutputDescriptor this_obj_conv;
14200         this_obj_conv.inner = (void*)(this_obj & (~1));
14201         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14202         StaticPaymentOutputDescriptor_free(this_obj_conv);
14203 }
14204
14205 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
14206         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14208         this_ptr_conv.is_owned = false;
14209         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14210         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14211         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14212         uint64_t ret_ref = (uint64_t)ret_var.inner;
14213         if (ret_var.is_owned) {
14214                 ret_ref |= 1;
14215         }
14216         return ret_ref;
14217 }
14218
14219 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
14220         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14222         this_ptr_conv.is_owned = false;
14223         LDKOutPoint val_conv;
14224         val_conv.inner = (void*)(val & (~1));
14225         val_conv.is_owned = (val & 1) || (val == 0);
14226         val_conv = OutPoint_clone(&val_conv);
14227         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14228 }
14229
14230 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
14231         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14233         this_ptr_conv.is_owned = false;
14234         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14235         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
14236         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14237 }
14238
14239 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
14240         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14242         this_ptr_conv.is_owned = false;
14243         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14244         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
14245         return ret_arr;
14246 }
14247
14248 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
14249         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14251         this_ptr_conv.is_owned = false;
14252         LDKThirtyTwoBytes val_ref;
14253         CHECK(*((uint32_t*)val) == 32);
14254         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14255         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
14256 }
14257
14258 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
14259         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14261         this_ptr_conv.is_owned = false;
14262         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
14263         return ret_val;
14264 }
14265
14266 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
14267         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14269         this_ptr_conv.is_owned = false;
14270         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
14271 }
14272
14273 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) {
14274         LDKOutPoint outpoint_arg_conv;
14275         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14276         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14277         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14278         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
14279         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
14280         LDKThirtyTwoBytes channel_keys_id_arg_ref;
14281         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
14282         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
14283         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
14284         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14285         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14286         uint64_t ret_ref = (uint64_t)ret_var.inner;
14287         if (ret_var.is_owned) {
14288                 ret_ref |= 1;
14289         }
14290         return ret_ref;
14291 }
14292
14293 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
14294         LDKStaticPaymentOutputDescriptor orig_conv;
14295         orig_conv.inner = (void*)(orig & (~1));
14296         orig_conv.is_owned = false;
14297         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
14298         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14299         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14300         uint64_t ret_ref = (uint64_t)ret_var.inner;
14301         if (ret_var.is_owned) {
14302                 ret_ref |= 1;
14303         }
14304         return ret_ref;
14305 }
14306
14307 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
14308         LDKStaticPaymentOutputDescriptor obj_conv;
14309         obj_conv.inner = (void*)(obj & (~1));
14310         obj_conv.is_owned = false;
14311         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
14312         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14313         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14314         CVec_u8Z_free(ret_var);
14315         return ret_arr;
14316 }
14317
14318 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
14319         LDKu8slice ser_ref;
14320         ser_ref.datalen = *((uint32_t*)ser);
14321         ser_ref.data = (int8_t*)(ser + 4);
14322         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14323         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
14324         return (uint64_t)ret_conv;
14325 }
14326
14327 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
14328         if ((this_ptr & 1) != 0) return;
14329         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
14330         FREE((void*)this_ptr);
14331         SpendableOutputDescriptor_free(this_ptr_conv);
14332 }
14333
14334 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
14335         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
14336         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
14337         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
14338         uint64_t ret_ref = (uint64_t)ret_copy;
14339         return ret_ref;
14340 }
14341
14342 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
14343         LDKOutPoint outpoint_conv;
14344         outpoint_conv.inner = (void*)(outpoint & (~1));
14345         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
14346         outpoint_conv = OutPoint_clone(&outpoint_conv);
14347         LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
14348         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
14349         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
14350         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
14351         uint64_t ret_ref = (uint64_t)ret_copy;
14352         return ret_ref;
14353 }
14354
14355 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
14356         LDKDelayedPaymentOutputDescriptor a_conv;
14357         a_conv.inner = (void*)(a & (~1));
14358         a_conv.is_owned = (a & 1) || (a == 0);
14359         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
14360         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
14361         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
14362         uint64_t ret_ref = (uint64_t)ret_copy;
14363         return ret_ref;
14364 }
14365
14366 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
14367         LDKStaticPaymentOutputDescriptor a_conv;
14368         a_conv.inner = (void*)(a & (~1));
14369         a_conv.is_owned = (a & 1) || (a == 0);
14370         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
14371         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
14372         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
14373         uint64_t ret_ref = (uint64_t)ret_copy;
14374         return ret_ref;
14375 }
14376
14377 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
14378         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
14379         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
14380         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14381         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14382         CVec_u8Z_free(ret_var);
14383         return ret_arr;
14384 }
14385
14386 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
14387         LDKu8slice ser_ref;
14388         ser_ref.datalen = *((uint32_t*)ser);
14389         ser_ref.data = (int8_t*)(ser + 4);
14390         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14391         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
14392         return (uint64_t)ret_conv;
14393 }
14394
14395 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
14396         if ((this_ptr & 1) != 0) return;
14397         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
14398         FREE((void*)this_ptr);
14399         BaseSign_free(this_ptr_conv);
14400 }
14401
14402 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
14403         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
14404         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
14405         *ret_ret = Sign_clone(orig_conv);
14406         return (uint64_t)ret_ret;
14407 }
14408
14409 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
14410         if ((this_ptr & 1) != 0) return;
14411         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
14412         FREE((void*)this_ptr);
14413         Sign_free(this_ptr_conv);
14414 }
14415
14416 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
14417         if ((this_ptr & 1) != 0) return;
14418         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
14419         FREE((void*)this_ptr);
14420         KeysInterface_free(this_ptr_conv);
14421 }
14422
14423 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
14424         LDKInMemorySigner this_obj_conv;
14425         this_obj_conv.inner = (void*)(this_obj & (~1));
14426         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14427         InMemorySigner_free(this_obj_conv);
14428 }
14429
14430 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
14431         LDKInMemorySigner this_ptr_conv;
14432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14433         this_ptr_conv.is_owned = false;
14434         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14435         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
14436         return ret_arr;
14437 }
14438
14439 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
14440         LDKInMemorySigner this_ptr_conv;
14441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14442         this_ptr_conv.is_owned = false;
14443         LDKSecretKey val_ref;
14444         CHECK(*((uint32_t*)val) == 32);
14445         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
14446         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
14447 }
14448
14449 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
14450         LDKInMemorySigner this_ptr_conv;
14451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14452         this_ptr_conv.is_owned = false;
14453         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14454         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
14455         return ret_arr;
14456 }
14457
14458 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
14459         LDKInMemorySigner this_ptr_conv;
14460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14461         this_ptr_conv.is_owned = false;
14462         LDKSecretKey val_ref;
14463         CHECK(*((uint32_t*)val) == 32);
14464         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
14465         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
14466 }
14467
14468 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
14469         LDKInMemorySigner this_ptr_conv;
14470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14471         this_ptr_conv.is_owned = false;
14472         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14473         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
14474         return ret_arr;
14475 }
14476
14477 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
14478         LDKInMemorySigner this_ptr_conv;
14479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14480         this_ptr_conv.is_owned = false;
14481         LDKSecretKey val_ref;
14482         CHECK(*((uint32_t*)val) == 32);
14483         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
14484         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
14485 }
14486
14487 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
14488         LDKInMemorySigner this_ptr_conv;
14489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14490         this_ptr_conv.is_owned = false;
14491         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14492         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
14493         return ret_arr;
14494 }
14495
14496 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
14497         LDKInMemorySigner this_ptr_conv;
14498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14499         this_ptr_conv.is_owned = false;
14500         LDKSecretKey val_ref;
14501         CHECK(*((uint32_t*)val) == 32);
14502         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
14503         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
14504 }
14505
14506 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
14507         LDKInMemorySigner this_ptr_conv;
14508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14509         this_ptr_conv.is_owned = false;
14510         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14511         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
14512         return ret_arr;
14513 }
14514
14515 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
14516         LDKInMemorySigner this_ptr_conv;
14517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14518         this_ptr_conv.is_owned = false;
14519         LDKSecretKey val_ref;
14520         CHECK(*((uint32_t*)val) == 32);
14521         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
14522         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
14523 }
14524
14525 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
14526         LDKInMemorySigner this_ptr_conv;
14527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14528         this_ptr_conv.is_owned = false;
14529         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14530         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
14531         return ret_arr;
14532 }
14533
14534 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
14535         LDKInMemorySigner this_ptr_conv;
14536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14537         this_ptr_conv.is_owned = false;
14538         LDKThirtyTwoBytes val_ref;
14539         CHECK(*((uint32_t*)val) == 32);
14540         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14541         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
14542 }
14543
14544 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
14545         LDKInMemorySigner orig_conv;
14546         orig_conv.inner = (void*)(orig & (~1));
14547         orig_conv.is_owned = false;
14548         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
14549         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14550         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14551         uint64_t ret_ref = (uint64_t)ret_var.inner;
14552         if (ret_var.is_owned) {
14553                 ret_ref |= 1;
14554         }
14555         return ret_ref;
14556 }
14557
14558 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) {
14559         LDKSecretKey funding_key_ref;
14560         CHECK(*((uint32_t*)funding_key) == 32);
14561         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
14562         LDKSecretKey revocation_base_key_ref;
14563         CHECK(*((uint32_t*)revocation_base_key) == 32);
14564         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
14565         LDKSecretKey payment_key_ref;
14566         CHECK(*((uint32_t*)payment_key) == 32);
14567         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
14568         LDKSecretKey delayed_payment_base_key_ref;
14569         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
14570         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
14571         LDKSecretKey htlc_base_key_ref;
14572         CHECK(*((uint32_t*)htlc_base_key) == 32);
14573         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
14574         LDKThirtyTwoBytes commitment_seed_ref;
14575         CHECK(*((uint32_t*)commitment_seed) == 32);
14576         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
14577         LDKThirtyTwoBytes channel_keys_id_ref;
14578         CHECK(*((uint32_t*)channel_keys_id) == 32);
14579         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
14580         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);
14581         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14582         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14583         uint64_t ret_ref = (uint64_t)ret_var.inner;
14584         if (ret_var.is_owned) {
14585                 ret_ref |= 1;
14586         }
14587         return ret_ref;
14588 }
14589
14590 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
14591         LDKInMemorySigner this_arg_conv;
14592         this_arg_conv.inner = (void*)(this_arg & (~1));
14593         this_arg_conv.is_owned = false;
14594         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
14595         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14596         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14597         uint64_t ret_ref = (uint64_t)ret_var.inner;
14598         if (ret_var.is_owned) {
14599                 ret_ref |= 1;
14600         }
14601         return ret_ref;
14602 }
14603
14604 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
14605         LDKInMemorySigner this_arg_conv;
14606         this_arg_conv.inner = (void*)(this_arg & (~1));
14607         this_arg_conv.is_owned = false;
14608         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
14609         return ret_val;
14610 }
14611
14612 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
14613         LDKInMemorySigner this_arg_conv;
14614         this_arg_conv.inner = (void*)(this_arg & (~1));
14615         this_arg_conv.is_owned = false;
14616         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
14617         return ret_val;
14618 }
14619
14620 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
14621         LDKInMemorySigner this_arg_conv;
14622         this_arg_conv.inner = (void*)(this_arg & (~1));
14623         this_arg_conv.is_owned = false;
14624         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
14625         return ret_val;
14626 }
14627
14628 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
14629         LDKInMemorySigner this_arg_conv;
14630         this_arg_conv.inner = (void*)(this_arg & (~1));
14631         this_arg_conv.is_owned = false;
14632         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
14633         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14634         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14635         uint64_t ret_ref = (uint64_t)ret_var.inner;
14636         if (ret_var.is_owned) {
14637                 ret_ref |= 1;
14638         }
14639         return ret_ref;
14640 }
14641
14642 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
14643         LDKInMemorySigner this_arg_conv;
14644         this_arg_conv.inner = (void*)(this_arg & (~1));
14645         this_arg_conv.is_owned = false;
14646         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
14647         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14648         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14649         uint64_t ret_ref = (uint64_t)ret_var.inner;
14650         if (ret_var.is_owned) {
14651                 ret_ref |= 1;
14652         }
14653         return ret_ref;
14654 }
14655
14656 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) {
14657         LDKInMemorySigner this_arg_conv;
14658         this_arg_conv.inner = (void*)(this_arg & (~1));
14659         this_arg_conv.is_owned = false;
14660         LDKTransaction spend_tx_ref;
14661         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
14662         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
14663         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
14664         spend_tx_ref.data_is_owned = true;
14665         LDKStaticPaymentOutputDescriptor descriptor_conv;
14666         descriptor_conv.inner = (void*)(descriptor & (~1));
14667         descriptor_conv.is_owned = false;
14668         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
14669         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
14670         return (uint64_t)ret_conv;
14671 }
14672
14673 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) {
14674         LDKInMemorySigner this_arg_conv;
14675         this_arg_conv.inner = (void*)(this_arg & (~1));
14676         this_arg_conv.is_owned = false;
14677         LDKTransaction spend_tx_ref;
14678         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
14679         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
14680         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
14681         spend_tx_ref.data_is_owned = true;
14682         LDKDelayedPaymentOutputDescriptor descriptor_conv;
14683         descriptor_conv.inner = (void*)(descriptor & (~1));
14684         descriptor_conv.is_owned = false;
14685         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
14686         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
14687         return (uint64_t)ret_conv;
14688 }
14689
14690 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
14691         LDKInMemorySigner this_arg_conv;
14692         this_arg_conv.inner = (void*)(this_arg & (~1));
14693         this_arg_conv.is_owned = false;
14694         LDKBaseSign* ret_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
14695         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
14696         return (uint64_t)ret_ret;
14697 }
14698
14699 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
14700         LDKInMemorySigner this_arg_conv;
14701         this_arg_conv.inner = (void*)(this_arg & (~1));
14702         this_arg_conv.is_owned = false;
14703         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
14704         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
14705         return (uint64_t)ret_ret;
14706 }
14707
14708 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
14709         LDKInMemorySigner obj_conv;
14710         obj_conv.inner = (void*)(obj & (~1));
14711         obj_conv.is_owned = false;
14712         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
14713         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14714         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14715         CVec_u8Z_free(ret_var);
14716         return ret_arr;
14717 }
14718
14719 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
14720         LDKu8slice ser_ref;
14721         ser_ref.datalen = *((uint32_t*)ser);
14722         ser_ref.data = (int8_t*)(ser + 4);
14723         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
14724         *ret_conv = InMemorySigner_read(ser_ref);
14725         return (uint64_t)ret_conv;
14726 }
14727
14728 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
14729         LDKKeysManager this_obj_conv;
14730         this_obj_conv.inner = (void*)(this_obj & (~1));
14731         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14732         KeysManager_free(this_obj_conv);
14733 }
14734
14735 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
14736         unsigned char seed_arr[32];
14737         CHECK(*((uint32_t*)seed) == 32);
14738         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
14739         unsigned char (*seed_ref)[32] = &seed_arr;
14740         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
14741         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14742         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14743         uint64_t ret_ref = (uint64_t)ret_var.inner;
14744         if (ret_var.is_owned) {
14745                 ret_ref |= 1;
14746         }
14747         return ret_ref;
14748 }
14749
14750 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
14751         LDKKeysManager this_arg_conv;
14752         this_arg_conv.inner = (void*)(this_arg & (~1));
14753         this_arg_conv.is_owned = false;
14754         unsigned char params_arr[32];
14755         CHECK(*((uint32_t*)params) == 32);
14756         memcpy(params_arr, (uint8_t*)(params + 4), 32);
14757         unsigned char (*params_ref)[32] = &params_arr;
14758         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
14759         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14760         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14761         uint64_t ret_ref = (uint64_t)ret_var.inner;
14762         if (ret_var.is_owned) {
14763                 ret_ref |= 1;
14764         }
14765         return ret_ref;
14766 }
14767
14768 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) {
14769         LDKKeysManager this_arg_conv;
14770         this_arg_conv.inner = (void*)(this_arg & (~1));
14771         this_arg_conv.is_owned = false;
14772         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
14773         descriptors_constr.datalen = *((uint32_t*)descriptors);
14774         if (descriptors_constr.datalen > 0)
14775                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
14776         else
14777                 descriptors_constr.data = NULL;
14778         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
14779         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
14780                 uint32_t descriptors_conv_27 = descriptors_vals[b];
14781                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
14782                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
14783                 descriptors_constr.data[b] = descriptors_conv_27_conv;
14784         }
14785         LDKCVec_TxOutZ outputs_constr;
14786         outputs_constr.datalen = *((uint32_t*)outputs);
14787         if (outputs_constr.datalen > 0)
14788                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
14789         else
14790                 outputs_constr.data = NULL;
14791         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
14792         for (size_t h = 0; h < outputs_constr.datalen; h++) {
14793                 uint32_t outputs_conv_7 = outputs_vals[h];
14794                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
14795                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
14796                 outputs_constr.data[h] = outputs_conv_7_conv;
14797         }
14798         LDKCVec_u8Z change_destination_script_ref;
14799         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
14800         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
14801         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
14802         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
14803         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
14804         return (uint64_t)ret_conv;
14805 }
14806
14807 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
14808         LDKKeysManager this_arg_conv;
14809         this_arg_conv.inner = (void*)(this_arg & (~1));
14810         this_arg_conv.is_owned = false;
14811         LDKKeysInterface* ret_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
14812         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
14813         return (uint64_t)ret_ret;
14814 }
14815
14816 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
14817         LDKChannelManager this_obj_conv;
14818         this_obj_conv.inner = (void*)(this_obj & (~1));
14819         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14820         ChannelManager_free(this_obj_conv);
14821 }
14822
14823 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
14824         LDKChainParameters this_obj_conv;
14825         this_obj_conv.inner = (void*)(this_obj & (~1));
14826         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14827         ChainParameters_free(this_obj_conv);
14828 }
14829
14830 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
14831         LDKChainParameters this_ptr_conv;
14832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14833         this_ptr_conv.is_owned = false;
14834         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
14835         return ret_conv;
14836 }
14837
14838 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
14839         LDKChainParameters this_ptr_conv;
14840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14841         this_ptr_conv.is_owned = false;
14842         LDKNetwork val_conv = LDKNetwork_from_js(val);
14843         ChainParameters_set_network(&this_ptr_conv, val_conv);
14844 }
14845
14846 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
14847         LDKChainParameters this_ptr_conv;
14848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14849         this_ptr_conv.is_owned = false;
14850         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
14851         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14852         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14853         uint64_t ret_ref = (uint64_t)ret_var.inner;
14854         if (ret_var.is_owned) {
14855                 ret_ref |= 1;
14856         }
14857         return ret_ref;
14858 }
14859
14860 void  __attribute__((visibility("default"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
14861         LDKChainParameters this_ptr_conv;
14862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14863         this_ptr_conv.is_owned = false;
14864         LDKBestBlock val_conv;
14865         val_conv.inner = (void*)(val & (~1));
14866         val_conv.is_owned = (val & 1) || (val == 0);
14867         val_conv = BestBlock_clone(&val_conv);
14868         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
14869 }
14870
14871 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
14872         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
14873         LDKBestBlock best_block_arg_conv;
14874         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
14875         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
14876         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
14877         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
14878         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14879         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14880         uint64_t ret_ref = (uint64_t)ret_var.inner;
14881         if (ret_var.is_owned) {
14882                 ret_ref |= 1;
14883         }
14884         return ret_ref;
14885 }
14886
14887 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32_t orig) {
14888         LDKChainParameters orig_conv;
14889         orig_conv.inner = (void*)(orig & (~1));
14890         orig_conv.is_owned = false;
14891         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
14892         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14893         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14894         uint64_t ret_ref = (uint64_t)ret_var.inner;
14895         if (ret_var.is_owned) {
14896                 ret_ref |= 1;
14897         }
14898         return ret_ref;
14899 }
14900
14901 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
14902         LDKCounterpartyForwardingInfo this_obj_conv;
14903         this_obj_conv.inner = (void*)(this_obj & (~1));
14904         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14905         CounterpartyForwardingInfo_free(this_obj_conv);
14906 }
14907
14908 int32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
14909         LDKCounterpartyForwardingInfo this_ptr_conv;
14910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14911         this_ptr_conv.is_owned = false;
14912         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
14913         return ret_val;
14914 }
14915
14916 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
14917         LDKCounterpartyForwardingInfo this_ptr_conv;
14918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14919         this_ptr_conv.is_owned = false;
14920         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
14921 }
14922
14923 int32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
14924         LDKCounterpartyForwardingInfo this_ptr_conv;
14925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14926         this_ptr_conv.is_owned = false;
14927         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
14928         return ret_val;
14929 }
14930
14931 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
14932         LDKCounterpartyForwardingInfo this_ptr_conv;
14933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14934         this_ptr_conv.is_owned = false;
14935         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
14936 }
14937
14938 int16_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
14939         LDKCounterpartyForwardingInfo this_ptr_conv;
14940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14941         this_ptr_conv.is_owned = false;
14942         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
14943         return ret_val;
14944 }
14945
14946 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
14947         LDKCounterpartyForwardingInfo this_ptr_conv;
14948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14949         this_ptr_conv.is_owned = false;
14950         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
14951 }
14952
14953 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_new(int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) {
14954         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
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 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
14965         LDKCounterpartyForwardingInfo orig_conv;
14966         orig_conv.inner = (void*)(orig & (~1));
14967         orig_conv.is_owned = false;
14968         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
14969         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14970         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14971         uint64_t ret_ref = (uint64_t)ret_var.inner;
14972         if (ret_var.is_owned) {
14973                 ret_ref |= 1;
14974         }
14975         return ret_ref;
14976 }
14977
14978 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
14979         LDKChannelCounterparty this_obj_conv;
14980         this_obj_conv.inner = (void*)(this_obj & (~1));
14981         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14982         ChannelCounterparty_free(this_obj_conv);
14983 }
14984
14985 int8_tArray  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
14986         LDKChannelCounterparty this_ptr_conv;
14987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14988         this_ptr_conv.is_owned = false;
14989         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14990         memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
14991         return ret_arr;
14992 }
14993
14994 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
14995         LDKChannelCounterparty this_ptr_conv;
14996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14997         this_ptr_conv.is_owned = false;
14998         LDKPublicKey val_ref;
14999         CHECK(*((uint32_t*)val) == 33);
15000         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15001         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
15002 }
15003
15004 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
15005         LDKChannelCounterparty this_ptr_conv;
15006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15007         this_ptr_conv.is_owned = false;
15008         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
15009         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15010         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15011         uint64_t ret_ref = (uint64_t)ret_var.inner;
15012         if (ret_var.is_owned) {
15013                 ret_ref |= 1;
15014         }
15015         return ret_ref;
15016 }
15017
15018 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
15019         LDKChannelCounterparty this_ptr_conv;
15020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15021         this_ptr_conv.is_owned = false;
15022         LDKInitFeatures val_conv;
15023         val_conv.inner = (void*)(val & (~1));
15024         val_conv.is_owned = (val & 1) || (val == 0);
15025         val_conv = InitFeatures_clone(&val_conv);
15026         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
15027 }
15028
15029 int64_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
15030         LDKChannelCounterparty this_ptr_conv;
15031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15032         this_ptr_conv.is_owned = false;
15033         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
15034         return ret_val;
15035 }
15036
15037 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
15038         LDKChannelCounterparty this_ptr_conv;
15039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15040         this_ptr_conv.is_owned = false;
15041         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
15042 }
15043
15044 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
15045         LDKChannelCounterparty this_ptr_conv;
15046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15047         this_ptr_conv.is_owned = false;
15048         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
15049         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15050         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15051         uint64_t ret_ref = (uint64_t)ret_var.inner;
15052         if (ret_var.is_owned) {
15053                 ret_ref |= 1;
15054         }
15055         return ret_ref;
15056 }
15057
15058 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
15059         LDKChannelCounterparty this_ptr_conv;
15060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15061         this_ptr_conv.is_owned = false;
15062         LDKCounterpartyForwardingInfo val_conv;
15063         val_conv.inner = (void*)(val & (~1));
15064         val_conv.is_owned = (val & 1) || (val == 0);
15065         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
15066         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
15067 }
15068
15069 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_new(int8_tArray node_id_arg, uint32_t features_arg, int64_t unspendable_punishment_reserve_arg, uint32_t forwarding_info_arg) {
15070         LDKPublicKey node_id_arg_ref;
15071         CHECK(*((uint32_t*)node_id_arg) == 33);
15072         memcpy(node_id_arg_ref.compressed_form, (uint8_t*)(node_id_arg + 4), 33);
15073         LDKInitFeatures features_arg_conv;
15074         features_arg_conv.inner = (void*)(features_arg & (~1));
15075         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
15076         features_arg_conv = InitFeatures_clone(&features_arg_conv);
15077         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
15078         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
15079         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
15080         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
15081         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
15082         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15083         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15084         uint64_t ret_ref = (uint64_t)ret_var.inner;
15085         if (ret_var.is_owned) {
15086                 ret_ref |= 1;
15087         }
15088         return ret_ref;
15089 }
15090
15091 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(uint32_t orig) {
15092         LDKChannelCounterparty orig_conv;
15093         orig_conv.inner = (void*)(orig & (~1));
15094         orig_conv.is_owned = false;
15095         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
15096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15098         uint64_t ret_ref = (uint64_t)ret_var.inner;
15099         if (ret_var.is_owned) {
15100                 ret_ref |= 1;
15101         }
15102         return ret_ref;
15103 }
15104
15105 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
15106         LDKChannelDetails this_obj_conv;
15107         this_obj_conv.inner = (void*)(this_obj & (~1));
15108         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15109         ChannelDetails_free(this_obj_conv);
15110 }
15111
15112 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
15113         LDKChannelDetails this_ptr_conv;
15114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15115         this_ptr_conv.is_owned = false;
15116         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15117         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
15118         return ret_arr;
15119 }
15120
15121 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15122         LDKChannelDetails this_ptr_conv;
15123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15124         this_ptr_conv.is_owned = false;
15125         LDKThirtyTwoBytes val_ref;
15126         CHECK(*((uint32_t*)val) == 32);
15127         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15128         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
15129 }
15130
15131 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
15132         LDKChannelDetails this_ptr_conv;
15133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15134         this_ptr_conv.is_owned = false;
15135         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
15136         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15137         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15138         uint64_t ret_ref = (uint64_t)ret_var.inner;
15139         if (ret_var.is_owned) {
15140                 ret_ref |= 1;
15141         }
15142         return ret_ref;
15143 }
15144
15145 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
15146         LDKChannelDetails this_ptr_conv;
15147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15148         this_ptr_conv.is_owned = false;
15149         LDKChannelCounterparty val_conv;
15150         val_conv.inner = (void*)(val & (~1));
15151         val_conv.is_owned = (val & 1) || (val == 0);
15152         val_conv = ChannelCounterparty_clone(&val_conv);
15153         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
15154 }
15155
15156 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
15157         LDKChannelDetails this_ptr_conv;
15158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15159         this_ptr_conv.is_owned = false;
15160         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
15161         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15162         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15163         uint64_t ret_ref = (uint64_t)ret_var.inner;
15164         if (ret_var.is_owned) {
15165                 ret_ref |= 1;
15166         }
15167         return ret_ref;
15168 }
15169
15170 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
15171         LDKChannelDetails this_ptr_conv;
15172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15173         this_ptr_conv.is_owned = false;
15174         LDKOutPoint val_conv;
15175         val_conv.inner = (void*)(val & (~1));
15176         val_conv.is_owned = (val & 1) || (val == 0);
15177         val_conv = OutPoint_clone(&val_conv);
15178         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
15179 }
15180
15181 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
15182         LDKChannelDetails this_ptr_conv;
15183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15184         this_ptr_conv.is_owned = false;
15185         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15186         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
15187         uint64_t ret_ref = (uint64_t)ret_copy;
15188         return ret_ref;
15189 }
15190
15191 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
15192         LDKChannelDetails this_ptr_conv;
15193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15194         this_ptr_conv.is_owned = false;
15195         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
15196         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
15197         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
15198 }
15199
15200 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
15201         LDKChannelDetails this_ptr_conv;
15202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15203         this_ptr_conv.is_owned = false;
15204         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
15205         return ret_val;
15206 }
15207
15208 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
15209         LDKChannelDetails this_ptr_conv;
15210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15211         this_ptr_conv.is_owned = false;
15212         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
15213 }
15214
15215 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
15216         LDKChannelDetails this_ptr_conv;
15217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15218         this_ptr_conv.is_owned = false;
15219         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15220         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
15221         uint64_t ret_ref = (uint64_t)ret_copy;
15222         return ret_ref;
15223 }
15224
15225 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
15226         LDKChannelDetails this_ptr_conv;
15227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15228         this_ptr_conv.is_owned = false;
15229         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
15230         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
15231         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
15232 }
15233
15234 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
15235         LDKChannelDetails this_ptr_conv;
15236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15237         this_ptr_conv.is_owned = false;
15238         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
15239         return ret_val;
15240 }
15241
15242 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
15243         LDKChannelDetails this_ptr_conv;
15244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15245         this_ptr_conv.is_owned = false;
15246         ChannelDetails_set_user_id(&this_ptr_conv, val);
15247 }
15248
15249 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
15250         LDKChannelDetails this_ptr_conv;
15251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15252         this_ptr_conv.is_owned = false;
15253         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
15254         return ret_val;
15255 }
15256
15257 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
15258         LDKChannelDetails this_ptr_conv;
15259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15260         this_ptr_conv.is_owned = false;
15261         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
15262 }
15263
15264 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
15265         LDKChannelDetails this_ptr_conv;
15266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15267         this_ptr_conv.is_owned = false;
15268         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
15269         return ret_val;
15270 }
15271
15272 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
15273         LDKChannelDetails this_ptr_conv;
15274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15275         this_ptr_conv.is_owned = false;
15276         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
15277 }
15278
15279 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
15280         LDKChannelDetails this_ptr_conv;
15281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15282         this_ptr_conv.is_owned = false;
15283         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15284         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
15285         uint64_t ret_ref = (uint64_t)ret_copy;
15286         return ret_ref;
15287 }
15288
15289 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
15290         LDKChannelDetails this_ptr_conv;
15291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15292         this_ptr_conv.is_owned = false;
15293         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
15294         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
15295         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
15296 }
15297
15298 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
15299         LDKChannelDetails this_ptr_conv;
15300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15301         this_ptr_conv.is_owned = false;
15302         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15303         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
15304         uint64_t ret_ref = (uint64_t)ret_copy;
15305         return ret_ref;
15306 }
15307
15308 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_spend_delay(uint32_t this_ptr, uint32_t val) {
15309         LDKChannelDetails this_ptr_conv;
15310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15311         this_ptr_conv.is_owned = false;
15312         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
15313         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
15314         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
15315 }
15316
15317 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
15318         LDKChannelDetails this_ptr_conv;
15319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15320         this_ptr_conv.is_owned = false;
15321         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
15322         return ret_val;
15323 }
15324
15325 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
15326         LDKChannelDetails this_ptr_conv;
15327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15328         this_ptr_conv.is_owned = false;
15329         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
15330 }
15331
15332 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
15333         LDKChannelDetails this_ptr_conv;
15334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15335         this_ptr_conv.is_owned = false;
15336         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
15337         return ret_val;
15338 }
15339
15340 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
15341         LDKChannelDetails this_ptr_conv;
15342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15343         this_ptr_conv.is_owned = false;
15344         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
15345 }
15346
15347 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
15348         LDKChannelDetails this_ptr_conv;
15349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15350         this_ptr_conv.is_owned = false;
15351         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
15352         return ret_val;
15353 }
15354
15355 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
15356         LDKChannelDetails this_ptr_conv;
15357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15358         this_ptr_conv.is_owned = false;
15359         ChannelDetails_set_is_usable(&this_ptr_conv, val);
15360 }
15361
15362 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
15363         LDKChannelDetails this_ptr_conv;
15364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15365         this_ptr_conv.is_owned = false;
15366         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
15367         return ret_val;
15368 }
15369
15370 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
15371         LDKChannelDetails this_ptr_conv;
15372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15373         this_ptr_conv.is_owned = false;
15374         ChannelDetails_set_is_public(&this_ptr_conv, val);
15375 }
15376
15377 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint32_t counterparty_arg, uint32_t funding_txo_arg, uint32_t short_channel_id_arg, int64_t channel_value_satoshis_arg, uint32_t unspendable_punishment_reserve_arg, int64_t user_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, uint32_t confirmations_required_arg, uint32_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
15378         LDKThirtyTwoBytes channel_id_arg_ref;
15379         CHECK(*((uint32_t*)channel_id_arg) == 32);
15380         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15381         LDKChannelCounterparty counterparty_arg_conv;
15382         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
15383         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
15384         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
15385         LDKOutPoint funding_txo_arg_conv;
15386         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
15387         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
15388         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
15389         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
15390         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
15391         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
15392         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
15393         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
15394         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
15395         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
15396         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
15397         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15398         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15399         uint64_t ret_ref = (uint64_t)ret_var.inner;
15400         if (ret_var.is_owned) {
15401                 ret_ref |= 1;
15402         }
15403         return ret_ref;
15404 }
15405
15406 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
15407         LDKChannelDetails orig_conv;
15408         orig_conv.inner = (void*)(orig & (~1));
15409         orig_conv.is_owned = false;
15410         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
15411         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15412         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15413         uint64_t ret_ref = (uint64_t)ret_var.inner;
15414         if (ret_var.is_owned) {
15415                 ret_ref |= 1;
15416         }
15417         return ret_ref;
15418 }
15419
15420 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
15421         if ((this_ptr & 1) != 0) return;
15422         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
15423         FREE((void*)this_ptr);
15424         PaymentSendFailure_free(this_ptr_conv);
15425 }
15426
15427 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
15428         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
15429         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15430         *ret_copy = PaymentSendFailure_clone(orig_conv);
15431         uint64_t ret_ref = (uint64_t)ret_copy;
15432         return ret_ref;
15433 }
15434
15435 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
15436         LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1);
15437         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
15438         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15439         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
15440         uint64_t ret_ref = (uint64_t)ret_copy;
15441         return ret_ref;
15442 }
15443
15444 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
15445         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
15446         a_constr.datalen = *((uint32_t*)a);
15447         if (a_constr.datalen > 0)
15448                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15449         else
15450                 a_constr.data = NULL;
15451         uint32_t* a_vals = (uint32_t*)(a + 4);
15452         for (size_t w = 0; w < a_constr.datalen; w++) {
15453                 uint32_t a_conv_22 = a_vals[w];
15454                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
15455                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
15456                 a_constr.data[w] = a_conv_22_conv;
15457         }
15458         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15459         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
15460         uint64_t ret_ref = (uint64_t)ret_copy;
15461         return ret_ref;
15462 }
15463
15464 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
15465         LDKCVec_APIErrorZ a_constr;
15466         a_constr.datalen = *((uint32_t*)a);
15467         if (a_constr.datalen > 0)
15468                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15469         else
15470                 a_constr.data = NULL;
15471         uint32_t* a_vals = (uint32_t*)(a + 4);
15472         for (size_t k = 0; k < a_constr.datalen; k++) {
15473                 uint32_t a_conv_10 = a_vals[k];
15474                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
15475                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
15476                 a_constr.data[k] = a_conv_10_conv;
15477         }
15478         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15479         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
15480         uint64_t ret_ref = (uint64_t)ret_copy;
15481         return ret_ref;
15482 }
15483
15484 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_partial_failure(uint32_tArray a) {
15485         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
15486         a_constr.datalen = *((uint32_t*)a);
15487         if (a_constr.datalen > 0)
15488                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15489         else
15490                 a_constr.data = NULL;
15491         uint32_t* a_vals = (uint32_t*)(a + 4);
15492         for (size_t w = 0; w < a_constr.datalen; w++) {
15493                 uint32_t a_conv_22 = a_vals[w];
15494                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
15495                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
15496                 a_constr.data[w] = a_conv_22_conv;
15497         }
15498         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15499         *ret_copy = PaymentSendFailure_partial_failure(a_constr);
15500         uint64_t ret_ref = (uint64_t)ret_copy;
15501         return ret_ref;
15502 }
15503
15504 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) {
15505         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
15506         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
15507         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
15508         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15509         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
15510         LDKUserConfig config_conv;
15511         config_conv.inner = (void*)(config & (~1));
15512         config_conv.is_owned = (config & 1) || (config == 0);
15513         config_conv = UserConfig_clone(&config_conv);
15514         LDKChainParameters params_conv;
15515         params_conv.inner = (void*)(params & (~1));
15516         params_conv.is_owned = (params & 1) || (params == 0);
15517         params_conv = ChainParameters_clone(&params_conv);
15518         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
15519         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15520         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15521         uint64_t ret_ref = (uint64_t)ret_var.inner;
15522         if (ret_var.is_owned) {
15523                 ret_ref |= 1;
15524         }
15525         return ret_ref;
15526 }
15527
15528 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
15529         LDKChannelManager this_arg_conv;
15530         this_arg_conv.inner = (void*)(this_arg & (~1));
15531         this_arg_conv.is_owned = false;
15532         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
15533         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15534         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15535         uint64_t ret_ref = (uint64_t)ret_var.inner;
15536         if (ret_var.is_owned) {
15537                 ret_ref |= 1;
15538         }
15539         return ret_ref;
15540 }
15541
15542 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) {
15543         LDKChannelManager this_arg_conv;
15544         this_arg_conv.inner = (void*)(this_arg & (~1));
15545         this_arg_conv.is_owned = false;
15546         LDKPublicKey their_network_key_ref;
15547         CHECK(*((uint32_t*)their_network_key) == 33);
15548         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
15549         LDKUserConfig override_config_conv;
15550         override_config_conv.inner = (void*)(override_config & (~1));
15551         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
15552         override_config_conv = UserConfig_clone(&override_config_conv);
15553         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15554         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
15555         return (uint64_t)ret_conv;
15556 }
15557
15558 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
15559         LDKChannelManager this_arg_conv;
15560         this_arg_conv.inner = (void*)(this_arg & (~1));
15561         this_arg_conv.is_owned = false;
15562         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
15563         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
15564         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
15565         for (size_t q = 0; q < ret_var.datalen; q++) {
15566                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
15567                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15568                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15569                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
15570                 if (ret_conv_16_var.is_owned) {
15571                         ret_conv_16_ref |= 1;
15572                 }
15573                 ret_arr_ptr[q] = ret_conv_16_ref;
15574         }
15575         FREE(ret_var.data);
15576         return ret_arr;
15577 }
15578
15579 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
15580         LDKChannelManager this_arg_conv;
15581         this_arg_conv.inner = (void*)(this_arg & (~1));
15582         this_arg_conv.is_owned = false;
15583         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
15584         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
15585         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
15586         for (size_t q = 0; q < ret_var.datalen; q++) {
15587                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
15588                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15589                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15590                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
15591                 if (ret_conv_16_var.is_owned) {
15592                         ret_conv_16_ref |= 1;
15593                 }
15594                 ret_arr_ptr[q] = ret_conv_16_ref;
15595         }
15596         FREE(ret_var.data);
15597         return ret_arr;
15598 }
15599
15600 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
15601         LDKChannelManager this_arg_conv;
15602         this_arg_conv.inner = (void*)(this_arg & (~1));
15603         this_arg_conv.is_owned = false;
15604         unsigned char channel_id_arr[32];
15605         CHECK(*((uint32_t*)channel_id) == 32);
15606         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
15607         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
15608         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15609         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
15610         return (uint64_t)ret_conv;
15611 }
15612
15613 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel_with_target_feerate(uint32_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) {
15614         LDKChannelManager this_arg_conv;
15615         this_arg_conv.inner = (void*)(this_arg & (~1));
15616         this_arg_conv.is_owned = false;
15617         unsigned char channel_id_arr[32];
15618         CHECK(*((uint32_t*)channel_id) == 32);
15619         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
15620         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
15621         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15622         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
15623         return (uint64_t)ret_conv;
15624 }
15625
15626 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
15627         LDKChannelManager this_arg_conv;
15628         this_arg_conv.inner = (void*)(this_arg & (~1));
15629         this_arg_conv.is_owned = false;
15630         unsigned char channel_id_arr[32];
15631         CHECK(*((uint32_t*)channel_id) == 32);
15632         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
15633         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
15634         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15635         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
15636         return (uint64_t)ret_conv;
15637 }
15638
15639 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
15640         LDKChannelManager this_arg_conv;
15641         this_arg_conv.inner = (void*)(this_arg & (~1));
15642         this_arg_conv.is_owned = false;
15643         ChannelManager_force_close_all_channels(&this_arg_conv);
15644 }
15645
15646 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
15647         LDKChannelManager this_arg_conv;
15648         this_arg_conv.inner = (void*)(this_arg & (~1));
15649         this_arg_conv.is_owned = false;
15650         LDKRoute route_conv;
15651         route_conv.inner = (void*)(route & (~1));
15652         route_conv.is_owned = false;
15653         LDKThirtyTwoBytes payment_hash_ref;
15654         CHECK(*((uint32_t*)payment_hash) == 32);
15655         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
15656         LDKThirtyTwoBytes payment_secret_ref;
15657         CHECK(*((uint32_t*)payment_secret) == 32);
15658         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
15659         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15660         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
15661         return (uint64_t)ret_conv;
15662 }
15663
15664 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_spontaneous_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_preimage) {
15665         LDKChannelManager this_arg_conv;
15666         this_arg_conv.inner = (void*)(this_arg & (~1));
15667         this_arg_conv.is_owned = false;
15668         LDKRoute route_conv;
15669         route_conv.inner = (void*)(route & (~1));
15670         route_conv.is_owned = false;
15671         LDKThirtyTwoBytes payment_preimage_ref;
15672         CHECK(*((uint32_t*)payment_preimage) == 32);
15673         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
15674         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
15675         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
15676         return (uint64_t)ret_conv;
15677 }
15678
15679 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
15680         LDKChannelManager this_arg_conv;
15681         this_arg_conv.inner = (void*)(this_arg & (~1));
15682         this_arg_conv.is_owned = false;
15683         unsigned char temporary_channel_id_arr[32];
15684         CHECK(*((uint32_t*)temporary_channel_id) == 32);
15685         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
15686         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
15687         LDKTransaction funding_transaction_ref;
15688         funding_transaction_ref.datalen = *((uint32_t*)funding_transaction);
15689         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
15690         memcpy(funding_transaction_ref.data, (uint8_t*)(funding_transaction + 4), funding_transaction_ref.datalen);
15691         funding_transaction_ref.data_is_owned = true;
15692         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15693         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
15694         return (uint64_t)ret_conv;
15695 }
15696
15697 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
15698         LDKChannelManager this_arg_conv;
15699         this_arg_conv.inner = (void*)(this_arg & (~1));
15700         this_arg_conv.is_owned = false;
15701         LDKThreeBytes rgb_ref;
15702         CHECK(*((uint32_t*)rgb) == 3);
15703         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
15704         LDKThirtyTwoBytes alias_ref;
15705         CHECK(*((uint32_t*)alias) == 32);
15706         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
15707         LDKCVec_NetAddressZ addresses_constr;
15708         addresses_constr.datalen = *((uint32_t*)addresses);
15709         if (addresses_constr.datalen > 0)
15710                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15711         else
15712                 addresses_constr.data = NULL;
15713         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
15714         for (size_t m = 0; m < addresses_constr.datalen; m++) {
15715                 uint32_t addresses_conv_12 = addresses_vals[m];
15716                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
15717                 addresses_constr.data[m] = addresses_conv_12_conv;
15718         }
15719         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
15720 }
15721
15722 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
15723         LDKChannelManager this_arg_conv;
15724         this_arg_conv.inner = (void*)(this_arg & (~1));
15725         this_arg_conv.is_owned = false;
15726         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
15727 }
15728
15729 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
15730         LDKChannelManager this_arg_conv;
15731         this_arg_conv.inner = (void*)(this_arg & (~1));
15732         this_arg_conv.is_owned = false;
15733         ChannelManager_timer_tick_occurred(&this_arg_conv);
15734 }
15735
15736 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
15737         LDKChannelManager this_arg_conv;
15738         this_arg_conv.inner = (void*)(this_arg & (~1));
15739         this_arg_conv.is_owned = false;
15740         unsigned char payment_hash_arr[32];
15741         CHECK(*((uint32_t*)payment_hash) == 32);
15742         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
15743         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
15744         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
15745         return ret_val;
15746 }
15747
15748 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
15749         LDKChannelManager this_arg_conv;
15750         this_arg_conv.inner = (void*)(this_arg & (~1));
15751         this_arg_conv.is_owned = false;
15752         LDKThirtyTwoBytes payment_preimage_ref;
15753         CHECK(*((uint32_t*)payment_preimage) == 32);
15754         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
15755         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
15756         return ret_val;
15757 }
15758
15759 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
15760         LDKChannelManager this_arg_conv;
15761         this_arg_conv.inner = (void*)(this_arg & (~1));
15762         this_arg_conv.is_owned = false;
15763         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15764         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
15765         return ret_arr;
15766 }
15767
15768 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
15769         LDKChannelManager this_arg_conv;
15770         this_arg_conv.inner = (void*)(this_arg & (~1));
15771         this_arg_conv.is_owned = false;
15772         LDKOutPoint funding_txo_conv;
15773         funding_txo_conv.inner = (void*)(funding_txo & (~1));
15774         funding_txo_conv.is_owned = false;
15775         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
15776 }
15777
15778 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) {
15779         LDKChannelManager this_arg_conv;
15780         this_arg_conv.inner = (void*)(this_arg & (~1));
15781         this_arg_conv.is_owned = false;
15782         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
15783         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
15784         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15785         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
15786         return (uint64_t)ret_ref;
15787 }
15788
15789 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) {
15790         LDKChannelManager this_arg_conv;
15791         this_arg_conv.inner = (void*)(this_arg & (~1));
15792         this_arg_conv.is_owned = false;
15793         LDKThirtyTwoBytes payment_hash_ref;
15794         CHECK(*((uint32_t*)payment_hash) == 32);
15795         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
15796         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
15797         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
15798         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15799         *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);
15800         return (uint64_t)ret_conv;
15801 }
15802
15803 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
15804         LDKChannelManager this_arg_conv;
15805         this_arg_conv.inner = (void*)(this_arg & (~1));
15806         this_arg_conv.is_owned = false;
15807         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
15808         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
15809         return (uint64_t)ret_ret;
15810 }
15811
15812 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
15813         LDKChannelManager this_arg_conv;
15814         this_arg_conv.inner = (void*)(this_arg & (~1));
15815         this_arg_conv.is_owned = false;
15816         LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
15817         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
15818         return (uint64_t)ret_ret;
15819 }
15820
15821 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
15822         LDKChannelManager this_arg_conv;
15823         this_arg_conv.inner = (void*)(this_arg & (~1));
15824         this_arg_conv.is_owned = false;
15825         LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
15826         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
15827         return (uint64_t)ret_ret;
15828 }
15829
15830 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
15831         LDKChannelManager this_arg_conv;
15832         this_arg_conv.inner = (void*)(this_arg & (~1));
15833         this_arg_conv.is_owned = false;
15834         LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
15835         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
15836         return (uint64_t)ret_ret;
15837 }
15838
15839 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
15840         LDKChannelManager this_arg_conv;
15841         this_arg_conv.inner = (void*)(this_arg & (~1));
15842         this_arg_conv.is_owned = false;
15843         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
15844         return ret_val;
15845 }
15846
15847 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
15848         LDKChannelManager this_arg_conv;
15849         this_arg_conv.inner = (void*)(this_arg & (~1));
15850         this_arg_conv.is_owned = false;
15851         ChannelManager_await_persistable_update(&this_arg_conv);
15852 }
15853
15854 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
15855         LDKChannelManager this_arg_conv;
15856         this_arg_conv.inner = (void*)(this_arg & (~1));
15857         this_arg_conv.is_owned = false;
15858         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
15859         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15860         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15861         uint64_t ret_ref = (uint64_t)ret_var.inner;
15862         if (ret_var.is_owned) {
15863                 ret_ref |= 1;
15864         }
15865         return ret_ref;
15866 }
15867
15868 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
15869         LDKChannelManager this_arg_conv;
15870         this_arg_conv.inner = (void*)(this_arg & (~1));
15871         this_arg_conv.is_owned = false;
15872         LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
15873         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
15874         return (uint64_t)ret_ret;
15875 }
15876
15877 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
15878         LDKChannelManager obj_conv;
15879         obj_conv.inner = (void*)(obj & (~1));
15880         obj_conv.is_owned = false;
15881         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
15882         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15883         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15884         CVec_u8Z_free(ret_var);
15885         return ret_arr;
15886 }
15887
15888 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
15889         LDKChannelManagerReadArgs this_obj_conv;
15890         this_obj_conv.inner = (void*)(this_obj & (~1));
15891         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15892         ChannelManagerReadArgs_free(this_obj_conv);
15893 }
15894
15895 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
15896         LDKChannelManagerReadArgs this_ptr_conv;
15897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15898         this_ptr_conv.is_owned = false;
15899         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
15900         return ret_ret;
15901 }
15902
15903 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
15904         LDKChannelManagerReadArgs this_ptr_conv;
15905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15906         this_ptr_conv.is_owned = false;
15907         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
15908         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
15909 }
15910
15911 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
15912         LDKChannelManagerReadArgs this_ptr_conv;
15913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15914         this_ptr_conv.is_owned = false;
15915         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
15916         return ret_ret;
15917 }
15918
15919 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
15920         LDKChannelManagerReadArgs this_ptr_conv;
15921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15922         this_ptr_conv.is_owned = false;
15923         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
15924         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
15925 }
15926
15927 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
15928         LDKChannelManagerReadArgs this_ptr_conv;
15929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15930         this_ptr_conv.is_owned = false;
15931         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
15932         return ret_ret;
15933 }
15934
15935 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
15936         LDKChannelManagerReadArgs this_ptr_conv;
15937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15938         this_ptr_conv.is_owned = false;
15939         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
15940         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
15941 }
15942
15943 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
15944         LDKChannelManagerReadArgs this_ptr_conv;
15945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15946         this_ptr_conv.is_owned = false;
15947         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
15948         return ret_ret;
15949 }
15950
15951 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
15952         LDKChannelManagerReadArgs this_ptr_conv;
15953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15954         this_ptr_conv.is_owned = false;
15955         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
15956         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
15957 }
15958
15959 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
15960         LDKChannelManagerReadArgs this_ptr_conv;
15961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15962         this_ptr_conv.is_owned = false;
15963         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
15964         return ret_ret;
15965 }
15966
15967 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
15968         LDKChannelManagerReadArgs this_ptr_conv;
15969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15970         this_ptr_conv.is_owned = false;
15971         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
15972         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
15973 }
15974
15975 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
15976         LDKChannelManagerReadArgs this_ptr_conv;
15977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15978         this_ptr_conv.is_owned = false;
15979         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
15980         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15981         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15982         uint64_t ret_ref = (uint64_t)ret_var.inner;
15983         if (ret_var.is_owned) {
15984                 ret_ref |= 1;
15985         }
15986         return ret_ref;
15987 }
15988
15989 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
15990         LDKChannelManagerReadArgs this_ptr_conv;
15991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15992         this_ptr_conv.is_owned = false;
15993         LDKUserConfig val_conv;
15994         val_conv.inner = (void*)(val & (~1));
15995         val_conv.is_owned = (val & 1) || (val == 0);
15996         val_conv = UserConfig_clone(&val_conv);
15997         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
15998 }
15999
16000 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) {
16001         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16002         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16003         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16004         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16005         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16006         LDKUserConfig default_config_conv;
16007         default_config_conv.inner = (void*)(default_config & (~1));
16008         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
16009         default_config_conv = UserConfig_clone(&default_config_conv);
16010         LDKCVec_ChannelMonitorZ channel_monitors_constr;
16011         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
16012         if (channel_monitors_constr.datalen > 0)
16013                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16014         else
16015                 channel_monitors_constr.data = NULL;
16016         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
16017         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
16018                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
16019                 LDKChannelMonitor channel_monitors_conv_16_conv;
16020                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
16021                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
16022                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
16023         }
16024         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);
16025         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16026         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16027         uint64_t ret_ref = (uint64_t)ret_var.inner;
16028         if (ret_var.is_owned) {
16029                 ret_ref |= 1;
16030         }
16031         return ret_ref;
16032 }
16033
16034 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
16035         LDKu8slice ser_ref;
16036         ser_ref.datalen = *((uint32_t*)ser);
16037         ser_ref.data = (int8_t*)(ser + 4);
16038         LDKChannelManagerReadArgs arg_conv;
16039         arg_conv.inner = (void*)(arg & (~1));
16040         arg_conv.is_owned = (arg & 1) || (arg == 0);
16041         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
16042         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16043         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
16044         return (uint64_t)ret_conv;
16045 }
16046
16047 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
16048         LDKDecodeError this_obj_conv;
16049         this_obj_conv.inner = (void*)(this_obj & (~1));
16050         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16051         DecodeError_free(this_obj_conv);
16052 }
16053
16054 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
16055         LDKDecodeError orig_conv;
16056         orig_conv.inner = (void*)(orig & (~1));
16057         orig_conv.is_owned = false;
16058         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
16059         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16060         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16061         uint64_t ret_ref = (uint64_t)ret_var.inner;
16062         if (ret_var.is_owned) {
16063                 ret_ref |= 1;
16064         }
16065         return ret_ref;
16066 }
16067
16068 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
16069         LDKInit this_obj_conv;
16070         this_obj_conv.inner = (void*)(this_obj & (~1));
16071         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16072         Init_free(this_obj_conv);
16073 }
16074
16075 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
16076         LDKInit this_ptr_conv;
16077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16078         this_ptr_conv.is_owned = false;
16079         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
16080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16082         uint64_t ret_ref = (uint64_t)ret_var.inner;
16083         if (ret_var.is_owned) {
16084                 ret_ref |= 1;
16085         }
16086         return ret_ref;
16087 }
16088
16089 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
16090         LDKInit this_ptr_conv;
16091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16092         this_ptr_conv.is_owned = false;
16093         LDKInitFeatures val_conv;
16094         val_conv.inner = (void*)(val & (~1));
16095         val_conv.is_owned = (val & 1) || (val == 0);
16096         val_conv = InitFeatures_clone(&val_conv);
16097         Init_set_features(&this_ptr_conv, val_conv);
16098 }
16099
16100 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
16101         LDKInitFeatures features_arg_conv;
16102         features_arg_conv.inner = (void*)(features_arg & (~1));
16103         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
16104         features_arg_conv = InitFeatures_clone(&features_arg_conv);
16105         LDKInit ret_var = Init_new(features_arg_conv);
16106         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16107         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16108         uint64_t ret_ref = (uint64_t)ret_var.inner;
16109         if (ret_var.is_owned) {
16110                 ret_ref |= 1;
16111         }
16112         return ret_ref;
16113 }
16114
16115 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
16116         LDKInit orig_conv;
16117         orig_conv.inner = (void*)(orig & (~1));
16118         orig_conv.is_owned = false;
16119         LDKInit ret_var = Init_clone(&orig_conv);
16120         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16121         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16122         uint64_t ret_ref = (uint64_t)ret_var.inner;
16123         if (ret_var.is_owned) {
16124                 ret_ref |= 1;
16125         }
16126         return ret_ref;
16127 }
16128
16129 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
16130         LDKErrorMessage this_obj_conv;
16131         this_obj_conv.inner = (void*)(this_obj & (~1));
16132         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16133         ErrorMessage_free(this_obj_conv);
16134 }
16135
16136 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
16137         LDKErrorMessage this_ptr_conv;
16138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16139         this_ptr_conv.is_owned = false;
16140         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16141         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
16142         return ret_arr;
16143 }
16144
16145 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16146         LDKErrorMessage this_ptr_conv;
16147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16148         this_ptr_conv.is_owned = false;
16149         LDKThirtyTwoBytes val_ref;
16150         CHECK(*((uint32_t*)val) == 32);
16151         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16152         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
16153 }
16154
16155 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
16156         LDKErrorMessage this_ptr_conv;
16157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16158         this_ptr_conv.is_owned = false;
16159         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
16160         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
16161         Str_free(ret_str);
16162         return ret_conv;
16163 }
16164
16165 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
16166         LDKErrorMessage this_ptr_conv;
16167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16168         this_ptr_conv.is_owned = false;
16169         LDKStr val_conv = str_ref_to_owned_c(val);
16170         ErrorMessage_set_data(&this_ptr_conv, val_conv);
16171 }
16172
16173 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
16174         LDKThirtyTwoBytes channel_id_arg_ref;
16175         CHECK(*((uint32_t*)channel_id_arg) == 32);
16176         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16177         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
16178         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
16179         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16180         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16181         uint64_t ret_ref = (uint64_t)ret_var.inner;
16182         if (ret_var.is_owned) {
16183                 ret_ref |= 1;
16184         }
16185         return ret_ref;
16186 }
16187
16188 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
16189         LDKErrorMessage orig_conv;
16190         orig_conv.inner = (void*)(orig & (~1));
16191         orig_conv.is_owned = false;
16192         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
16193         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16194         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16195         uint64_t ret_ref = (uint64_t)ret_var.inner;
16196         if (ret_var.is_owned) {
16197                 ret_ref |= 1;
16198         }
16199         return ret_ref;
16200 }
16201
16202 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
16203         LDKPing this_obj_conv;
16204         this_obj_conv.inner = (void*)(this_obj & (~1));
16205         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16206         Ping_free(this_obj_conv);
16207 }
16208
16209 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
16210         LDKPing this_ptr_conv;
16211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16212         this_ptr_conv.is_owned = false;
16213         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
16214         return ret_val;
16215 }
16216
16217 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
16218         LDKPing this_ptr_conv;
16219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16220         this_ptr_conv.is_owned = false;
16221         Ping_set_ponglen(&this_ptr_conv, val);
16222 }
16223
16224 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
16225         LDKPing this_ptr_conv;
16226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16227         this_ptr_conv.is_owned = false;
16228         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
16229         return ret_val;
16230 }
16231
16232 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
16233         LDKPing this_ptr_conv;
16234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16235         this_ptr_conv.is_owned = false;
16236         Ping_set_byteslen(&this_ptr_conv, val);
16237 }
16238
16239 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
16240         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
16241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16243         uint64_t ret_ref = (uint64_t)ret_var.inner;
16244         if (ret_var.is_owned) {
16245                 ret_ref |= 1;
16246         }
16247         return ret_ref;
16248 }
16249
16250 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
16251         LDKPing orig_conv;
16252         orig_conv.inner = (void*)(orig & (~1));
16253         orig_conv.is_owned = false;
16254         LDKPing ret_var = Ping_clone(&orig_conv);
16255         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16256         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16257         uint64_t ret_ref = (uint64_t)ret_var.inner;
16258         if (ret_var.is_owned) {
16259                 ret_ref |= 1;
16260         }
16261         return ret_ref;
16262 }
16263
16264 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
16265         LDKPong this_obj_conv;
16266         this_obj_conv.inner = (void*)(this_obj & (~1));
16267         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16268         Pong_free(this_obj_conv);
16269 }
16270
16271 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
16272         LDKPong this_ptr_conv;
16273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16274         this_ptr_conv.is_owned = false;
16275         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
16276         return ret_val;
16277 }
16278
16279 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
16280         LDKPong this_ptr_conv;
16281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16282         this_ptr_conv.is_owned = false;
16283         Pong_set_byteslen(&this_ptr_conv, val);
16284 }
16285
16286 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
16287         LDKPong ret_var = Pong_new(byteslen_arg);
16288         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16289         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16290         uint64_t ret_ref = (uint64_t)ret_var.inner;
16291         if (ret_var.is_owned) {
16292                 ret_ref |= 1;
16293         }
16294         return ret_ref;
16295 }
16296
16297 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
16298         LDKPong orig_conv;
16299         orig_conv.inner = (void*)(orig & (~1));
16300         orig_conv.is_owned = false;
16301         LDKPong ret_var = Pong_clone(&orig_conv);
16302         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16303         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16304         uint64_t ret_ref = (uint64_t)ret_var.inner;
16305         if (ret_var.is_owned) {
16306                 ret_ref |= 1;
16307         }
16308         return ret_ref;
16309 }
16310
16311 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
16312         LDKOpenChannel this_obj_conv;
16313         this_obj_conv.inner = (void*)(this_obj & (~1));
16314         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16315         OpenChannel_free(this_obj_conv);
16316 }
16317
16318 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
16319         LDKOpenChannel this_ptr_conv;
16320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16321         this_ptr_conv.is_owned = false;
16322         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16323         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
16324         return ret_arr;
16325 }
16326
16327 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16328         LDKOpenChannel this_ptr_conv;
16329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16330         this_ptr_conv.is_owned = false;
16331         LDKThirtyTwoBytes val_ref;
16332         CHECK(*((uint32_t*)val) == 32);
16333         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16334         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
16335 }
16336
16337 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
16338         LDKOpenChannel this_ptr_conv;
16339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16340         this_ptr_conv.is_owned = false;
16341         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16342         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
16343         return ret_arr;
16344 }
16345
16346 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
16347         LDKOpenChannel this_ptr_conv;
16348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16349         this_ptr_conv.is_owned = false;
16350         LDKThirtyTwoBytes val_ref;
16351         CHECK(*((uint32_t*)val) == 32);
16352         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16353         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
16354 }
16355
16356 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
16357         LDKOpenChannel this_ptr_conv;
16358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16359         this_ptr_conv.is_owned = false;
16360         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
16361         return ret_val;
16362 }
16363
16364 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
16365         LDKOpenChannel this_ptr_conv;
16366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16367         this_ptr_conv.is_owned = false;
16368         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
16369 }
16370
16371 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
16372         LDKOpenChannel this_ptr_conv;
16373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16374         this_ptr_conv.is_owned = false;
16375         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
16376         return ret_val;
16377 }
16378
16379 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
16380         LDKOpenChannel this_ptr_conv;
16381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16382         this_ptr_conv.is_owned = false;
16383         OpenChannel_set_push_msat(&this_ptr_conv, val);
16384 }
16385
16386 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
16387         LDKOpenChannel this_ptr_conv;
16388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16389         this_ptr_conv.is_owned = false;
16390         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
16391         return ret_val;
16392 }
16393
16394 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
16395         LDKOpenChannel this_ptr_conv;
16396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16397         this_ptr_conv.is_owned = false;
16398         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
16399 }
16400
16401 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
16402         LDKOpenChannel this_ptr_conv;
16403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16404         this_ptr_conv.is_owned = false;
16405         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
16406         return ret_val;
16407 }
16408
16409 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
16410         LDKOpenChannel this_ptr_conv;
16411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16412         this_ptr_conv.is_owned = false;
16413         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
16414 }
16415
16416 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
16417         LDKOpenChannel this_ptr_conv;
16418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16419         this_ptr_conv.is_owned = false;
16420         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
16421         return ret_val;
16422 }
16423
16424 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
16425         LDKOpenChannel this_ptr_conv;
16426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16427         this_ptr_conv.is_owned = false;
16428         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
16429 }
16430
16431 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
16432         LDKOpenChannel this_ptr_conv;
16433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16434         this_ptr_conv.is_owned = false;
16435         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
16436         return ret_val;
16437 }
16438
16439 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
16440         LDKOpenChannel this_ptr_conv;
16441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16442         this_ptr_conv.is_owned = false;
16443         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
16444 }
16445
16446 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
16447         LDKOpenChannel this_ptr_conv;
16448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16449         this_ptr_conv.is_owned = false;
16450         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
16451         return ret_val;
16452 }
16453
16454 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
16455         LDKOpenChannel this_ptr_conv;
16456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16457         this_ptr_conv.is_owned = false;
16458         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
16459 }
16460
16461 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
16462         LDKOpenChannel this_ptr_conv;
16463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16464         this_ptr_conv.is_owned = false;
16465         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
16466         return ret_val;
16467 }
16468
16469 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
16470         LDKOpenChannel this_ptr_conv;
16471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16472         this_ptr_conv.is_owned = false;
16473         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
16474 }
16475
16476 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
16477         LDKOpenChannel this_ptr_conv;
16478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16479         this_ptr_conv.is_owned = false;
16480         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
16481         return ret_val;
16482 }
16483
16484 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
16485         LDKOpenChannel this_ptr_conv;
16486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16487         this_ptr_conv.is_owned = false;
16488         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
16489 }
16490
16491 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
16492         LDKOpenChannel this_ptr_conv;
16493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16494         this_ptr_conv.is_owned = false;
16495         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16496         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
16497         return ret_arr;
16498 }
16499
16500 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
16501         LDKOpenChannel this_ptr_conv;
16502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16503         this_ptr_conv.is_owned = false;
16504         LDKPublicKey val_ref;
16505         CHECK(*((uint32_t*)val) == 33);
16506         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16507         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
16508 }
16509
16510 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
16511         LDKOpenChannel this_ptr_conv;
16512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16513         this_ptr_conv.is_owned = false;
16514         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16515         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
16516         return ret_arr;
16517 }
16518
16519 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
16520         LDKOpenChannel this_ptr_conv;
16521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16522         this_ptr_conv.is_owned = false;
16523         LDKPublicKey val_ref;
16524         CHECK(*((uint32_t*)val) == 33);
16525         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16526         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
16527 }
16528
16529 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
16530         LDKOpenChannel this_ptr_conv;
16531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16532         this_ptr_conv.is_owned = false;
16533         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16534         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
16535         return ret_arr;
16536 }
16537
16538 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
16539         LDKOpenChannel this_ptr_conv;
16540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16541         this_ptr_conv.is_owned = false;
16542         LDKPublicKey val_ref;
16543         CHECK(*((uint32_t*)val) == 33);
16544         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16545         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
16546 }
16547
16548 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
16549         LDKOpenChannel this_ptr_conv;
16550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16551         this_ptr_conv.is_owned = false;
16552         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16553         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
16554         return ret_arr;
16555 }
16556
16557 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
16558         LDKOpenChannel this_ptr_conv;
16559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16560         this_ptr_conv.is_owned = false;
16561         LDKPublicKey val_ref;
16562         CHECK(*((uint32_t*)val) == 33);
16563         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16564         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16565 }
16566
16567 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
16568         LDKOpenChannel this_ptr_conv;
16569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16570         this_ptr_conv.is_owned = false;
16571         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16572         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
16573         return ret_arr;
16574 }
16575
16576 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
16577         LDKOpenChannel this_ptr_conv;
16578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16579         this_ptr_conv.is_owned = false;
16580         LDKPublicKey val_ref;
16581         CHECK(*((uint32_t*)val) == 33);
16582         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16583         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
16584 }
16585
16586 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
16587         LDKOpenChannel this_ptr_conv;
16588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16589         this_ptr_conv.is_owned = false;
16590         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16591         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
16592         return ret_arr;
16593 }
16594
16595 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
16596         LDKOpenChannel this_ptr_conv;
16597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16598         this_ptr_conv.is_owned = false;
16599         LDKPublicKey val_ref;
16600         CHECK(*((uint32_t*)val) == 33);
16601         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16602         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
16603 }
16604
16605 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
16606         LDKOpenChannel this_ptr_conv;
16607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16608         this_ptr_conv.is_owned = false;
16609         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
16610         return ret_val;
16611 }
16612
16613 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
16614         LDKOpenChannel this_ptr_conv;
16615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16616         this_ptr_conv.is_owned = false;
16617         OpenChannel_set_channel_flags(&this_ptr_conv, val);
16618 }
16619
16620 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
16621         LDKOpenChannel orig_conv;
16622         orig_conv.inner = (void*)(orig & (~1));
16623         orig_conv.is_owned = false;
16624         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
16625         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16626         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16627         uint64_t ret_ref = (uint64_t)ret_var.inner;
16628         if (ret_var.is_owned) {
16629                 ret_ref |= 1;
16630         }
16631         return ret_ref;
16632 }
16633
16634 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
16635         LDKAcceptChannel this_obj_conv;
16636         this_obj_conv.inner = (void*)(this_obj & (~1));
16637         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16638         AcceptChannel_free(this_obj_conv);
16639 }
16640
16641 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
16642         LDKAcceptChannel this_ptr_conv;
16643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16644         this_ptr_conv.is_owned = false;
16645         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16646         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
16647         return ret_arr;
16648 }
16649
16650 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
16651         LDKAcceptChannel this_ptr_conv;
16652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16653         this_ptr_conv.is_owned = false;
16654         LDKThirtyTwoBytes val_ref;
16655         CHECK(*((uint32_t*)val) == 32);
16656         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16657         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
16658 }
16659
16660 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
16661         LDKAcceptChannel this_ptr_conv;
16662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16663         this_ptr_conv.is_owned = false;
16664         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
16665         return ret_val;
16666 }
16667
16668 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
16669         LDKAcceptChannel this_ptr_conv;
16670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16671         this_ptr_conv.is_owned = false;
16672         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
16673 }
16674
16675 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
16676         LDKAcceptChannel this_ptr_conv;
16677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16678         this_ptr_conv.is_owned = false;
16679         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
16680         return ret_val;
16681 }
16682
16683 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
16684         LDKAcceptChannel this_ptr_conv;
16685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16686         this_ptr_conv.is_owned = false;
16687         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
16688 }
16689
16690 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
16691         LDKAcceptChannel this_ptr_conv;
16692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16693         this_ptr_conv.is_owned = false;
16694         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
16695         return ret_val;
16696 }
16697
16698 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
16699         LDKAcceptChannel this_ptr_conv;
16700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16701         this_ptr_conv.is_owned = false;
16702         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
16703 }
16704
16705 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
16706         LDKAcceptChannel this_ptr_conv;
16707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16708         this_ptr_conv.is_owned = false;
16709         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
16710         return ret_val;
16711 }
16712
16713 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
16714         LDKAcceptChannel this_ptr_conv;
16715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16716         this_ptr_conv.is_owned = false;
16717         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
16718 }
16719
16720 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
16721         LDKAcceptChannel this_ptr_conv;
16722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16723         this_ptr_conv.is_owned = false;
16724         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
16725         return ret_val;
16726 }
16727
16728 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
16729         LDKAcceptChannel this_ptr_conv;
16730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16731         this_ptr_conv.is_owned = false;
16732         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
16733 }
16734
16735 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
16736         LDKAcceptChannel this_ptr_conv;
16737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16738         this_ptr_conv.is_owned = false;
16739         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
16740         return ret_val;
16741 }
16742
16743 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
16744         LDKAcceptChannel this_ptr_conv;
16745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16746         this_ptr_conv.is_owned = false;
16747         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
16748 }
16749
16750 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
16751         LDKAcceptChannel this_ptr_conv;
16752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16753         this_ptr_conv.is_owned = false;
16754         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
16755         return ret_val;
16756 }
16757
16758 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
16759         LDKAcceptChannel this_ptr_conv;
16760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16761         this_ptr_conv.is_owned = false;
16762         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
16763 }
16764
16765 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
16766         LDKAcceptChannel this_ptr_conv;
16767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16768         this_ptr_conv.is_owned = false;
16769         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16770         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
16771         return ret_arr;
16772 }
16773
16774 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
16775         LDKAcceptChannel this_ptr_conv;
16776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16777         this_ptr_conv.is_owned = false;
16778         LDKPublicKey val_ref;
16779         CHECK(*((uint32_t*)val) == 33);
16780         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16781         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
16782 }
16783
16784 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
16785         LDKAcceptChannel this_ptr_conv;
16786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16787         this_ptr_conv.is_owned = false;
16788         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16789         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
16790         return ret_arr;
16791 }
16792
16793 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
16794         LDKAcceptChannel this_ptr_conv;
16795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16796         this_ptr_conv.is_owned = false;
16797         LDKPublicKey val_ref;
16798         CHECK(*((uint32_t*)val) == 33);
16799         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16800         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
16801 }
16802
16803 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
16804         LDKAcceptChannel this_ptr_conv;
16805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16806         this_ptr_conv.is_owned = false;
16807         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16808         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
16809         return ret_arr;
16810 }
16811
16812 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
16813         LDKAcceptChannel this_ptr_conv;
16814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16815         this_ptr_conv.is_owned = false;
16816         LDKPublicKey val_ref;
16817         CHECK(*((uint32_t*)val) == 33);
16818         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16819         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
16820 }
16821
16822 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
16823         LDKAcceptChannel this_ptr_conv;
16824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16825         this_ptr_conv.is_owned = false;
16826         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16827         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
16828         return ret_arr;
16829 }
16830
16831 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
16832         LDKAcceptChannel this_ptr_conv;
16833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16834         this_ptr_conv.is_owned = false;
16835         LDKPublicKey val_ref;
16836         CHECK(*((uint32_t*)val) == 33);
16837         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16838         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16839 }
16840
16841 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
16842         LDKAcceptChannel this_ptr_conv;
16843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16844         this_ptr_conv.is_owned = false;
16845         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16846         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
16847         return ret_arr;
16848 }
16849
16850 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
16851         LDKAcceptChannel this_ptr_conv;
16852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16853         this_ptr_conv.is_owned = false;
16854         LDKPublicKey val_ref;
16855         CHECK(*((uint32_t*)val) == 33);
16856         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16857         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
16858 }
16859
16860 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
16861         LDKAcceptChannel this_ptr_conv;
16862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16863         this_ptr_conv.is_owned = false;
16864         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16865         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
16866         return ret_arr;
16867 }
16868
16869 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
16870         LDKAcceptChannel this_ptr_conv;
16871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16872         this_ptr_conv.is_owned = false;
16873         LDKPublicKey val_ref;
16874         CHECK(*((uint32_t*)val) == 33);
16875         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16876         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
16877 }
16878
16879 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
16880         LDKAcceptChannel orig_conv;
16881         orig_conv.inner = (void*)(orig & (~1));
16882         orig_conv.is_owned = false;
16883         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
16884         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16885         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16886         uint64_t ret_ref = (uint64_t)ret_var.inner;
16887         if (ret_var.is_owned) {
16888                 ret_ref |= 1;
16889         }
16890         return ret_ref;
16891 }
16892
16893 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
16894         LDKFundingCreated this_obj_conv;
16895         this_obj_conv.inner = (void*)(this_obj & (~1));
16896         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16897         FundingCreated_free(this_obj_conv);
16898 }
16899
16900 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
16901         LDKFundingCreated this_ptr_conv;
16902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16903         this_ptr_conv.is_owned = false;
16904         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16905         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
16906         return ret_arr;
16907 }
16908
16909 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
16910         LDKFundingCreated this_ptr_conv;
16911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16912         this_ptr_conv.is_owned = false;
16913         LDKThirtyTwoBytes val_ref;
16914         CHECK(*((uint32_t*)val) == 32);
16915         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16916         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
16917 }
16918
16919 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
16920         LDKFundingCreated this_ptr_conv;
16921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16922         this_ptr_conv.is_owned = false;
16923         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16924         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
16925         return ret_arr;
16926 }
16927
16928 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
16929         LDKFundingCreated this_ptr_conv;
16930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16931         this_ptr_conv.is_owned = false;
16932         LDKThirtyTwoBytes val_ref;
16933         CHECK(*((uint32_t*)val) == 32);
16934         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16935         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
16936 }
16937
16938 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
16939         LDKFundingCreated this_ptr_conv;
16940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16941         this_ptr_conv.is_owned = false;
16942         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
16943         return ret_val;
16944 }
16945
16946 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
16947         LDKFundingCreated this_ptr_conv;
16948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16949         this_ptr_conv.is_owned = false;
16950         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
16951 }
16952
16953 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
16954         LDKFundingCreated this_ptr_conv;
16955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16956         this_ptr_conv.is_owned = false;
16957         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16958         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
16959         return ret_arr;
16960 }
16961
16962 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
16963         LDKFundingCreated this_ptr_conv;
16964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16965         this_ptr_conv.is_owned = false;
16966         LDKSignature val_ref;
16967         CHECK(*((uint32_t*)val) == 64);
16968         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16969         FundingCreated_set_signature(&this_ptr_conv, val_ref);
16970 }
16971
16972 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) {
16973         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
16974         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
16975         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
16976         LDKThirtyTwoBytes funding_txid_arg_ref;
16977         CHECK(*((uint32_t*)funding_txid_arg) == 32);
16978         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
16979         LDKSignature signature_arg_ref;
16980         CHECK(*((uint32_t*)signature_arg) == 64);
16981         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
16982         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
16983         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16984         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16985         uint64_t ret_ref = (uint64_t)ret_var.inner;
16986         if (ret_var.is_owned) {
16987                 ret_ref |= 1;
16988         }
16989         return ret_ref;
16990 }
16991
16992 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
16993         LDKFundingCreated orig_conv;
16994         orig_conv.inner = (void*)(orig & (~1));
16995         orig_conv.is_owned = false;
16996         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
16997         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16998         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16999         uint64_t ret_ref = (uint64_t)ret_var.inner;
17000         if (ret_var.is_owned) {
17001                 ret_ref |= 1;
17002         }
17003         return ret_ref;
17004 }
17005
17006 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
17007         LDKFundingSigned this_obj_conv;
17008         this_obj_conv.inner = (void*)(this_obj & (~1));
17009         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17010         FundingSigned_free(this_obj_conv);
17011 }
17012
17013 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
17014         LDKFundingSigned this_ptr_conv;
17015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17016         this_ptr_conv.is_owned = false;
17017         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17018         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
17019         return ret_arr;
17020 }
17021
17022 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17023         LDKFundingSigned this_ptr_conv;
17024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17025         this_ptr_conv.is_owned = false;
17026         LDKThirtyTwoBytes val_ref;
17027         CHECK(*((uint32_t*)val) == 32);
17028         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17029         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
17030 }
17031
17032 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
17033         LDKFundingSigned this_ptr_conv;
17034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17035         this_ptr_conv.is_owned = false;
17036         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17037         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
17038         return ret_arr;
17039 }
17040
17041 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
17042         LDKFundingSigned this_ptr_conv;
17043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17044         this_ptr_conv.is_owned = false;
17045         LDKSignature val_ref;
17046         CHECK(*((uint32_t*)val) == 64);
17047         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17048         FundingSigned_set_signature(&this_ptr_conv, val_ref);
17049 }
17050
17051 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
17052         LDKThirtyTwoBytes channel_id_arg_ref;
17053         CHECK(*((uint32_t*)channel_id_arg) == 32);
17054         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17055         LDKSignature signature_arg_ref;
17056         CHECK(*((uint32_t*)signature_arg) == 64);
17057         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
17058         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
17059         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17060         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17061         uint64_t ret_ref = (uint64_t)ret_var.inner;
17062         if (ret_var.is_owned) {
17063                 ret_ref |= 1;
17064         }
17065         return ret_ref;
17066 }
17067
17068 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
17069         LDKFundingSigned orig_conv;
17070         orig_conv.inner = (void*)(orig & (~1));
17071         orig_conv.is_owned = false;
17072         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
17073         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17074         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17075         uint64_t ret_ref = (uint64_t)ret_var.inner;
17076         if (ret_var.is_owned) {
17077                 ret_ref |= 1;
17078         }
17079         return ret_ref;
17080 }
17081
17082 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
17083         LDKFundingLocked this_obj_conv;
17084         this_obj_conv.inner = (void*)(this_obj & (~1));
17085         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17086         FundingLocked_free(this_obj_conv);
17087 }
17088
17089 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
17090         LDKFundingLocked this_ptr_conv;
17091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17092         this_ptr_conv.is_owned = false;
17093         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17094         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
17095         return ret_arr;
17096 }
17097
17098 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17099         LDKFundingLocked this_ptr_conv;
17100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17101         this_ptr_conv.is_owned = false;
17102         LDKThirtyTwoBytes val_ref;
17103         CHECK(*((uint32_t*)val) == 32);
17104         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17105         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
17106 }
17107
17108 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
17109         LDKFundingLocked this_ptr_conv;
17110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17111         this_ptr_conv.is_owned = false;
17112         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17113         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
17114         return ret_arr;
17115 }
17116
17117 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
17118         LDKFundingLocked this_ptr_conv;
17119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17120         this_ptr_conv.is_owned = false;
17121         LDKPublicKey val_ref;
17122         CHECK(*((uint32_t*)val) == 33);
17123         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17124         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
17125 }
17126
17127 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
17128         LDKThirtyTwoBytes channel_id_arg_ref;
17129         CHECK(*((uint32_t*)channel_id_arg) == 32);
17130         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17131         LDKPublicKey next_per_commitment_point_arg_ref;
17132         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
17133         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
17134         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
17135         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17136         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17137         uint64_t ret_ref = (uint64_t)ret_var.inner;
17138         if (ret_var.is_owned) {
17139                 ret_ref |= 1;
17140         }
17141         return ret_ref;
17142 }
17143
17144 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
17145         LDKFundingLocked orig_conv;
17146         orig_conv.inner = (void*)(orig & (~1));
17147         orig_conv.is_owned = false;
17148         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
17149         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17150         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17151         uint64_t ret_ref = (uint64_t)ret_var.inner;
17152         if (ret_var.is_owned) {
17153                 ret_ref |= 1;
17154         }
17155         return ret_ref;
17156 }
17157
17158 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
17159         LDKShutdown this_obj_conv;
17160         this_obj_conv.inner = (void*)(this_obj & (~1));
17161         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17162         Shutdown_free(this_obj_conv);
17163 }
17164
17165 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
17166         LDKShutdown this_ptr_conv;
17167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17168         this_ptr_conv.is_owned = false;
17169         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17170         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
17171         return ret_arr;
17172 }
17173
17174 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17175         LDKShutdown this_ptr_conv;
17176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17177         this_ptr_conv.is_owned = false;
17178         LDKThirtyTwoBytes val_ref;
17179         CHECK(*((uint32_t*)val) == 32);
17180         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17181         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
17182 }
17183
17184 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
17185         LDKShutdown this_ptr_conv;
17186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17187         this_ptr_conv.is_owned = false;
17188         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
17189         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17190         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17191         return ret_arr;
17192 }
17193
17194 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
17195         LDKShutdown this_ptr_conv;
17196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17197         this_ptr_conv.is_owned = false;
17198         LDKCVec_u8Z val_ref;
17199         val_ref.datalen = *((uint32_t*)val);
17200         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
17201         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
17202         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
17203 }
17204
17205 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
17206         LDKThirtyTwoBytes channel_id_arg_ref;
17207         CHECK(*((uint32_t*)channel_id_arg) == 32);
17208         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17209         LDKCVec_u8Z scriptpubkey_arg_ref;
17210         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
17211         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
17212         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
17213         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
17214         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17215         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17216         uint64_t ret_ref = (uint64_t)ret_var.inner;
17217         if (ret_var.is_owned) {
17218                 ret_ref |= 1;
17219         }
17220         return ret_ref;
17221 }
17222
17223 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
17224         LDKShutdown orig_conv;
17225         orig_conv.inner = (void*)(orig & (~1));
17226         orig_conv.is_owned = false;
17227         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
17228         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17229         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17230         uint64_t ret_ref = (uint64_t)ret_var.inner;
17231         if (ret_var.is_owned) {
17232                 ret_ref |= 1;
17233         }
17234         return ret_ref;
17235 }
17236
17237 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
17238         LDKClosingSignedFeeRange this_obj_conv;
17239         this_obj_conv.inner = (void*)(this_obj & (~1));
17240         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17241         ClosingSignedFeeRange_free(this_obj_conv);
17242 }
17243
17244 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
17245         LDKClosingSignedFeeRange this_ptr_conv;
17246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17247         this_ptr_conv.is_owned = false;
17248         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
17249         return ret_val;
17250 }
17251
17252 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
17253         LDKClosingSignedFeeRange this_ptr_conv;
17254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17255         this_ptr_conv.is_owned = false;
17256         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
17257 }
17258
17259 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
17260         LDKClosingSignedFeeRange this_ptr_conv;
17261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17262         this_ptr_conv.is_owned = false;
17263         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
17264         return ret_val;
17265 }
17266
17267 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
17268         LDKClosingSignedFeeRange this_ptr_conv;
17269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17270         this_ptr_conv.is_owned = false;
17271         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
17272 }
17273
17274 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
17275         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
17276         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17277         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17278         uint64_t ret_ref = (uint64_t)ret_var.inner;
17279         if (ret_var.is_owned) {
17280                 ret_ref |= 1;
17281         }
17282         return ret_ref;
17283 }
17284
17285 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
17286         LDKClosingSignedFeeRange orig_conv;
17287         orig_conv.inner = (void*)(orig & (~1));
17288         orig_conv.is_owned = false;
17289         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
17290         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17291         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17292         uint64_t ret_ref = (uint64_t)ret_var.inner;
17293         if (ret_var.is_owned) {
17294                 ret_ref |= 1;
17295         }
17296         return ret_ref;
17297 }
17298
17299 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
17300         LDKClosingSigned this_obj_conv;
17301         this_obj_conv.inner = (void*)(this_obj & (~1));
17302         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17303         ClosingSigned_free(this_obj_conv);
17304 }
17305
17306 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
17307         LDKClosingSigned this_ptr_conv;
17308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17309         this_ptr_conv.is_owned = false;
17310         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17311         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
17312         return ret_arr;
17313 }
17314
17315 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17316         LDKClosingSigned this_ptr_conv;
17317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17318         this_ptr_conv.is_owned = false;
17319         LDKThirtyTwoBytes val_ref;
17320         CHECK(*((uint32_t*)val) == 32);
17321         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17322         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
17323 }
17324
17325 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
17326         LDKClosingSigned this_ptr_conv;
17327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17328         this_ptr_conv.is_owned = false;
17329         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
17330         return ret_val;
17331 }
17332
17333 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
17334         LDKClosingSigned this_ptr_conv;
17335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17336         this_ptr_conv.is_owned = false;
17337         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
17338 }
17339
17340 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
17341         LDKClosingSigned this_ptr_conv;
17342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17343         this_ptr_conv.is_owned = false;
17344         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17345         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
17346         return ret_arr;
17347 }
17348
17349 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
17350         LDKClosingSigned this_ptr_conv;
17351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17352         this_ptr_conv.is_owned = false;
17353         LDKSignature val_ref;
17354         CHECK(*((uint32_t*)val) == 64);
17355         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17356         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
17357 }
17358
17359 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
17360         LDKClosingSigned this_ptr_conv;
17361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17362         this_ptr_conv.is_owned = false;
17363         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
17364         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17365         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17366         uint64_t ret_ref = (uint64_t)ret_var.inner;
17367         if (ret_var.is_owned) {
17368                 ret_ref |= 1;
17369         }
17370         return ret_ref;
17371 }
17372
17373 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
17374         LDKClosingSigned this_ptr_conv;
17375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17376         this_ptr_conv.is_owned = false;
17377         LDKClosingSignedFeeRange val_conv;
17378         val_conv.inner = (void*)(val & (~1));
17379         val_conv.is_owned = (val & 1) || (val == 0);
17380         val_conv = ClosingSignedFeeRange_clone(&val_conv);
17381         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
17382 }
17383
17384 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg, uint32_t fee_range_arg) {
17385         LDKThirtyTwoBytes channel_id_arg_ref;
17386         CHECK(*((uint32_t*)channel_id_arg) == 32);
17387         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17388         LDKSignature signature_arg_ref;
17389         CHECK(*((uint32_t*)signature_arg) == 64);
17390         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
17391         LDKClosingSignedFeeRange fee_range_arg_conv;
17392         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
17393         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
17394         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
17395         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
17396         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17397         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17398         uint64_t ret_ref = (uint64_t)ret_var.inner;
17399         if (ret_var.is_owned) {
17400                 ret_ref |= 1;
17401         }
17402         return ret_ref;
17403 }
17404
17405 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
17406         LDKClosingSigned orig_conv;
17407         orig_conv.inner = (void*)(orig & (~1));
17408         orig_conv.is_owned = false;
17409         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
17410         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17411         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17412         uint64_t ret_ref = (uint64_t)ret_var.inner;
17413         if (ret_var.is_owned) {
17414                 ret_ref |= 1;
17415         }
17416         return ret_ref;
17417 }
17418
17419 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
17420         LDKUpdateAddHTLC this_obj_conv;
17421         this_obj_conv.inner = (void*)(this_obj & (~1));
17422         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17423         UpdateAddHTLC_free(this_obj_conv);
17424 }
17425
17426 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
17427         LDKUpdateAddHTLC this_ptr_conv;
17428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17429         this_ptr_conv.is_owned = false;
17430         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17431         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
17432         return ret_arr;
17433 }
17434
17435 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17436         LDKUpdateAddHTLC this_ptr_conv;
17437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17438         this_ptr_conv.is_owned = false;
17439         LDKThirtyTwoBytes val_ref;
17440         CHECK(*((uint32_t*)val) == 32);
17441         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17442         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
17443 }
17444
17445 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
17446         LDKUpdateAddHTLC this_ptr_conv;
17447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17448         this_ptr_conv.is_owned = false;
17449         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
17450         return ret_val;
17451 }
17452
17453 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
17454         LDKUpdateAddHTLC this_ptr_conv;
17455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17456         this_ptr_conv.is_owned = false;
17457         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
17458 }
17459
17460 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
17461         LDKUpdateAddHTLC this_ptr_conv;
17462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17463         this_ptr_conv.is_owned = false;
17464         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
17465         return ret_val;
17466 }
17467
17468 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
17469         LDKUpdateAddHTLC this_ptr_conv;
17470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17471         this_ptr_conv.is_owned = false;
17472         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
17473 }
17474
17475 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
17476         LDKUpdateAddHTLC this_ptr_conv;
17477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17478         this_ptr_conv.is_owned = false;
17479         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17480         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
17481         return ret_arr;
17482 }
17483
17484 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
17485         LDKUpdateAddHTLC this_ptr_conv;
17486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17487         this_ptr_conv.is_owned = false;
17488         LDKThirtyTwoBytes val_ref;
17489         CHECK(*((uint32_t*)val) == 32);
17490         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17491         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
17492 }
17493
17494 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
17495         LDKUpdateAddHTLC this_ptr_conv;
17496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17497         this_ptr_conv.is_owned = false;
17498         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
17499         return ret_val;
17500 }
17501
17502 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
17503         LDKUpdateAddHTLC this_ptr_conv;
17504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17505         this_ptr_conv.is_owned = false;
17506         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
17507 }
17508
17509 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
17510         LDKUpdateAddHTLC orig_conv;
17511         orig_conv.inner = (void*)(orig & (~1));
17512         orig_conv.is_owned = false;
17513         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
17514         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17515         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17516         uint64_t ret_ref = (uint64_t)ret_var.inner;
17517         if (ret_var.is_owned) {
17518                 ret_ref |= 1;
17519         }
17520         return ret_ref;
17521 }
17522
17523 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
17524         LDKUpdateFulfillHTLC this_obj_conv;
17525         this_obj_conv.inner = (void*)(this_obj & (~1));
17526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17527         UpdateFulfillHTLC_free(this_obj_conv);
17528 }
17529
17530 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
17531         LDKUpdateFulfillHTLC this_ptr_conv;
17532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17533         this_ptr_conv.is_owned = false;
17534         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17535         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
17536         return ret_arr;
17537 }
17538
17539 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17540         LDKUpdateFulfillHTLC this_ptr_conv;
17541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17542         this_ptr_conv.is_owned = false;
17543         LDKThirtyTwoBytes val_ref;
17544         CHECK(*((uint32_t*)val) == 32);
17545         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17546         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
17547 }
17548
17549 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
17550         LDKUpdateFulfillHTLC this_ptr_conv;
17551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17552         this_ptr_conv.is_owned = false;
17553         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
17554         return ret_val;
17555 }
17556
17557 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
17558         LDKUpdateFulfillHTLC this_ptr_conv;
17559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17560         this_ptr_conv.is_owned = false;
17561         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
17562 }
17563
17564 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
17565         LDKUpdateFulfillHTLC this_ptr_conv;
17566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17567         this_ptr_conv.is_owned = false;
17568         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17569         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
17570         return ret_arr;
17571 }
17572
17573 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
17574         LDKUpdateFulfillHTLC this_ptr_conv;
17575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17576         this_ptr_conv.is_owned = false;
17577         LDKThirtyTwoBytes val_ref;
17578         CHECK(*((uint32_t*)val) == 32);
17579         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17580         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
17581 }
17582
17583 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
17584         LDKThirtyTwoBytes channel_id_arg_ref;
17585         CHECK(*((uint32_t*)channel_id_arg) == 32);
17586         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17587         LDKThirtyTwoBytes payment_preimage_arg_ref;
17588         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
17589         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
17590         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
17591         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17592         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17593         uint64_t ret_ref = (uint64_t)ret_var.inner;
17594         if (ret_var.is_owned) {
17595                 ret_ref |= 1;
17596         }
17597         return ret_ref;
17598 }
17599
17600 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
17601         LDKUpdateFulfillHTLC orig_conv;
17602         orig_conv.inner = (void*)(orig & (~1));
17603         orig_conv.is_owned = false;
17604         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
17605         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17606         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17607         uint64_t ret_ref = (uint64_t)ret_var.inner;
17608         if (ret_var.is_owned) {
17609                 ret_ref |= 1;
17610         }
17611         return ret_ref;
17612 }
17613
17614 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
17615         LDKUpdateFailHTLC this_obj_conv;
17616         this_obj_conv.inner = (void*)(this_obj & (~1));
17617         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17618         UpdateFailHTLC_free(this_obj_conv);
17619 }
17620
17621 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
17622         LDKUpdateFailHTLC this_ptr_conv;
17623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17624         this_ptr_conv.is_owned = false;
17625         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17626         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
17627         return ret_arr;
17628 }
17629
17630 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17631         LDKUpdateFailHTLC this_ptr_conv;
17632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17633         this_ptr_conv.is_owned = false;
17634         LDKThirtyTwoBytes val_ref;
17635         CHECK(*((uint32_t*)val) == 32);
17636         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17637         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
17638 }
17639
17640 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
17641         LDKUpdateFailHTLC this_ptr_conv;
17642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17643         this_ptr_conv.is_owned = false;
17644         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
17645         return ret_val;
17646 }
17647
17648 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
17649         LDKUpdateFailHTLC this_ptr_conv;
17650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17651         this_ptr_conv.is_owned = false;
17652         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
17653 }
17654
17655 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
17656         LDKUpdateFailHTLC orig_conv;
17657         orig_conv.inner = (void*)(orig & (~1));
17658         orig_conv.is_owned = false;
17659         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
17660         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17661         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17662         uint64_t ret_ref = (uint64_t)ret_var.inner;
17663         if (ret_var.is_owned) {
17664                 ret_ref |= 1;
17665         }
17666         return ret_ref;
17667 }
17668
17669 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
17670         LDKUpdateFailMalformedHTLC this_obj_conv;
17671         this_obj_conv.inner = (void*)(this_obj & (~1));
17672         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17673         UpdateFailMalformedHTLC_free(this_obj_conv);
17674 }
17675
17676 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
17677         LDKUpdateFailMalformedHTLC this_ptr_conv;
17678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17679         this_ptr_conv.is_owned = false;
17680         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17681         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
17682         return ret_arr;
17683 }
17684
17685 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17686         LDKUpdateFailMalformedHTLC this_ptr_conv;
17687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17688         this_ptr_conv.is_owned = false;
17689         LDKThirtyTwoBytes val_ref;
17690         CHECK(*((uint32_t*)val) == 32);
17691         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17692         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
17693 }
17694
17695 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
17696         LDKUpdateFailMalformedHTLC this_ptr_conv;
17697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17698         this_ptr_conv.is_owned = false;
17699         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
17700         return ret_val;
17701 }
17702
17703 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
17704         LDKUpdateFailMalformedHTLC this_ptr_conv;
17705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17706         this_ptr_conv.is_owned = false;
17707         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
17708 }
17709
17710 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
17711         LDKUpdateFailMalformedHTLC this_ptr_conv;
17712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17713         this_ptr_conv.is_owned = false;
17714         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
17715         return ret_val;
17716 }
17717
17718 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
17719         LDKUpdateFailMalformedHTLC this_ptr_conv;
17720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17721         this_ptr_conv.is_owned = false;
17722         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
17723 }
17724
17725 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
17726         LDKUpdateFailMalformedHTLC orig_conv;
17727         orig_conv.inner = (void*)(orig & (~1));
17728         orig_conv.is_owned = false;
17729         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
17730         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17731         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17732         uint64_t ret_ref = (uint64_t)ret_var.inner;
17733         if (ret_var.is_owned) {
17734                 ret_ref |= 1;
17735         }
17736         return ret_ref;
17737 }
17738
17739 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
17740         LDKCommitmentSigned this_obj_conv;
17741         this_obj_conv.inner = (void*)(this_obj & (~1));
17742         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17743         CommitmentSigned_free(this_obj_conv);
17744 }
17745
17746 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
17747         LDKCommitmentSigned this_ptr_conv;
17748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17749         this_ptr_conv.is_owned = false;
17750         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17751         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
17752         return ret_arr;
17753 }
17754
17755 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17756         LDKCommitmentSigned this_ptr_conv;
17757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17758         this_ptr_conv.is_owned = false;
17759         LDKThirtyTwoBytes val_ref;
17760         CHECK(*((uint32_t*)val) == 32);
17761         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17762         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
17763 }
17764
17765 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
17766         LDKCommitmentSigned this_ptr_conv;
17767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17768         this_ptr_conv.is_owned = false;
17769         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17770         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
17771         return ret_arr;
17772 }
17773
17774 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
17775         LDKCommitmentSigned this_ptr_conv;
17776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17777         this_ptr_conv.is_owned = false;
17778         LDKSignature val_ref;
17779         CHECK(*((uint32_t*)val) == 64);
17780         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17781         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
17782 }
17783
17784 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
17785         LDKCommitmentSigned this_ptr_conv;
17786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17787         this_ptr_conv.is_owned = false;
17788         LDKCVec_SignatureZ val_constr;
17789         val_constr.datalen = *((uint32_t*)val);
17790         if (val_constr.datalen > 0)
17791                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17792         else
17793                 val_constr.data = NULL;
17794         int8_tArray* val_vals = (int8_tArray*)(val + 4);
17795         for (size_t m = 0; m < val_constr.datalen; m++) {
17796                 int8_tArray val_conv_12 = val_vals[m];
17797                 LDKSignature val_conv_12_ref;
17798                 CHECK(*((uint32_t*)val_conv_12) == 64);
17799                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
17800                 val_constr.data[m] = val_conv_12_ref;
17801         }
17802         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
17803 }
17804
17805 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
17806         LDKThirtyTwoBytes channel_id_arg_ref;
17807         CHECK(*((uint32_t*)channel_id_arg) == 32);
17808         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17809         LDKSignature signature_arg_ref;
17810         CHECK(*((uint32_t*)signature_arg) == 64);
17811         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
17812         LDKCVec_SignatureZ htlc_signatures_arg_constr;
17813         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
17814         if (htlc_signatures_arg_constr.datalen > 0)
17815                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17816         else
17817                 htlc_signatures_arg_constr.data = NULL;
17818         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
17819         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
17820                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
17821                 LDKSignature htlc_signatures_arg_conv_12_ref;
17822                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
17823                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
17824                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
17825         }
17826         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
17827         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17828         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17829         uint64_t ret_ref = (uint64_t)ret_var.inner;
17830         if (ret_var.is_owned) {
17831                 ret_ref |= 1;
17832         }
17833         return ret_ref;
17834 }
17835
17836 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
17837         LDKCommitmentSigned orig_conv;
17838         orig_conv.inner = (void*)(orig & (~1));
17839         orig_conv.is_owned = false;
17840         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
17841         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17842         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17843         uint64_t ret_ref = (uint64_t)ret_var.inner;
17844         if (ret_var.is_owned) {
17845                 ret_ref |= 1;
17846         }
17847         return ret_ref;
17848 }
17849
17850 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
17851         LDKRevokeAndACK this_obj_conv;
17852         this_obj_conv.inner = (void*)(this_obj & (~1));
17853         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17854         RevokeAndACK_free(this_obj_conv);
17855 }
17856
17857 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
17858         LDKRevokeAndACK this_ptr_conv;
17859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17860         this_ptr_conv.is_owned = false;
17861         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17862         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
17863         return ret_arr;
17864 }
17865
17866 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17867         LDKRevokeAndACK this_ptr_conv;
17868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17869         this_ptr_conv.is_owned = false;
17870         LDKThirtyTwoBytes val_ref;
17871         CHECK(*((uint32_t*)val) == 32);
17872         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17873         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
17874 }
17875
17876 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
17877         LDKRevokeAndACK this_ptr_conv;
17878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17879         this_ptr_conv.is_owned = false;
17880         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17881         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
17882         return ret_arr;
17883 }
17884
17885 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
17886         LDKRevokeAndACK this_ptr_conv;
17887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17888         this_ptr_conv.is_owned = false;
17889         LDKThirtyTwoBytes val_ref;
17890         CHECK(*((uint32_t*)val) == 32);
17891         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17892         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
17893 }
17894
17895 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
17896         LDKRevokeAndACK this_ptr_conv;
17897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17898         this_ptr_conv.is_owned = false;
17899         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17900         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
17901         return ret_arr;
17902 }
17903
17904 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
17905         LDKRevokeAndACK this_ptr_conv;
17906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17907         this_ptr_conv.is_owned = false;
17908         LDKPublicKey val_ref;
17909         CHECK(*((uint32_t*)val) == 33);
17910         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17911         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
17912 }
17913
17914 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) {
17915         LDKThirtyTwoBytes channel_id_arg_ref;
17916         CHECK(*((uint32_t*)channel_id_arg) == 32);
17917         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17918         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
17919         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
17920         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
17921         LDKPublicKey next_per_commitment_point_arg_ref;
17922         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
17923         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
17924         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
17925         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17926         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17927         uint64_t ret_ref = (uint64_t)ret_var.inner;
17928         if (ret_var.is_owned) {
17929                 ret_ref |= 1;
17930         }
17931         return ret_ref;
17932 }
17933
17934 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
17935         LDKRevokeAndACK orig_conv;
17936         orig_conv.inner = (void*)(orig & (~1));
17937         orig_conv.is_owned = false;
17938         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
17939         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17940         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17941         uint64_t ret_ref = (uint64_t)ret_var.inner;
17942         if (ret_var.is_owned) {
17943                 ret_ref |= 1;
17944         }
17945         return ret_ref;
17946 }
17947
17948 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
17949         LDKUpdateFee this_obj_conv;
17950         this_obj_conv.inner = (void*)(this_obj & (~1));
17951         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17952         UpdateFee_free(this_obj_conv);
17953 }
17954
17955 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
17956         LDKUpdateFee this_ptr_conv;
17957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17958         this_ptr_conv.is_owned = false;
17959         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17960         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
17961         return ret_arr;
17962 }
17963
17964 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17965         LDKUpdateFee this_ptr_conv;
17966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17967         this_ptr_conv.is_owned = false;
17968         LDKThirtyTwoBytes val_ref;
17969         CHECK(*((uint32_t*)val) == 32);
17970         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17971         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
17972 }
17973
17974 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
17975         LDKUpdateFee this_ptr_conv;
17976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17977         this_ptr_conv.is_owned = false;
17978         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
17979         return ret_val;
17980 }
17981
17982 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
17983         LDKUpdateFee this_ptr_conv;
17984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17985         this_ptr_conv.is_owned = false;
17986         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
17987 }
17988
17989 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
17990         LDKThirtyTwoBytes channel_id_arg_ref;
17991         CHECK(*((uint32_t*)channel_id_arg) == 32);
17992         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17993         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
17994         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17995         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17996         uint64_t ret_ref = (uint64_t)ret_var.inner;
17997         if (ret_var.is_owned) {
17998                 ret_ref |= 1;
17999         }
18000         return ret_ref;
18001 }
18002
18003 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
18004         LDKUpdateFee orig_conv;
18005         orig_conv.inner = (void*)(orig & (~1));
18006         orig_conv.is_owned = false;
18007         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
18008         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18009         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18010         uint64_t ret_ref = (uint64_t)ret_var.inner;
18011         if (ret_var.is_owned) {
18012                 ret_ref |= 1;
18013         }
18014         return ret_ref;
18015 }
18016
18017 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
18018         LDKDataLossProtect this_obj_conv;
18019         this_obj_conv.inner = (void*)(this_obj & (~1));
18020         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18021         DataLossProtect_free(this_obj_conv);
18022 }
18023
18024 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
18025         LDKDataLossProtect this_ptr_conv;
18026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18027         this_ptr_conv.is_owned = false;
18028         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18029         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
18030         return ret_arr;
18031 }
18032
18033 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
18034         LDKDataLossProtect this_ptr_conv;
18035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18036         this_ptr_conv.is_owned = false;
18037         LDKThirtyTwoBytes val_ref;
18038         CHECK(*((uint32_t*)val) == 32);
18039         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18040         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
18041 }
18042
18043 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
18044         LDKDataLossProtect this_ptr_conv;
18045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18046         this_ptr_conv.is_owned = false;
18047         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18048         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
18049         return ret_arr;
18050 }
18051
18052 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
18053         LDKDataLossProtect this_ptr_conv;
18054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18055         this_ptr_conv.is_owned = false;
18056         LDKPublicKey val_ref;
18057         CHECK(*((uint32_t*)val) == 33);
18058         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18059         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
18060 }
18061
18062 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
18063         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
18064         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
18065         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
18066         LDKPublicKey my_current_per_commitment_point_arg_ref;
18067         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
18068         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
18069         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
18070         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18071         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18072         uint64_t ret_ref = (uint64_t)ret_var.inner;
18073         if (ret_var.is_owned) {
18074                 ret_ref |= 1;
18075         }
18076         return ret_ref;
18077 }
18078
18079 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
18080         LDKDataLossProtect orig_conv;
18081         orig_conv.inner = (void*)(orig & (~1));
18082         orig_conv.is_owned = false;
18083         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
18084         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18085         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18086         uint64_t ret_ref = (uint64_t)ret_var.inner;
18087         if (ret_var.is_owned) {
18088                 ret_ref |= 1;
18089         }
18090         return ret_ref;
18091 }
18092
18093 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
18094         LDKChannelReestablish this_obj_conv;
18095         this_obj_conv.inner = (void*)(this_obj & (~1));
18096         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18097         ChannelReestablish_free(this_obj_conv);
18098 }
18099
18100 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
18101         LDKChannelReestablish this_ptr_conv;
18102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18103         this_ptr_conv.is_owned = false;
18104         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18105         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
18106         return ret_arr;
18107 }
18108
18109 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18110         LDKChannelReestablish this_ptr_conv;
18111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18112         this_ptr_conv.is_owned = false;
18113         LDKThirtyTwoBytes val_ref;
18114         CHECK(*((uint32_t*)val) == 32);
18115         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18116         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
18117 }
18118
18119 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
18120         LDKChannelReestablish this_ptr_conv;
18121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18122         this_ptr_conv.is_owned = false;
18123         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
18124         return ret_val;
18125 }
18126
18127 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
18128         LDKChannelReestablish this_ptr_conv;
18129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18130         this_ptr_conv.is_owned = false;
18131         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
18132 }
18133
18134 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
18135         LDKChannelReestablish this_ptr_conv;
18136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18137         this_ptr_conv.is_owned = false;
18138         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
18139         return ret_val;
18140 }
18141
18142 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
18143         LDKChannelReestablish this_ptr_conv;
18144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18145         this_ptr_conv.is_owned = false;
18146         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
18147 }
18148
18149 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
18150         LDKChannelReestablish orig_conv;
18151         orig_conv.inner = (void*)(orig & (~1));
18152         orig_conv.is_owned = false;
18153         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
18154         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18155         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18156         uint64_t ret_ref = (uint64_t)ret_var.inner;
18157         if (ret_var.is_owned) {
18158                 ret_ref |= 1;
18159         }
18160         return ret_ref;
18161 }
18162
18163 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
18164         LDKAnnouncementSignatures this_obj_conv;
18165         this_obj_conv.inner = (void*)(this_obj & (~1));
18166         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18167         AnnouncementSignatures_free(this_obj_conv);
18168 }
18169
18170 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
18171         LDKAnnouncementSignatures this_ptr_conv;
18172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18173         this_ptr_conv.is_owned = false;
18174         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18175         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
18176         return ret_arr;
18177 }
18178
18179 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18180         LDKAnnouncementSignatures this_ptr_conv;
18181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18182         this_ptr_conv.is_owned = false;
18183         LDKThirtyTwoBytes val_ref;
18184         CHECK(*((uint32_t*)val) == 32);
18185         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18186         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
18187 }
18188
18189 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
18190         LDKAnnouncementSignatures this_ptr_conv;
18191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18192         this_ptr_conv.is_owned = false;
18193         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
18194         return ret_val;
18195 }
18196
18197 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
18198         LDKAnnouncementSignatures this_ptr_conv;
18199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18200         this_ptr_conv.is_owned = false;
18201         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
18202 }
18203
18204 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
18205         LDKAnnouncementSignatures this_ptr_conv;
18206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18207         this_ptr_conv.is_owned = false;
18208         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18209         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
18210         return ret_arr;
18211 }
18212
18213 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
18214         LDKAnnouncementSignatures this_ptr_conv;
18215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18216         this_ptr_conv.is_owned = false;
18217         LDKSignature val_ref;
18218         CHECK(*((uint32_t*)val) == 64);
18219         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18220         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
18221 }
18222
18223 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
18224         LDKAnnouncementSignatures this_ptr_conv;
18225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18226         this_ptr_conv.is_owned = false;
18227         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18228         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
18229         return ret_arr;
18230 }
18231
18232 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
18233         LDKAnnouncementSignatures this_ptr_conv;
18234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18235         this_ptr_conv.is_owned = false;
18236         LDKSignature val_ref;
18237         CHECK(*((uint32_t*)val) == 64);
18238         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18239         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
18240 }
18241
18242 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) {
18243         LDKThirtyTwoBytes channel_id_arg_ref;
18244         CHECK(*((uint32_t*)channel_id_arg) == 32);
18245         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
18246         LDKSignature node_signature_arg_ref;
18247         CHECK(*((uint32_t*)node_signature_arg) == 64);
18248         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
18249         LDKSignature bitcoin_signature_arg_ref;
18250         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
18251         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
18252         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
18253         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18254         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18255         uint64_t ret_ref = (uint64_t)ret_var.inner;
18256         if (ret_var.is_owned) {
18257                 ret_ref |= 1;
18258         }
18259         return ret_ref;
18260 }
18261
18262 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
18263         LDKAnnouncementSignatures orig_conv;
18264         orig_conv.inner = (void*)(orig & (~1));
18265         orig_conv.is_owned = false;
18266         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
18267         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18268         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18269         uint64_t ret_ref = (uint64_t)ret_var.inner;
18270         if (ret_var.is_owned) {
18271                 ret_ref |= 1;
18272         }
18273         return ret_ref;
18274 }
18275
18276 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
18277         if ((this_ptr & 1) != 0) return;
18278         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
18279         FREE((void*)this_ptr);
18280         NetAddress_free(this_ptr_conv);
18281 }
18282
18283 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
18284         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
18285         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18286         *ret_copy = NetAddress_clone(orig_conv);
18287         uint64_t ret_ref = (uint64_t)ret_copy;
18288         return ret_ref;
18289 }
18290
18291 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
18292         LDKFourBytes addr_ref;
18293         CHECK(*((uint32_t*)addr) == 4);
18294         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 4);
18295         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18296         *ret_copy = NetAddress_ipv4(addr_ref, port);
18297         uint64_t ret_ref = (uint64_t)ret_copy;
18298         return ret_ref;
18299 }
18300
18301 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
18302         LDKSixteenBytes addr_ref;
18303         CHECK(*((uint32_t*)addr) == 16);
18304         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 16);
18305         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18306         *ret_copy = NetAddress_ipv6(addr_ref, port);
18307         uint64_t ret_ref = (uint64_t)ret_copy;
18308         return ret_ref;
18309 }
18310
18311 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v2(int8_tArray addr, int16_t port) {
18312         LDKTenBytes addr_ref;
18313         CHECK(*((uint32_t*)addr) == 10);
18314         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 10);
18315         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18316         *ret_copy = NetAddress_onion_v2(addr_ref, port);
18317         uint64_t ret_ref = (uint64_t)ret_copy;
18318         return ret_ref;
18319 }
18320
18321 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v3(int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
18322         LDKThirtyTwoBytes ed25519_pubkey_ref;
18323         CHECK(*((uint32_t*)ed25519_pubkey) == 32);
18324         memcpy(ed25519_pubkey_ref.data, (uint8_t*)(ed25519_pubkey + 4), 32);
18325         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18326         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
18327         uint64_t ret_ref = (uint64_t)ret_copy;
18328         return ret_ref;
18329 }
18330
18331 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
18332         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
18333         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
18334         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18335         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18336         CVec_u8Z_free(ret_var);
18337         return ret_arr;
18338 }
18339
18340 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
18341         LDKu8slice ser_ref;
18342         ser_ref.datalen = *((uint32_t*)ser);
18343         ser_ref.data = (int8_t*)(ser + 4);
18344         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
18345         *ret_conv = Result_read(ser_ref);
18346         return (uint64_t)ret_conv;
18347 }
18348
18349 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
18350         LDKu8slice ser_ref;
18351         ser_ref.datalen = *((uint32_t*)ser);
18352         ser_ref.data = (int8_t*)(ser + 4);
18353         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18354         *ret_conv = NetAddress_read(ser_ref);
18355         return (uint64_t)ret_conv;
18356 }
18357
18358 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
18359         LDKUnsignedNodeAnnouncement this_obj_conv;
18360         this_obj_conv.inner = (void*)(this_obj & (~1));
18361         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18362         UnsignedNodeAnnouncement_free(this_obj_conv);
18363 }
18364
18365 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
18366         LDKUnsignedNodeAnnouncement this_ptr_conv;
18367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18368         this_ptr_conv.is_owned = false;
18369         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
18370         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18371         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18372         uint64_t ret_ref = (uint64_t)ret_var.inner;
18373         if (ret_var.is_owned) {
18374                 ret_ref |= 1;
18375         }
18376         return ret_ref;
18377 }
18378
18379 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
18380         LDKUnsignedNodeAnnouncement this_ptr_conv;
18381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18382         this_ptr_conv.is_owned = false;
18383         LDKNodeFeatures val_conv;
18384         val_conv.inner = (void*)(val & (~1));
18385         val_conv.is_owned = (val & 1) || (val == 0);
18386         val_conv = NodeFeatures_clone(&val_conv);
18387         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
18388 }
18389
18390 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
18391         LDKUnsignedNodeAnnouncement this_ptr_conv;
18392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18393         this_ptr_conv.is_owned = false;
18394         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
18395         return ret_val;
18396 }
18397
18398 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
18399         LDKUnsignedNodeAnnouncement this_ptr_conv;
18400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18401         this_ptr_conv.is_owned = false;
18402         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
18403 }
18404
18405 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
18406         LDKUnsignedNodeAnnouncement this_ptr_conv;
18407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18408         this_ptr_conv.is_owned = false;
18409         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18410         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
18411         return ret_arr;
18412 }
18413
18414 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
18415         LDKUnsignedNodeAnnouncement this_ptr_conv;
18416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18417         this_ptr_conv.is_owned = false;
18418         LDKPublicKey val_ref;
18419         CHECK(*((uint32_t*)val) == 33);
18420         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18421         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
18422 }
18423
18424 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
18425         LDKUnsignedNodeAnnouncement this_ptr_conv;
18426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18427         this_ptr_conv.is_owned = false;
18428         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
18429         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
18430         return ret_arr;
18431 }
18432
18433 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
18434         LDKUnsignedNodeAnnouncement this_ptr_conv;
18435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18436         this_ptr_conv.is_owned = false;
18437         LDKThreeBytes val_ref;
18438         CHECK(*((uint32_t*)val) == 3);
18439         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
18440         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
18441 }
18442
18443 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
18444         LDKUnsignedNodeAnnouncement this_ptr_conv;
18445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18446         this_ptr_conv.is_owned = false;
18447         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18448         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
18449         return ret_arr;
18450 }
18451
18452 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
18453         LDKUnsignedNodeAnnouncement this_ptr_conv;
18454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18455         this_ptr_conv.is_owned = false;
18456         LDKThirtyTwoBytes val_ref;
18457         CHECK(*((uint32_t*)val) == 32);
18458         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18459         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
18460 }
18461
18462 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
18463         LDKUnsignedNodeAnnouncement this_ptr_conv;
18464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18465         this_ptr_conv.is_owned = false;
18466         LDKCVec_NetAddressZ val_constr;
18467         val_constr.datalen = *((uint32_t*)val);
18468         if (val_constr.datalen > 0)
18469                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18470         else
18471                 val_constr.data = NULL;
18472         uint32_t* val_vals = (uint32_t*)(val + 4);
18473         for (size_t m = 0; m < val_constr.datalen; m++) {
18474                 uint32_t val_conv_12 = val_vals[m];
18475                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
18476                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
18477                 val_constr.data[m] = val_conv_12_conv;
18478         }
18479         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
18480 }
18481
18482 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
18483         LDKUnsignedNodeAnnouncement orig_conv;
18484         orig_conv.inner = (void*)(orig & (~1));
18485         orig_conv.is_owned = false;
18486         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
18487         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18488         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18489         uint64_t ret_ref = (uint64_t)ret_var.inner;
18490         if (ret_var.is_owned) {
18491                 ret_ref |= 1;
18492         }
18493         return ret_ref;
18494 }
18495
18496 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
18497         LDKNodeAnnouncement this_obj_conv;
18498         this_obj_conv.inner = (void*)(this_obj & (~1));
18499         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18500         NodeAnnouncement_free(this_obj_conv);
18501 }
18502
18503 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
18504         LDKNodeAnnouncement this_ptr_conv;
18505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18506         this_ptr_conv.is_owned = false;
18507         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18508         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
18509         return ret_arr;
18510 }
18511
18512 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
18513         LDKNodeAnnouncement this_ptr_conv;
18514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18515         this_ptr_conv.is_owned = false;
18516         LDKSignature val_ref;
18517         CHECK(*((uint32_t*)val) == 64);
18518         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18519         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
18520 }
18521
18522 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
18523         LDKNodeAnnouncement this_ptr_conv;
18524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18525         this_ptr_conv.is_owned = false;
18526         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
18527         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18528         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18529         uint64_t ret_ref = (uint64_t)ret_var.inner;
18530         if (ret_var.is_owned) {
18531                 ret_ref |= 1;
18532         }
18533         return ret_ref;
18534 }
18535
18536 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
18537         LDKNodeAnnouncement this_ptr_conv;
18538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18539         this_ptr_conv.is_owned = false;
18540         LDKUnsignedNodeAnnouncement val_conv;
18541         val_conv.inner = (void*)(val & (~1));
18542         val_conv.is_owned = (val & 1) || (val == 0);
18543         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
18544         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
18545 }
18546
18547 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
18548         LDKSignature signature_arg_ref;
18549         CHECK(*((uint32_t*)signature_arg) == 64);
18550         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
18551         LDKUnsignedNodeAnnouncement contents_arg_conv;
18552         contents_arg_conv.inner = (void*)(contents_arg & (~1));
18553         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
18554         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
18555         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
18556         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18557         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18558         uint64_t ret_ref = (uint64_t)ret_var.inner;
18559         if (ret_var.is_owned) {
18560                 ret_ref |= 1;
18561         }
18562         return ret_ref;
18563 }
18564
18565 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
18566         LDKNodeAnnouncement orig_conv;
18567         orig_conv.inner = (void*)(orig & (~1));
18568         orig_conv.is_owned = false;
18569         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
18570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18572         uint64_t ret_ref = (uint64_t)ret_var.inner;
18573         if (ret_var.is_owned) {
18574                 ret_ref |= 1;
18575         }
18576         return ret_ref;
18577 }
18578
18579 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
18580         LDKUnsignedChannelAnnouncement this_obj_conv;
18581         this_obj_conv.inner = (void*)(this_obj & (~1));
18582         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18583         UnsignedChannelAnnouncement_free(this_obj_conv);
18584 }
18585
18586 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
18587         LDKUnsignedChannelAnnouncement this_ptr_conv;
18588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18589         this_ptr_conv.is_owned = false;
18590         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
18591         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18592         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18593         uint64_t ret_ref = (uint64_t)ret_var.inner;
18594         if (ret_var.is_owned) {
18595                 ret_ref |= 1;
18596         }
18597         return ret_ref;
18598 }
18599
18600 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
18601         LDKUnsignedChannelAnnouncement this_ptr_conv;
18602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18603         this_ptr_conv.is_owned = false;
18604         LDKChannelFeatures val_conv;
18605         val_conv.inner = (void*)(val & (~1));
18606         val_conv.is_owned = (val & 1) || (val == 0);
18607         val_conv = ChannelFeatures_clone(&val_conv);
18608         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
18609 }
18610
18611 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
18612         LDKUnsignedChannelAnnouncement this_ptr_conv;
18613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18614         this_ptr_conv.is_owned = false;
18615         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18616         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
18617         return ret_arr;
18618 }
18619
18620 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
18621         LDKUnsignedChannelAnnouncement this_ptr_conv;
18622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18623         this_ptr_conv.is_owned = false;
18624         LDKThirtyTwoBytes val_ref;
18625         CHECK(*((uint32_t*)val) == 32);
18626         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18627         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
18628 }
18629
18630 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
18631         LDKUnsignedChannelAnnouncement this_ptr_conv;
18632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18633         this_ptr_conv.is_owned = false;
18634         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
18635         return ret_val;
18636 }
18637
18638 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
18639         LDKUnsignedChannelAnnouncement this_ptr_conv;
18640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18641         this_ptr_conv.is_owned = false;
18642         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
18643 }
18644
18645 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
18646         LDKUnsignedChannelAnnouncement this_ptr_conv;
18647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18648         this_ptr_conv.is_owned = false;
18649         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18650         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
18651         return ret_arr;
18652 }
18653
18654 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
18655         LDKUnsignedChannelAnnouncement this_ptr_conv;
18656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18657         this_ptr_conv.is_owned = false;
18658         LDKPublicKey val_ref;
18659         CHECK(*((uint32_t*)val) == 33);
18660         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18661         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
18662 }
18663
18664 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
18665         LDKUnsignedChannelAnnouncement this_ptr_conv;
18666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18667         this_ptr_conv.is_owned = false;
18668         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18669         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
18670         return ret_arr;
18671 }
18672
18673 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
18674         LDKUnsignedChannelAnnouncement this_ptr_conv;
18675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18676         this_ptr_conv.is_owned = false;
18677         LDKPublicKey val_ref;
18678         CHECK(*((uint32_t*)val) == 33);
18679         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18680         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
18681 }
18682
18683 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
18684         LDKUnsignedChannelAnnouncement this_ptr_conv;
18685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18686         this_ptr_conv.is_owned = false;
18687         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18688         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
18689         return ret_arr;
18690 }
18691
18692 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
18693         LDKUnsignedChannelAnnouncement this_ptr_conv;
18694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18695         this_ptr_conv.is_owned = false;
18696         LDKPublicKey val_ref;
18697         CHECK(*((uint32_t*)val) == 33);
18698         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18699         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
18700 }
18701
18702 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
18703         LDKUnsignedChannelAnnouncement this_ptr_conv;
18704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18705         this_ptr_conv.is_owned = false;
18706         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18707         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
18708         return ret_arr;
18709 }
18710
18711 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
18712         LDKUnsignedChannelAnnouncement this_ptr_conv;
18713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18714         this_ptr_conv.is_owned = false;
18715         LDKPublicKey val_ref;
18716         CHECK(*((uint32_t*)val) == 33);
18717         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18718         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
18719 }
18720
18721 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
18722         LDKUnsignedChannelAnnouncement orig_conv;
18723         orig_conv.inner = (void*)(orig & (~1));
18724         orig_conv.is_owned = false;
18725         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
18726         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18727         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18728         uint64_t ret_ref = (uint64_t)ret_var.inner;
18729         if (ret_var.is_owned) {
18730                 ret_ref |= 1;
18731         }
18732         return ret_ref;
18733 }
18734
18735 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
18736         LDKChannelAnnouncement this_obj_conv;
18737         this_obj_conv.inner = (void*)(this_obj & (~1));
18738         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18739         ChannelAnnouncement_free(this_obj_conv);
18740 }
18741
18742 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
18743         LDKChannelAnnouncement this_ptr_conv;
18744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18745         this_ptr_conv.is_owned = false;
18746         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18747         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
18748         return ret_arr;
18749 }
18750
18751 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
18752         LDKChannelAnnouncement this_ptr_conv;
18753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18754         this_ptr_conv.is_owned = false;
18755         LDKSignature val_ref;
18756         CHECK(*((uint32_t*)val) == 64);
18757         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18758         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
18759 }
18760
18761 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
18762         LDKChannelAnnouncement this_ptr_conv;
18763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18764         this_ptr_conv.is_owned = false;
18765         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18766         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
18767         return ret_arr;
18768 }
18769
18770 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
18771         LDKChannelAnnouncement this_ptr_conv;
18772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18773         this_ptr_conv.is_owned = false;
18774         LDKSignature val_ref;
18775         CHECK(*((uint32_t*)val) == 64);
18776         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18777         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
18778 }
18779
18780 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
18781         LDKChannelAnnouncement this_ptr_conv;
18782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18783         this_ptr_conv.is_owned = false;
18784         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18785         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
18786         return ret_arr;
18787 }
18788
18789 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
18790         LDKChannelAnnouncement this_ptr_conv;
18791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18792         this_ptr_conv.is_owned = false;
18793         LDKSignature val_ref;
18794         CHECK(*((uint32_t*)val) == 64);
18795         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18796         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
18797 }
18798
18799 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
18800         LDKChannelAnnouncement this_ptr_conv;
18801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18802         this_ptr_conv.is_owned = false;
18803         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18804         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
18805         return ret_arr;
18806 }
18807
18808 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
18809         LDKChannelAnnouncement this_ptr_conv;
18810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18811         this_ptr_conv.is_owned = false;
18812         LDKSignature val_ref;
18813         CHECK(*((uint32_t*)val) == 64);
18814         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18815         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
18816 }
18817
18818 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
18819         LDKChannelAnnouncement this_ptr_conv;
18820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18821         this_ptr_conv.is_owned = false;
18822         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
18823         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18824         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18825         uint64_t ret_ref = (uint64_t)ret_var.inner;
18826         if (ret_var.is_owned) {
18827                 ret_ref |= 1;
18828         }
18829         return ret_ref;
18830 }
18831
18832 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
18833         LDKChannelAnnouncement this_ptr_conv;
18834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18835         this_ptr_conv.is_owned = false;
18836         LDKUnsignedChannelAnnouncement val_conv;
18837         val_conv.inner = (void*)(val & (~1));
18838         val_conv.is_owned = (val & 1) || (val == 0);
18839         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
18840         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
18841 }
18842
18843 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) {
18844         LDKSignature node_signature_1_arg_ref;
18845         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
18846         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
18847         LDKSignature node_signature_2_arg_ref;
18848         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
18849         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
18850         LDKSignature bitcoin_signature_1_arg_ref;
18851         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
18852         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
18853         LDKSignature bitcoin_signature_2_arg_ref;
18854         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
18855         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
18856         LDKUnsignedChannelAnnouncement contents_arg_conv;
18857         contents_arg_conv.inner = (void*)(contents_arg & (~1));
18858         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
18859         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
18860         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);
18861         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18862         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18863         uint64_t ret_ref = (uint64_t)ret_var.inner;
18864         if (ret_var.is_owned) {
18865                 ret_ref |= 1;
18866         }
18867         return ret_ref;
18868 }
18869
18870 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
18871         LDKChannelAnnouncement orig_conv;
18872         orig_conv.inner = (void*)(orig & (~1));
18873         orig_conv.is_owned = false;
18874         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
18875         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18876         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18877         uint64_t ret_ref = (uint64_t)ret_var.inner;
18878         if (ret_var.is_owned) {
18879                 ret_ref |= 1;
18880         }
18881         return ret_ref;
18882 }
18883
18884 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
18885         LDKUnsignedChannelUpdate this_obj_conv;
18886         this_obj_conv.inner = (void*)(this_obj & (~1));
18887         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18888         UnsignedChannelUpdate_free(this_obj_conv);
18889 }
18890
18891 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
18892         LDKUnsignedChannelUpdate this_ptr_conv;
18893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18894         this_ptr_conv.is_owned = false;
18895         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18896         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
18897         return ret_arr;
18898 }
18899
18900 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
18901         LDKUnsignedChannelUpdate this_ptr_conv;
18902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18903         this_ptr_conv.is_owned = false;
18904         LDKThirtyTwoBytes val_ref;
18905         CHECK(*((uint32_t*)val) == 32);
18906         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18907         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
18908 }
18909
18910 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
18911         LDKUnsignedChannelUpdate this_ptr_conv;
18912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18913         this_ptr_conv.is_owned = false;
18914         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
18915         return ret_val;
18916 }
18917
18918 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
18919         LDKUnsignedChannelUpdate this_ptr_conv;
18920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18921         this_ptr_conv.is_owned = false;
18922         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
18923 }
18924
18925 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
18926         LDKUnsignedChannelUpdate this_ptr_conv;
18927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18928         this_ptr_conv.is_owned = false;
18929         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
18930         return ret_val;
18931 }
18932
18933 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
18934         LDKUnsignedChannelUpdate this_ptr_conv;
18935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18936         this_ptr_conv.is_owned = false;
18937         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
18938 }
18939
18940 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
18941         LDKUnsignedChannelUpdate this_ptr_conv;
18942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18943         this_ptr_conv.is_owned = false;
18944         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
18945         return ret_val;
18946 }
18947
18948 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
18949         LDKUnsignedChannelUpdate this_ptr_conv;
18950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18951         this_ptr_conv.is_owned = false;
18952         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
18953 }
18954
18955 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
18956         LDKUnsignedChannelUpdate this_ptr_conv;
18957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18958         this_ptr_conv.is_owned = false;
18959         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
18960         return ret_val;
18961 }
18962
18963 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
18964         LDKUnsignedChannelUpdate this_ptr_conv;
18965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18966         this_ptr_conv.is_owned = false;
18967         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
18968 }
18969
18970 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
18971         LDKUnsignedChannelUpdate this_ptr_conv;
18972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18973         this_ptr_conv.is_owned = false;
18974         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
18975         return ret_val;
18976 }
18977
18978 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
18979         LDKUnsignedChannelUpdate this_ptr_conv;
18980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18981         this_ptr_conv.is_owned = false;
18982         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
18983 }
18984
18985 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
18986         LDKUnsignedChannelUpdate this_ptr_conv;
18987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18988         this_ptr_conv.is_owned = false;
18989         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
18990         return ret_val;
18991 }
18992
18993 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
18994         LDKUnsignedChannelUpdate this_ptr_conv;
18995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18996         this_ptr_conv.is_owned = false;
18997         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
18998 }
18999
19000 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
19001         LDKUnsignedChannelUpdate this_ptr_conv;
19002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19003         this_ptr_conv.is_owned = false;
19004         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
19005         return ret_val;
19006 }
19007
19008 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
19009         LDKUnsignedChannelUpdate this_ptr_conv;
19010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19011         this_ptr_conv.is_owned = false;
19012         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
19013 }
19014
19015 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
19016         LDKUnsignedChannelUpdate orig_conv;
19017         orig_conv.inner = (void*)(orig & (~1));
19018         orig_conv.is_owned = false;
19019         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
19020         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19021         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19022         uint64_t ret_ref = (uint64_t)ret_var.inner;
19023         if (ret_var.is_owned) {
19024                 ret_ref |= 1;
19025         }
19026         return ret_ref;
19027 }
19028
19029 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
19030         LDKChannelUpdate this_obj_conv;
19031         this_obj_conv.inner = (void*)(this_obj & (~1));
19032         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19033         ChannelUpdate_free(this_obj_conv);
19034 }
19035
19036 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
19037         LDKChannelUpdate this_ptr_conv;
19038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19039         this_ptr_conv.is_owned = false;
19040         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19041         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
19042         return ret_arr;
19043 }
19044
19045 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
19046         LDKChannelUpdate this_ptr_conv;
19047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19048         this_ptr_conv.is_owned = false;
19049         LDKSignature val_ref;
19050         CHECK(*((uint32_t*)val) == 64);
19051         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19052         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
19053 }
19054
19055 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
19056         LDKChannelUpdate this_ptr_conv;
19057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19058         this_ptr_conv.is_owned = false;
19059         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
19060         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19061         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19062         uint64_t ret_ref = (uint64_t)ret_var.inner;
19063         if (ret_var.is_owned) {
19064                 ret_ref |= 1;
19065         }
19066         return ret_ref;
19067 }
19068
19069 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
19070         LDKChannelUpdate this_ptr_conv;
19071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19072         this_ptr_conv.is_owned = false;
19073         LDKUnsignedChannelUpdate val_conv;
19074         val_conv.inner = (void*)(val & (~1));
19075         val_conv.is_owned = (val & 1) || (val == 0);
19076         val_conv = UnsignedChannelUpdate_clone(&val_conv);
19077         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
19078 }
19079
19080 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
19081         LDKSignature signature_arg_ref;
19082         CHECK(*((uint32_t*)signature_arg) == 64);
19083         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
19084         LDKUnsignedChannelUpdate contents_arg_conv;
19085         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19086         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19087         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
19088         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
19089         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19090         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19091         uint64_t ret_ref = (uint64_t)ret_var.inner;
19092         if (ret_var.is_owned) {
19093                 ret_ref |= 1;
19094         }
19095         return ret_ref;
19096 }
19097
19098 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
19099         LDKChannelUpdate orig_conv;
19100         orig_conv.inner = (void*)(orig & (~1));
19101         orig_conv.is_owned = false;
19102         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
19103         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19104         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19105         uint64_t ret_ref = (uint64_t)ret_var.inner;
19106         if (ret_var.is_owned) {
19107                 ret_ref |= 1;
19108         }
19109         return ret_ref;
19110 }
19111
19112 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
19113         LDKQueryChannelRange this_obj_conv;
19114         this_obj_conv.inner = (void*)(this_obj & (~1));
19115         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19116         QueryChannelRange_free(this_obj_conv);
19117 }
19118
19119 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
19120         LDKQueryChannelRange this_ptr_conv;
19121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19122         this_ptr_conv.is_owned = false;
19123         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19124         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
19125         return ret_arr;
19126 }
19127
19128 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19129         LDKQueryChannelRange this_ptr_conv;
19130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19131         this_ptr_conv.is_owned = false;
19132         LDKThirtyTwoBytes val_ref;
19133         CHECK(*((uint32_t*)val) == 32);
19134         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19135         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19136 }
19137
19138 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
19139         LDKQueryChannelRange this_ptr_conv;
19140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19141         this_ptr_conv.is_owned = false;
19142         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
19143         return ret_val;
19144 }
19145
19146 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
19147         LDKQueryChannelRange this_ptr_conv;
19148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19149         this_ptr_conv.is_owned = false;
19150         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
19151 }
19152
19153 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
19154         LDKQueryChannelRange this_ptr_conv;
19155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19156         this_ptr_conv.is_owned = false;
19157         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
19158         return ret_val;
19159 }
19160
19161 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
19162         LDKQueryChannelRange this_ptr_conv;
19163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19164         this_ptr_conv.is_owned = false;
19165         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19166 }
19167
19168 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
19169         LDKThirtyTwoBytes chain_hash_arg_ref;
19170         CHECK(*((uint32_t*)chain_hash_arg) == 32);
19171         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
19172         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
19173         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19174         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19175         uint64_t ret_ref = (uint64_t)ret_var.inner;
19176         if (ret_var.is_owned) {
19177                 ret_ref |= 1;
19178         }
19179         return ret_ref;
19180 }
19181
19182 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
19183         LDKQueryChannelRange orig_conv;
19184         orig_conv.inner = (void*)(orig & (~1));
19185         orig_conv.is_owned = false;
19186         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
19187         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19188         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19189         uint64_t ret_ref = (uint64_t)ret_var.inner;
19190         if (ret_var.is_owned) {
19191                 ret_ref |= 1;
19192         }
19193         return ret_ref;
19194 }
19195
19196 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
19197         LDKReplyChannelRange this_obj_conv;
19198         this_obj_conv.inner = (void*)(this_obj & (~1));
19199         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19200         ReplyChannelRange_free(this_obj_conv);
19201 }
19202
19203 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
19204         LDKReplyChannelRange this_ptr_conv;
19205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19206         this_ptr_conv.is_owned = false;
19207         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19208         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
19209         return ret_arr;
19210 }
19211
19212 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19213         LDKReplyChannelRange this_ptr_conv;
19214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19215         this_ptr_conv.is_owned = false;
19216         LDKThirtyTwoBytes val_ref;
19217         CHECK(*((uint32_t*)val) == 32);
19218         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19219         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19220 }
19221
19222 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
19223         LDKReplyChannelRange this_ptr_conv;
19224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19225         this_ptr_conv.is_owned = false;
19226         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
19227         return ret_val;
19228 }
19229
19230 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
19231         LDKReplyChannelRange this_ptr_conv;
19232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19233         this_ptr_conv.is_owned = false;
19234         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
19235 }
19236
19237 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
19238         LDKReplyChannelRange this_ptr_conv;
19239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19240         this_ptr_conv.is_owned = false;
19241         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
19242         return ret_val;
19243 }
19244
19245 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
19246         LDKReplyChannelRange this_ptr_conv;
19247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19248         this_ptr_conv.is_owned = false;
19249         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19250 }
19251
19252 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
19253         LDKReplyChannelRange this_ptr_conv;
19254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19255         this_ptr_conv.is_owned = false;
19256         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
19257         return ret_val;
19258 }
19259
19260 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
19261         LDKReplyChannelRange this_ptr_conv;
19262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19263         this_ptr_conv.is_owned = false;
19264         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
19265 }
19266
19267 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
19268         LDKReplyChannelRange this_ptr_conv;
19269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19270         this_ptr_conv.is_owned = false;
19271         LDKCVec_u64Z val_constr;
19272         val_constr.datalen = *((uint32_t*)val);
19273         if (val_constr.datalen > 0)
19274                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19275         else
19276                 val_constr.data = NULL;
19277         int64_t* val_vals = (int64_t*)(val + 4);
19278         for (size_t i = 0; i < val_constr.datalen; i++) {
19279                 int64_t val_conv_8 = val_vals[i];
19280                 val_constr.data[i] = val_conv_8;
19281         }
19282         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
19283 }
19284
19285 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) {
19286         LDKThirtyTwoBytes chain_hash_arg_ref;
19287         CHECK(*((uint32_t*)chain_hash_arg) == 32);
19288         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
19289         LDKCVec_u64Z short_channel_ids_arg_constr;
19290         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
19291         if (short_channel_ids_arg_constr.datalen > 0)
19292                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19293         else
19294                 short_channel_ids_arg_constr.data = NULL;
19295         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
19296         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
19297                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
19298                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
19299         }
19300         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
19301         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19302         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19303         uint64_t ret_ref = (uint64_t)ret_var.inner;
19304         if (ret_var.is_owned) {
19305                 ret_ref |= 1;
19306         }
19307         return ret_ref;
19308 }
19309
19310 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
19311         LDKReplyChannelRange orig_conv;
19312         orig_conv.inner = (void*)(orig & (~1));
19313         orig_conv.is_owned = false;
19314         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
19315         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19316         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19317         uint64_t ret_ref = (uint64_t)ret_var.inner;
19318         if (ret_var.is_owned) {
19319                 ret_ref |= 1;
19320         }
19321         return ret_ref;
19322 }
19323
19324 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
19325         LDKQueryShortChannelIds this_obj_conv;
19326         this_obj_conv.inner = (void*)(this_obj & (~1));
19327         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19328         QueryShortChannelIds_free(this_obj_conv);
19329 }
19330
19331 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
19332         LDKQueryShortChannelIds this_ptr_conv;
19333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19334         this_ptr_conv.is_owned = false;
19335         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19336         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
19337         return ret_arr;
19338 }
19339
19340 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19341         LDKQueryShortChannelIds this_ptr_conv;
19342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19343         this_ptr_conv.is_owned = false;
19344         LDKThirtyTwoBytes val_ref;
19345         CHECK(*((uint32_t*)val) == 32);
19346         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19347         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
19348 }
19349
19350 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
19351         LDKQueryShortChannelIds this_ptr_conv;
19352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19353         this_ptr_conv.is_owned = false;
19354         LDKCVec_u64Z val_constr;
19355         val_constr.datalen = *((uint32_t*)val);
19356         if (val_constr.datalen > 0)
19357                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19358         else
19359                 val_constr.data = NULL;
19360         int64_t* val_vals = (int64_t*)(val + 4);
19361         for (size_t i = 0; i < val_constr.datalen; i++) {
19362                 int64_t val_conv_8 = val_vals[i];
19363                 val_constr.data[i] = val_conv_8;
19364         }
19365         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
19366 }
19367
19368 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
19369         LDKThirtyTwoBytes chain_hash_arg_ref;
19370         CHECK(*((uint32_t*)chain_hash_arg) == 32);
19371         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
19372         LDKCVec_u64Z short_channel_ids_arg_constr;
19373         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
19374         if (short_channel_ids_arg_constr.datalen > 0)
19375                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19376         else
19377                 short_channel_ids_arg_constr.data = NULL;
19378         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
19379         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
19380                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
19381                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
19382         }
19383         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
19384         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19385         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19386         uint64_t ret_ref = (uint64_t)ret_var.inner;
19387         if (ret_var.is_owned) {
19388                 ret_ref |= 1;
19389         }
19390         return ret_ref;
19391 }
19392
19393 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
19394         LDKQueryShortChannelIds orig_conv;
19395         orig_conv.inner = (void*)(orig & (~1));
19396         orig_conv.is_owned = false;
19397         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
19398         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19399         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19400         uint64_t ret_ref = (uint64_t)ret_var.inner;
19401         if (ret_var.is_owned) {
19402                 ret_ref |= 1;
19403         }
19404         return ret_ref;
19405 }
19406
19407 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
19408         LDKReplyShortChannelIdsEnd this_obj_conv;
19409         this_obj_conv.inner = (void*)(this_obj & (~1));
19410         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19411         ReplyShortChannelIdsEnd_free(this_obj_conv);
19412 }
19413
19414 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
19415         LDKReplyShortChannelIdsEnd this_ptr_conv;
19416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19417         this_ptr_conv.is_owned = false;
19418         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19419         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
19420         return ret_arr;
19421 }
19422
19423 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19424         LDKReplyShortChannelIdsEnd this_ptr_conv;
19425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19426         this_ptr_conv.is_owned = false;
19427         LDKThirtyTwoBytes val_ref;
19428         CHECK(*((uint32_t*)val) == 32);
19429         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19430         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
19431 }
19432
19433 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
19434         LDKReplyShortChannelIdsEnd this_ptr_conv;
19435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19436         this_ptr_conv.is_owned = false;
19437         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
19438         return ret_val;
19439 }
19440
19441 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
19442         LDKReplyShortChannelIdsEnd this_ptr_conv;
19443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19444         this_ptr_conv.is_owned = false;
19445         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
19446 }
19447
19448 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
19449         LDKThirtyTwoBytes chain_hash_arg_ref;
19450         CHECK(*((uint32_t*)chain_hash_arg) == 32);
19451         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
19452         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
19453         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19454         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19455         uint64_t ret_ref = (uint64_t)ret_var.inner;
19456         if (ret_var.is_owned) {
19457                 ret_ref |= 1;
19458         }
19459         return ret_ref;
19460 }
19461
19462 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
19463         LDKReplyShortChannelIdsEnd orig_conv;
19464         orig_conv.inner = (void*)(orig & (~1));
19465         orig_conv.is_owned = false;
19466         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
19467         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19468         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19469         uint64_t ret_ref = (uint64_t)ret_var.inner;
19470         if (ret_var.is_owned) {
19471                 ret_ref |= 1;
19472         }
19473         return ret_ref;
19474 }
19475
19476 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
19477         LDKGossipTimestampFilter this_obj_conv;
19478         this_obj_conv.inner = (void*)(this_obj & (~1));
19479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19480         GossipTimestampFilter_free(this_obj_conv);
19481 }
19482
19483 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
19484         LDKGossipTimestampFilter this_ptr_conv;
19485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19486         this_ptr_conv.is_owned = false;
19487         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19488         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
19489         return ret_arr;
19490 }
19491
19492 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19493         LDKGossipTimestampFilter this_ptr_conv;
19494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19495         this_ptr_conv.is_owned = false;
19496         LDKThirtyTwoBytes val_ref;
19497         CHECK(*((uint32_t*)val) == 32);
19498         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19499         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
19500 }
19501
19502 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
19503         LDKGossipTimestampFilter this_ptr_conv;
19504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19505         this_ptr_conv.is_owned = false;
19506         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
19507         return ret_val;
19508 }
19509
19510 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
19511         LDKGossipTimestampFilter this_ptr_conv;
19512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19513         this_ptr_conv.is_owned = false;
19514         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
19515 }
19516
19517 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
19518         LDKGossipTimestampFilter this_ptr_conv;
19519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19520         this_ptr_conv.is_owned = false;
19521         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
19522         return ret_val;
19523 }
19524
19525 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
19526         LDKGossipTimestampFilter this_ptr_conv;
19527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19528         this_ptr_conv.is_owned = false;
19529         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
19530 }
19531
19532 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
19533         LDKThirtyTwoBytes chain_hash_arg_ref;
19534         CHECK(*((uint32_t*)chain_hash_arg) == 32);
19535         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
19536         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
19537         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19538         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19539         uint64_t ret_ref = (uint64_t)ret_var.inner;
19540         if (ret_var.is_owned) {
19541                 ret_ref |= 1;
19542         }
19543         return ret_ref;
19544 }
19545
19546 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
19547         LDKGossipTimestampFilter orig_conv;
19548         orig_conv.inner = (void*)(orig & (~1));
19549         orig_conv.is_owned = false;
19550         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
19551         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19552         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19553         uint64_t ret_ref = (uint64_t)ret_var.inner;
19554         if (ret_var.is_owned) {
19555                 ret_ref |= 1;
19556         }
19557         return ret_ref;
19558 }
19559
19560 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
19561         if ((this_ptr & 1) != 0) return;
19562         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
19563         FREE((void*)this_ptr);
19564         ErrorAction_free(this_ptr_conv);
19565 }
19566
19567 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
19568         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
19569         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19570         *ret_copy = ErrorAction_clone(orig_conv);
19571         uint64_t ret_ref = (uint64_t)ret_copy;
19572         return ret_ref;
19573 }
19574
19575 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
19576         LDKErrorMessage msg_conv;
19577         msg_conv.inner = (void*)(msg & (~1));
19578         msg_conv.is_owned = (msg & 1) || (msg == 0);
19579         msg_conv = ErrorMessage_clone(&msg_conv);
19580         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19581         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
19582         uint64_t ret_ref = (uint64_t)ret_copy;
19583         return ret_ref;
19584 }
19585
19586 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_error() {
19587         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19588         *ret_copy = ErrorAction_ignore_error();
19589         uint64_t ret_ref = (uint64_t)ret_copy;
19590         return ret_ref;
19591 }
19592
19593 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
19594         LDKLevel a_conv = LDKLevel_from_js(a);
19595         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19596         *ret_copy = ErrorAction_ignore_and_log(a_conv);
19597         uint64_t ret_ref = (uint64_t)ret_copy;
19598         return ret_ref;
19599 }
19600
19601 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_send_error_message(uint32_t msg) {
19602         LDKErrorMessage msg_conv;
19603         msg_conv.inner = (void*)(msg & (~1));
19604         msg_conv.is_owned = (msg & 1) || (msg == 0);
19605         msg_conv = ErrorMessage_clone(&msg_conv);
19606         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19607         *ret_copy = ErrorAction_send_error_message(msg_conv);
19608         uint64_t ret_ref = (uint64_t)ret_copy;
19609         return ret_ref;
19610 }
19611
19612 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
19613         LDKLightningError this_obj_conv;
19614         this_obj_conv.inner = (void*)(this_obj & (~1));
19615         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19616         LightningError_free(this_obj_conv);
19617 }
19618
19619 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
19620         LDKLightningError this_ptr_conv;
19621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19622         this_ptr_conv.is_owned = false;
19623         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
19624         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
19625         Str_free(ret_str);
19626         return ret_conv;
19627 }
19628
19629 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
19630         LDKLightningError this_ptr_conv;
19631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19632         this_ptr_conv.is_owned = false;
19633         LDKStr val_conv = str_ref_to_owned_c(val);
19634         LightningError_set_err(&this_ptr_conv, val_conv);
19635 }
19636
19637 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
19638         LDKLightningError this_ptr_conv;
19639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19640         this_ptr_conv.is_owned = false;
19641         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19642         *ret_copy = LightningError_get_action(&this_ptr_conv);
19643         uint64_t ret_ref = (uint64_t)ret_copy;
19644         return ret_ref;
19645 }
19646
19647 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
19648         LDKLightningError this_ptr_conv;
19649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19650         this_ptr_conv.is_owned = false;
19651         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
19652         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
19653         LightningError_set_action(&this_ptr_conv, val_conv);
19654 }
19655
19656 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
19657         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
19658         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
19659         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
19660         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
19661         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19662         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19663         uint64_t ret_ref = (uint64_t)ret_var.inner;
19664         if (ret_var.is_owned) {
19665                 ret_ref |= 1;
19666         }
19667         return ret_ref;
19668 }
19669
19670 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
19671         LDKLightningError orig_conv;
19672         orig_conv.inner = (void*)(orig & (~1));
19673         orig_conv.is_owned = false;
19674         LDKLightningError ret_var = LightningError_clone(&orig_conv);
19675         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19676         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19677         uint64_t ret_ref = (uint64_t)ret_var.inner;
19678         if (ret_var.is_owned) {
19679                 ret_ref |= 1;
19680         }
19681         return ret_ref;
19682 }
19683
19684 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
19685         LDKCommitmentUpdate this_obj_conv;
19686         this_obj_conv.inner = (void*)(this_obj & (~1));
19687         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19688         CommitmentUpdate_free(this_obj_conv);
19689 }
19690
19691 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
19692         LDKCommitmentUpdate this_ptr_conv;
19693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19694         this_ptr_conv.is_owned = false;
19695         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
19696         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19697         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19698         for (size_t p = 0; p < ret_var.datalen; p++) {
19699                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
19700                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19701                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19702                 uint64_t ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
19703                 if (ret_conv_15_var.is_owned) {
19704                         ret_conv_15_ref |= 1;
19705                 }
19706                 ret_arr_ptr[p] = ret_conv_15_ref;
19707         }
19708         FREE(ret_var.data);
19709         return ret_arr;
19710 }
19711
19712 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
19713         LDKCommitmentUpdate this_ptr_conv;
19714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19715         this_ptr_conv.is_owned = false;
19716         LDKCVec_UpdateAddHTLCZ val_constr;
19717         val_constr.datalen = *((uint32_t*)val);
19718         if (val_constr.datalen > 0)
19719                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
19720         else
19721                 val_constr.data = NULL;
19722         uint32_t* val_vals = (uint32_t*)(val + 4);
19723         for (size_t p = 0; p < val_constr.datalen; p++) {
19724                 uint32_t val_conv_15 = val_vals[p];
19725                 LDKUpdateAddHTLC val_conv_15_conv;
19726                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
19727                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
19728                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
19729                 val_constr.data[p] = val_conv_15_conv;
19730         }
19731         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
19732 }
19733
19734 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
19735         LDKCommitmentUpdate this_ptr_conv;
19736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19737         this_ptr_conv.is_owned = false;
19738         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
19739         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19740         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19741         for (size_t t = 0; t < ret_var.datalen; t++) {
19742                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
19743                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19744                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19745                 uint64_t ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
19746                 if (ret_conv_19_var.is_owned) {
19747                         ret_conv_19_ref |= 1;
19748                 }
19749                 ret_arr_ptr[t] = ret_conv_19_ref;
19750         }
19751         FREE(ret_var.data);
19752         return ret_arr;
19753 }
19754
19755 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
19756         LDKCommitmentUpdate this_ptr_conv;
19757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19758         this_ptr_conv.is_owned = false;
19759         LDKCVec_UpdateFulfillHTLCZ val_constr;
19760         val_constr.datalen = *((uint32_t*)val);
19761         if (val_constr.datalen > 0)
19762                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
19763         else
19764                 val_constr.data = NULL;
19765         uint32_t* val_vals = (uint32_t*)(val + 4);
19766         for (size_t t = 0; t < val_constr.datalen; t++) {
19767                 uint32_t val_conv_19 = val_vals[t];
19768                 LDKUpdateFulfillHTLC val_conv_19_conv;
19769                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
19770                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
19771                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
19772                 val_constr.data[t] = val_conv_19_conv;
19773         }
19774         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
19775 }
19776
19777 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
19778         LDKCommitmentUpdate this_ptr_conv;
19779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19780         this_ptr_conv.is_owned = false;
19781         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
19782         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19783         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19784         for (size_t q = 0; q < ret_var.datalen; q++) {
19785                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
19786                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19787                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19788                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
19789                 if (ret_conv_16_var.is_owned) {
19790                         ret_conv_16_ref |= 1;
19791                 }
19792                 ret_arr_ptr[q] = ret_conv_16_ref;
19793         }
19794         FREE(ret_var.data);
19795         return ret_arr;
19796 }
19797
19798 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
19799         LDKCommitmentUpdate this_ptr_conv;
19800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19801         this_ptr_conv.is_owned = false;
19802         LDKCVec_UpdateFailHTLCZ val_constr;
19803         val_constr.datalen = *((uint32_t*)val);
19804         if (val_constr.datalen > 0)
19805                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
19806         else
19807                 val_constr.data = NULL;
19808         uint32_t* val_vals = (uint32_t*)(val + 4);
19809         for (size_t q = 0; q < val_constr.datalen; q++) {
19810                 uint32_t val_conv_16 = val_vals[q];
19811                 LDKUpdateFailHTLC val_conv_16_conv;
19812                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
19813                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
19814                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
19815                 val_constr.data[q] = val_conv_16_conv;
19816         }
19817         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
19818 }
19819
19820 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
19821         LDKCommitmentUpdate this_ptr_conv;
19822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19823         this_ptr_conv.is_owned = false;
19824         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
19825         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19826         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19827         for (size_t z = 0; z < ret_var.datalen; z++) {
19828                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
19829                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19830                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19831                 uint64_t ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
19832                 if (ret_conv_25_var.is_owned) {
19833                         ret_conv_25_ref |= 1;
19834                 }
19835                 ret_arr_ptr[z] = ret_conv_25_ref;
19836         }
19837         FREE(ret_var.data);
19838         return ret_arr;
19839 }
19840
19841 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
19842         LDKCommitmentUpdate this_ptr_conv;
19843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19844         this_ptr_conv.is_owned = false;
19845         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
19846         val_constr.datalen = *((uint32_t*)val);
19847         if (val_constr.datalen > 0)
19848                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
19849         else
19850                 val_constr.data = NULL;
19851         uint32_t* val_vals = (uint32_t*)(val + 4);
19852         for (size_t z = 0; z < val_constr.datalen; z++) {
19853                 uint32_t val_conv_25 = val_vals[z];
19854                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
19855                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
19856                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
19857                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
19858                 val_constr.data[z] = val_conv_25_conv;
19859         }
19860         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
19861 }
19862
19863 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
19864         LDKCommitmentUpdate this_ptr_conv;
19865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19866         this_ptr_conv.is_owned = false;
19867         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
19868         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19869         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19870         uint64_t ret_ref = (uint64_t)ret_var.inner;
19871         if (ret_var.is_owned) {
19872                 ret_ref |= 1;
19873         }
19874         return ret_ref;
19875 }
19876
19877 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
19878         LDKCommitmentUpdate this_ptr_conv;
19879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19880         this_ptr_conv.is_owned = false;
19881         LDKUpdateFee val_conv;
19882         val_conv.inner = (void*)(val & (~1));
19883         val_conv.is_owned = (val & 1) || (val == 0);
19884         val_conv = UpdateFee_clone(&val_conv);
19885         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
19886 }
19887
19888 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
19889         LDKCommitmentUpdate this_ptr_conv;
19890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19891         this_ptr_conv.is_owned = false;
19892         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
19893         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19894         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19895         uint64_t ret_ref = (uint64_t)ret_var.inner;
19896         if (ret_var.is_owned) {
19897                 ret_ref |= 1;
19898         }
19899         return ret_ref;
19900 }
19901
19902 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
19903         LDKCommitmentUpdate this_ptr_conv;
19904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19905         this_ptr_conv.is_owned = false;
19906         LDKCommitmentSigned val_conv;
19907         val_conv.inner = (void*)(val & (~1));
19908         val_conv.is_owned = (val & 1) || (val == 0);
19909         val_conv = CommitmentSigned_clone(&val_conv);
19910         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
19911 }
19912
19913 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) {
19914         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
19915         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
19916         if (update_add_htlcs_arg_constr.datalen > 0)
19917                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
19918         else
19919                 update_add_htlcs_arg_constr.data = NULL;
19920         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
19921         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
19922                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
19923                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
19924                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
19925                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
19926                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
19927                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
19928         }
19929         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
19930         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
19931         if (update_fulfill_htlcs_arg_constr.datalen > 0)
19932                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
19933         else
19934                 update_fulfill_htlcs_arg_constr.data = NULL;
19935         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
19936         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
19937                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
19938                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
19939                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
19940                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
19941                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
19942                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
19943         }
19944         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
19945         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
19946         if (update_fail_htlcs_arg_constr.datalen > 0)
19947                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
19948         else
19949                 update_fail_htlcs_arg_constr.data = NULL;
19950         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
19951         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
19952                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
19953                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
19954                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
19955                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
19956                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
19957                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
19958         }
19959         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
19960         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
19961         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
19962                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
19963         else
19964                 update_fail_malformed_htlcs_arg_constr.data = NULL;
19965         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
19966         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
19967                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
19968                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
19969                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
19970                 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);
19971                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
19972                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
19973         }
19974         LDKUpdateFee update_fee_arg_conv;
19975         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
19976         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
19977         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
19978         LDKCommitmentSigned commitment_signed_arg_conv;
19979         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
19980         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
19981         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
19982         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);
19983         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19984         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19985         uint64_t ret_ref = (uint64_t)ret_var.inner;
19986         if (ret_var.is_owned) {
19987                 ret_ref |= 1;
19988         }
19989         return ret_ref;
19990 }
19991
19992 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
19993         LDKCommitmentUpdate orig_conv;
19994         orig_conv.inner = (void*)(orig & (~1));
19995         orig_conv.is_owned = false;
19996         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
19997         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19998         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19999         uint64_t ret_ref = (uint64_t)ret_var.inner;
20000         if (ret_var.is_owned) {
20001                 ret_ref |= 1;
20002         }
20003         return ret_ref;
20004 }
20005
20006 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
20007         if ((this_ptr & 1) != 0) return;
20008         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
20009         FREE((void*)this_ptr);
20010         ChannelMessageHandler_free(this_ptr_conv);
20011 }
20012
20013 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
20014         if ((this_ptr & 1) != 0) return;
20015         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
20016         FREE((void*)this_ptr);
20017         RoutingMessageHandler_free(this_ptr_conv);
20018 }
20019
20020 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
20021         LDKAcceptChannel obj_conv;
20022         obj_conv.inner = (void*)(obj & (~1));
20023         obj_conv.is_owned = false;
20024         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
20025         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20026         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20027         CVec_u8Z_free(ret_var);
20028         return ret_arr;
20029 }
20030
20031 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
20032         LDKu8slice ser_ref;
20033         ser_ref.datalen = *((uint32_t*)ser);
20034         ser_ref.data = (int8_t*)(ser + 4);
20035         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20036         *ret_conv = AcceptChannel_read(ser_ref);
20037         return (uint64_t)ret_conv;
20038 }
20039
20040 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
20041         LDKAnnouncementSignatures obj_conv;
20042         obj_conv.inner = (void*)(obj & (~1));
20043         obj_conv.is_owned = false;
20044         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
20045         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20046         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20047         CVec_u8Z_free(ret_var);
20048         return ret_arr;
20049 }
20050
20051 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
20052         LDKu8slice ser_ref;
20053         ser_ref.datalen = *((uint32_t*)ser);
20054         ser_ref.data = (int8_t*)(ser + 4);
20055         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20056         *ret_conv = AnnouncementSignatures_read(ser_ref);
20057         return (uint64_t)ret_conv;
20058 }
20059
20060 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
20061         LDKChannelReestablish obj_conv;
20062         obj_conv.inner = (void*)(obj & (~1));
20063         obj_conv.is_owned = false;
20064         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
20065         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20066         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20067         CVec_u8Z_free(ret_var);
20068         return ret_arr;
20069 }
20070
20071 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
20072         LDKu8slice ser_ref;
20073         ser_ref.datalen = *((uint32_t*)ser);
20074         ser_ref.data = (int8_t*)(ser + 4);
20075         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20076         *ret_conv = ChannelReestablish_read(ser_ref);
20077         return (uint64_t)ret_conv;
20078 }
20079
20080 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
20081         LDKClosingSigned obj_conv;
20082         obj_conv.inner = (void*)(obj & (~1));
20083         obj_conv.is_owned = false;
20084         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
20085         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20086         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20087         CVec_u8Z_free(ret_var);
20088         return ret_arr;
20089 }
20090
20091 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
20092         LDKu8slice ser_ref;
20093         ser_ref.datalen = *((uint32_t*)ser);
20094         ser_ref.data = (int8_t*)(ser + 4);
20095         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20096         *ret_conv = ClosingSigned_read(ser_ref);
20097         return (uint64_t)ret_conv;
20098 }
20099
20100 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
20101         LDKClosingSignedFeeRange obj_conv;
20102         obj_conv.inner = (void*)(obj & (~1));
20103         obj_conv.is_owned = false;
20104         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
20105         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20106         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20107         CVec_u8Z_free(ret_var);
20108         return ret_arr;
20109 }
20110
20111 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
20112         LDKu8slice ser_ref;
20113         ser_ref.datalen = *((uint32_t*)ser);
20114         ser_ref.data = (int8_t*)(ser + 4);
20115         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
20116         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
20117         return (uint64_t)ret_conv;
20118 }
20119
20120 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
20121         LDKCommitmentSigned obj_conv;
20122         obj_conv.inner = (void*)(obj & (~1));
20123         obj_conv.is_owned = false;
20124         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
20125         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20126         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20127         CVec_u8Z_free(ret_var);
20128         return ret_arr;
20129 }
20130
20131 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
20132         LDKu8slice ser_ref;
20133         ser_ref.datalen = *((uint32_t*)ser);
20134         ser_ref.data = (int8_t*)(ser + 4);
20135         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20136         *ret_conv = CommitmentSigned_read(ser_ref);
20137         return (uint64_t)ret_conv;
20138 }
20139
20140 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
20141         LDKFundingCreated obj_conv;
20142         obj_conv.inner = (void*)(obj & (~1));
20143         obj_conv.is_owned = false;
20144         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
20145         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20146         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20147         CVec_u8Z_free(ret_var);
20148         return ret_arr;
20149 }
20150
20151 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
20152         LDKu8slice ser_ref;
20153         ser_ref.datalen = *((uint32_t*)ser);
20154         ser_ref.data = (int8_t*)(ser + 4);
20155         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20156         *ret_conv = FundingCreated_read(ser_ref);
20157         return (uint64_t)ret_conv;
20158 }
20159
20160 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
20161         LDKFundingSigned obj_conv;
20162         obj_conv.inner = (void*)(obj & (~1));
20163         obj_conv.is_owned = false;
20164         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
20165         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20166         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20167         CVec_u8Z_free(ret_var);
20168         return ret_arr;
20169 }
20170
20171 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
20172         LDKu8slice ser_ref;
20173         ser_ref.datalen = *((uint32_t*)ser);
20174         ser_ref.data = (int8_t*)(ser + 4);
20175         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
20176         *ret_conv = FundingSigned_read(ser_ref);
20177         return (uint64_t)ret_conv;
20178 }
20179
20180 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
20181         LDKFundingLocked obj_conv;
20182         obj_conv.inner = (void*)(obj & (~1));
20183         obj_conv.is_owned = false;
20184         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
20185         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20186         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20187         CVec_u8Z_free(ret_var);
20188         return ret_arr;
20189 }
20190
20191 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
20192         LDKu8slice ser_ref;
20193         ser_ref.datalen = *((uint32_t*)ser);
20194         ser_ref.data = (int8_t*)(ser + 4);
20195         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
20196         *ret_conv = FundingLocked_read(ser_ref);
20197         return (uint64_t)ret_conv;
20198 }
20199
20200 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
20201         LDKInit obj_conv;
20202         obj_conv.inner = (void*)(obj & (~1));
20203         obj_conv.is_owned = false;
20204         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
20205         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20206         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20207         CVec_u8Z_free(ret_var);
20208         return ret_arr;
20209 }
20210
20211 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
20212         LDKu8slice ser_ref;
20213         ser_ref.datalen = *((uint32_t*)ser);
20214         ser_ref.data = (int8_t*)(ser + 4);
20215         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20216         *ret_conv = Init_read(ser_ref);
20217         return (uint64_t)ret_conv;
20218 }
20219
20220 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
20221         LDKOpenChannel obj_conv;
20222         obj_conv.inner = (void*)(obj & (~1));
20223         obj_conv.is_owned = false;
20224         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
20225         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20226         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20227         CVec_u8Z_free(ret_var);
20228         return ret_arr;
20229 }
20230
20231 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
20232         LDKu8slice ser_ref;
20233         ser_ref.datalen = *((uint32_t*)ser);
20234         ser_ref.data = (int8_t*)(ser + 4);
20235         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20236         *ret_conv = OpenChannel_read(ser_ref);
20237         return (uint64_t)ret_conv;
20238 }
20239
20240 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
20241         LDKRevokeAndACK obj_conv;
20242         obj_conv.inner = (void*)(obj & (~1));
20243         obj_conv.is_owned = false;
20244         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
20245         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20246         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20247         CVec_u8Z_free(ret_var);
20248         return ret_arr;
20249 }
20250
20251 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
20252         LDKu8slice ser_ref;
20253         ser_ref.datalen = *((uint32_t*)ser);
20254         ser_ref.data = (int8_t*)(ser + 4);
20255         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20256         *ret_conv = RevokeAndACK_read(ser_ref);
20257         return (uint64_t)ret_conv;
20258 }
20259
20260 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
20261         LDKShutdown obj_conv;
20262         obj_conv.inner = (void*)(obj & (~1));
20263         obj_conv.is_owned = false;
20264         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
20265         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20266         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20267         CVec_u8Z_free(ret_var);
20268         return ret_arr;
20269 }
20270
20271 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
20272         LDKu8slice ser_ref;
20273         ser_ref.datalen = *((uint32_t*)ser);
20274         ser_ref.data = (int8_t*)(ser + 4);
20275         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20276         *ret_conv = Shutdown_read(ser_ref);
20277         return (uint64_t)ret_conv;
20278 }
20279
20280 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
20281         LDKUpdateFailHTLC obj_conv;
20282         obj_conv.inner = (void*)(obj & (~1));
20283         obj_conv.is_owned = false;
20284         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
20285         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20286         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20287         CVec_u8Z_free(ret_var);
20288         return ret_arr;
20289 }
20290
20291 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
20292         LDKu8slice ser_ref;
20293         ser_ref.datalen = *((uint32_t*)ser);
20294         ser_ref.data = (int8_t*)(ser + 4);
20295         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20296         *ret_conv = UpdateFailHTLC_read(ser_ref);
20297         return (uint64_t)ret_conv;
20298 }
20299
20300 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
20301         LDKUpdateFailMalformedHTLC obj_conv;
20302         obj_conv.inner = (void*)(obj & (~1));
20303         obj_conv.is_owned = false;
20304         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
20305         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20306         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20307         CVec_u8Z_free(ret_var);
20308         return ret_arr;
20309 }
20310
20311 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
20312         LDKu8slice ser_ref;
20313         ser_ref.datalen = *((uint32_t*)ser);
20314         ser_ref.data = (int8_t*)(ser + 4);
20315         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
20316         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
20317         return (uint64_t)ret_conv;
20318 }
20319
20320 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
20321         LDKUpdateFee obj_conv;
20322         obj_conv.inner = (void*)(obj & (~1));
20323         obj_conv.is_owned = false;
20324         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
20325         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20326         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20327         CVec_u8Z_free(ret_var);
20328         return ret_arr;
20329 }
20330
20331 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
20332         LDKu8slice ser_ref;
20333         ser_ref.datalen = *((uint32_t*)ser);
20334         ser_ref.data = (int8_t*)(ser + 4);
20335         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
20336         *ret_conv = UpdateFee_read(ser_ref);
20337         return (uint64_t)ret_conv;
20338 }
20339
20340 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
20341         LDKUpdateFulfillHTLC obj_conv;
20342         obj_conv.inner = (void*)(obj & (~1));
20343         obj_conv.is_owned = false;
20344         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
20345         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20346         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20347         CVec_u8Z_free(ret_var);
20348         return ret_arr;
20349 }
20350
20351 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
20352         LDKu8slice ser_ref;
20353         ser_ref.datalen = *((uint32_t*)ser);
20354         ser_ref.data = (int8_t*)(ser + 4);
20355         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
20356         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
20357         return (uint64_t)ret_conv;
20358 }
20359
20360 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
20361         LDKUpdateAddHTLC obj_conv;
20362         obj_conv.inner = (void*)(obj & (~1));
20363         obj_conv.is_owned = false;
20364         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
20365         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20366         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20367         CVec_u8Z_free(ret_var);
20368         return ret_arr;
20369 }
20370
20371 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
20372         LDKu8slice ser_ref;
20373         ser_ref.datalen = *((uint32_t*)ser);
20374         ser_ref.data = (int8_t*)(ser + 4);
20375         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
20376         *ret_conv = UpdateAddHTLC_read(ser_ref);
20377         return (uint64_t)ret_conv;
20378 }
20379
20380 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
20381         LDKPing obj_conv;
20382         obj_conv.inner = (void*)(obj & (~1));
20383         obj_conv.is_owned = false;
20384         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
20385         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20386         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20387         CVec_u8Z_free(ret_var);
20388         return ret_arr;
20389 }
20390
20391 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
20392         LDKu8slice ser_ref;
20393         ser_ref.datalen = *((uint32_t*)ser);
20394         ser_ref.data = (int8_t*)(ser + 4);
20395         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
20396         *ret_conv = Ping_read(ser_ref);
20397         return (uint64_t)ret_conv;
20398 }
20399
20400 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
20401         LDKPong obj_conv;
20402         obj_conv.inner = (void*)(obj & (~1));
20403         obj_conv.is_owned = false;
20404         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
20405         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20406         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20407         CVec_u8Z_free(ret_var);
20408         return ret_arr;
20409 }
20410
20411 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
20412         LDKu8slice ser_ref;
20413         ser_ref.datalen = *((uint32_t*)ser);
20414         ser_ref.data = (int8_t*)(ser + 4);
20415         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
20416         *ret_conv = Pong_read(ser_ref);
20417         return (uint64_t)ret_conv;
20418 }
20419
20420 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
20421         LDKUnsignedChannelAnnouncement obj_conv;
20422         obj_conv.inner = (void*)(obj & (~1));
20423         obj_conv.is_owned = false;
20424         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
20425         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20426         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20427         CVec_u8Z_free(ret_var);
20428         return ret_arr;
20429 }
20430
20431 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
20432         LDKu8slice ser_ref;
20433         ser_ref.datalen = *((uint32_t*)ser);
20434         ser_ref.data = (int8_t*)(ser + 4);
20435         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
20436         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
20437         return (uint64_t)ret_conv;
20438 }
20439
20440 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
20441         LDKChannelAnnouncement obj_conv;
20442         obj_conv.inner = (void*)(obj & (~1));
20443         obj_conv.is_owned = false;
20444         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
20445         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20446         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20447         CVec_u8Z_free(ret_var);
20448         return ret_arr;
20449 }
20450
20451 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
20452         LDKu8slice ser_ref;
20453         ser_ref.datalen = *((uint32_t*)ser);
20454         ser_ref.data = (int8_t*)(ser + 4);
20455         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
20456         *ret_conv = ChannelAnnouncement_read(ser_ref);
20457         return (uint64_t)ret_conv;
20458 }
20459
20460 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
20461         LDKUnsignedChannelUpdate obj_conv;
20462         obj_conv.inner = (void*)(obj & (~1));
20463         obj_conv.is_owned = false;
20464         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
20465         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20466         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20467         CVec_u8Z_free(ret_var);
20468         return ret_arr;
20469 }
20470
20471 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
20472         LDKu8slice ser_ref;
20473         ser_ref.datalen = *((uint32_t*)ser);
20474         ser_ref.data = (int8_t*)(ser + 4);
20475         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
20476         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
20477         return (uint64_t)ret_conv;
20478 }
20479
20480 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
20481         LDKChannelUpdate obj_conv;
20482         obj_conv.inner = (void*)(obj & (~1));
20483         obj_conv.is_owned = false;
20484         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
20485         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20486         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20487         CVec_u8Z_free(ret_var);
20488         return ret_arr;
20489 }
20490
20491 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
20492         LDKu8slice ser_ref;
20493         ser_ref.datalen = *((uint32_t*)ser);
20494         ser_ref.data = (int8_t*)(ser + 4);
20495         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20496         *ret_conv = ChannelUpdate_read(ser_ref);
20497         return (uint64_t)ret_conv;
20498 }
20499
20500 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
20501         LDKErrorMessage obj_conv;
20502         obj_conv.inner = (void*)(obj & (~1));
20503         obj_conv.is_owned = false;
20504         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
20505         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20506         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20507         CVec_u8Z_free(ret_var);
20508         return ret_arr;
20509 }
20510
20511 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
20512         LDKu8slice ser_ref;
20513         ser_ref.datalen = *((uint32_t*)ser);
20514         ser_ref.data = (int8_t*)(ser + 4);
20515         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20516         *ret_conv = ErrorMessage_read(ser_ref);
20517         return (uint64_t)ret_conv;
20518 }
20519
20520 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
20521         LDKUnsignedNodeAnnouncement obj_conv;
20522         obj_conv.inner = (void*)(obj & (~1));
20523         obj_conv.is_owned = false;
20524         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
20525         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20526         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20527         CVec_u8Z_free(ret_var);
20528         return ret_arr;
20529 }
20530
20531 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
20532         LDKu8slice ser_ref;
20533         ser_ref.datalen = *((uint32_t*)ser);
20534         ser_ref.data = (int8_t*)(ser + 4);
20535         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20536         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
20537         return (uint64_t)ret_conv;
20538 }
20539
20540 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
20541         LDKNodeAnnouncement obj_conv;
20542         obj_conv.inner = (void*)(obj & (~1));
20543         obj_conv.is_owned = false;
20544         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
20545         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20546         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20547         CVec_u8Z_free(ret_var);
20548         return ret_arr;
20549 }
20550
20551 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
20552         LDKu8slice ser_ref;
20553         ser_ref.datalen = *((uint32_t*)ser);
20554         ser_ref.data = (int8_t*)(ser + 4);
20555         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20556         *ret_conv = NodeAnnouncement_read(ser_ref);
20557         return (uint64_t)ret_conv;
20558 }
20559
20560 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
20561         LDKu8slice ser_ref;
20562         ser_ref.datalen = *((uint32_t*)ser);
20563         ser_ref.data = (int8_t*)(ser + 4);
20564         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20565         *ret_conv = QueryShortChannelIds_read(ser_ref);
20566         return (uint64_t)ret_conv;
20567 }
20568
20569 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
20570         LDKQueryShortChannelIds obj_conv;
20571         obj_conv.inner = (void*)(obj & (~1));
20572         obj_conv.is_owned = false;
20573         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
20574         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20575         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20576         CVec_u8Z_free(ret_var);
20577         return ret_arr;
20578 }
20579
20580 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
20581         LDKReplyShortChannelIdsEnd obj_conv;
20582         obj_conv.inner = (void*)(obj & (~1));
20583         obj_conv.is_owned = false;
20584         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
20585         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20586         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20587         CVec_u8Z_free(ret_var);
20588         return ret_arr;
20589 }
20590
20591 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
20592         LDKu8slice ser_ref;
20593         ser_ref.datalen = *((uint32_t*)ser);
20594         ser_ref.data = (int8_t*)(ser + 4);
20595         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20596         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
20597         return (uint64_t)ret_conv;
20598 }
20599
20600 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
20601         LDKQueryChannelRange this_arg_conv;
20602         this_arg_conv.inner = (void*)(this_arg & (~1));
20603         this_arg_conv.is_owned = false;
20604         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
20605         return ret_val;
20606 }
20607
20608 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
20609         LDKQueryChannelRange obj_conv;
20610         obj_conv.inner = (void*)(obj & (~1));
20611         obj_conv.is_owned = false;
20612         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
20613         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20614         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20615         CVec_u8Z_free(ret_var);
20616         return ret_arr;
20617 }
20618
20619 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
20620         LDKu8slice ser_ref;
20621         ser_ref.datalen = *((uint32_t*)ser);
20622         ser_ref.data = (int8_t*)(ser + 4);
20623         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20624         *ret_conv = QueryChannelRange_read(ser_ref);
20625         return (uint64_t)ret_conv;
20626 }
20627
20628 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
20629         LDKu8slice ser_ref;
20630         ser_ref.datalen = *((uint32_t*)ser);
20631         ser_ref.data = (int8_t*)(ser + 4);
20632         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20633         *ret_conv = ReplyChannelRange_read(ser_ref);
20634         return (uint64_t)ret_conv;
20635 }
20636
20637 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
20638         LDKReplyChannelRange obj_conv;
20639         obj_conv.inner = (void*)(obj & (~1));
20640         obj_conv.is_owned = false;
20641         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
20642         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20643         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20644         CVec_u8Z_free(ret_var);
20645         return ret_arr;
20646 }
20647
20648 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
20649         LDKGossipTimestampFilter obj_conv;
20650         obj_conv.inner = (void*)(obj & (~1));
20651         obj_conv.is_owned = false;
20652         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
20653         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20654         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20655         CVec_u8Z_free(ret_var);
20656         return ret_arr;
20657 }
20658
20659 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
20660         LDKu8slice ser_ref;
20661         ser_ref.datalen = *((uint32_t*)ser);
20662         ser_ref.data = (int8_t*)(ser + 4);
20663         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20664         *ret_conv = GossipTimestampFilter_read(ser_ref);
20665         return (uint64_t)ret_conv;
20666 }
20667
20668 void  __attribute__((visibility("default"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
20669         if ((this_ptr & 1) != 0) return;
20670         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(((uint64_t)this_ptr) & ~1);
20671         FREE((void*)this_ptr);
20672         CustomMessageHandler_free(this_ptr_conv);
20673 }
20674
20675 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
20676         LDKIgnoringMessageHandler this_obj_conv;
20677         this_obj_conv.inner = (void*)(this_obj & (~1));
20678         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20679         IgnoringMessageHandler_free(this_obj_conv);
20680 }
20681
20682 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
20683         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
20684         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20685         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20686         uint64_t ret_ref = (uint64_t)ret_var.inner;
20687         if (ret_var.is_owned) {
20688                 ret_ref |= 1;
20689         }
20690         return ret_ref;
20691 }
20692
20693 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
20694         LDKIgnoringMessageHandler this_arg_conv;
20695         this_arg_conv.inner = (void*)(this_arg & (~1));
20696         this_arg_conv.is_owned = false;
20697         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20698         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
20699         return (uint64_t)ret_ret;
20700 }
20701
20702 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
20703         LDKIgnoringMessageHandler this_arg_conv;
20704         this_arg_conv.inner = (void*)(this_arg & (~1));
20705         this_arg_conv.is_owned = false;
20706         LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
20707         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
20708         return (uint64_t)ret_ret;
20709 }
20710
20711 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
20712         LDKIgnoringMessageHandler this_arg_conv;
20713         this_arg_conv.inner = (void*)(this_arg & (~1));
20714         this_arg_conv.is_owned = false;
20715         LDKCustomMessageReader* ret_ret =MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
20716         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
20717         return (uint64_t)ret_ret;
20718 }
20719
20720 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
20721         LDKIgnoringMessageHandler this_arg_conv;
20722         this_arg_conv.inner = (void*)(this_arg & (~1));
20723         this_arg_conv.is_owned = false;
20724         LDKCustomMessageHandler* ret_ret =MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
20725         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
20726         return (uint64_t)ret_ret;
20727 }
20728
20729 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
20730         LDKErroringMessageHandler this_obj_conv;
20731         this_obj_conv.inner = (void*)(this_obj & (~1));
20732         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20733         ErroringMessageHandler_free(this_obj_conv);
20734 }
20735
20736 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
20737         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
20738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20740         uint64_t ret_ref = (uint64_t)ret_var.inner;
20741         if (ret_var.is_owned) {
20742                 ret_ref |= 1;
20743         }
20744         return ret_ref;
20745 }
20746
20747 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
20748         LDKErroringMessageHandler this_arg_conv;
20749         this_arg_conv.inner = (void*)(this_arg & (~1));
20750         this_arg_conv.is_owned = false;
20751         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20752         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
20753         return (uint64_t)ret_ret;
20754 }
20755
20756 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
20757         LDKErroringMessageHandler this_arg_conv;
20758         this_arg_conv.inner = (void*)(this_arg & (~1));
20759         this_arg_conv.is_owned = false;
20760         LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
20761         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
20762         return (uint64_t)ret_ret;
20763 }
20764
20765 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
20766         LDKMessageHandler this_obj_conv;
20767         this_obj_conv.inner = (void*)(this_obj & (~1));
20768         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20769         MessageHandler_free(this_obj_conv);
20770 }
20771
20772 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
20773         LDKMessageHandler this_ptr_conv;
20774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20775         this_ptr_conv.is_owned = false;
20776         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
20777         return ret_ret;
20778 }
20779
20780 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
20781         LDKMessageHandler this_ptr_conv;
20782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20783         this_ptr_conv.is_owned = false;
20784         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
20785         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
20786 }
20787
20788 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
20789         LDKMessageHandler this_ptr_conv;
20790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20791         this_ptr_conv.is_owned = false;
20792         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
20793         return ret_ret;
20794 }
20795
20796 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
20797         LDKMessageHandler this_ptr_conv;
20798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20799         this_ptr_conv.is_owned = false;
20800         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
20801         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
20802 }
20803
20804 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
20805         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
20806         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
20807         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_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_SocketDescriptor_clone(uint32_t orig) {
20818         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
20819         LDKSocketDescriptor* ret_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
20820         *ret_ret = SocketDescriptor_clone(orig_conv);
20821         return (uint64_t)ret_ret;
20822 }
20823
20824 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
20825         if ((this_ptr & 1) != 0) return;
20826         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
20827         FREE((void*)this_ptr);
20828         SocketDescriptor_free(this_ptr_conv);
20829 }
20830
20831 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
20832         LDKPeerHandleError this_obj_conv;
20833         this_obj_conv.inner = (void*)(this_obj & (~1));
20834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20835         PeerHandleError_free(this_obj_conv);
20836 }
20837
20838 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
20839         LDKPeerHandleError this_ptr_conv;
20840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20841         this_ptr_conv.is_owned = false;
20842         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
20843         return ret_val;
20844 }
20845
20846 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
20847         LDKPeerHandleError this_ptr_conv;
20848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20849         this_ptr_conv.is_owned = false;
20850         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
20851 }
20852
20853 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
20854         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
20855         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20856         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20857         uint64_t ret_ref = (uint64_t)ret_var.inner;
20858         if (ret_var.is_owned) {
20859                 ret_ref |= 1;
20860         }
20861         return ret_ref;
20862 }
20863
20864 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
20865         LDKPeerHandleError orig_conv;
20866         orig_conv.inner = (void*)(orig & (~1));
20867         orig_conv.is_owned = false;
20868         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
20869         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20870         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20871         uint64_t ret_ref = (uint64_t)ret_var.inner;
20872         if (ret_var.is_owned) {
20873                 ret_ref |= 1;
20874         }
20875         return ret_ref;
20876 }
20877
20878 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
20879         LDKPeerManager this_obj_conv;
20880         this_obj_conv.inner = (void*)(this_obj & (~1));
20881         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20882         PeerManager_free(this_obj_conv);
20883 }
20884
20885 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, uint32_t custom_message_handler) {
20886         LDKMessageHandler message_handler_conv;
20887         message_handler_conv.inner = (void*)(message_handler & (~1));
20888         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
20889         // Warning: we need a move here but no clone is available for LDKMessageHandler
20890         LDKSecretKey our_node_secret_ref;
20891         CHECK(*((uint32_t*)our_node_secret) == 32);
20892         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
20893         unsigned char ephemeral_random_data_arr[32];
20894         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
20895         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
20896         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
20897         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20898         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1);
20899         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
20900         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20901         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20902         uint64_t ret_ref = (uint64_t)ret_var.inner;
20903         if (ret_var.is_owned) {
20904                 ret_ref |= 1;
20905         }
20906         return ret_ref;
20907 }
20908
20909 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
20910         LDKPeerManager this_arg_conv;
20911         this_arg_conv.inner = (void*)(this_arg & (~1));
20912         this_arg_conv.is_owned = false;
20913         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
20914         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
20915         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
20916         for (size_t m = 0; m < ret_var.datalen; m++) {
20917                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20918                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
20919                 ret_arr_ptr[m] = ret_conv_12_arr;
20920         }
20921         FREE(ret_var.data);
20922         return ret_arr;
20923 }
20924
20925 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
20926         LDKPeerManager this_arg_conv;
20927         this_arg_conv.inner = (void*)(this_arg & (~1));
20928         this_arg_conv.is_owned = false;
20929         LDKPublicKey their_node_id_ref;
20930         CHECK(*((uint32_t*)their_node_id) == 33);
20931         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
20932         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20933         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20934         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
20935         return (uint64_t)ret_conv;
20936 }
20937
20938 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
20939         LDKPeerManager this_arg_conv;
20940         this_arg_conv.inner = (void*)(this_arg & (~1));
20941         this_arg_conv.is_owned = false;
20942         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20943         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20944         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
20945         return (uint64_t)ret_conv;
20946 }
20947
20948 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
20949         LDKPeerManager this_arg_conv;
20950         this_arg_conv.inner = (void*)(this_arg & (~1));
20951         this_arg_conv.is_owned = false;
20952         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20953         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20954         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
20955         return (uint64_t)ret_conv;
20956 }
20957
20958 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
20959         LDKPeerManager this_arg_conv;
20960         this_arg_conv.inner = (void*)(this_arg & (~1));
20961         this_arg_conv.is_owned = false;
20962         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
20963         LDKu8slice data_ref;
20964         data_ref.datalen = *((uint32_t*)data);
20965         data_ref.data = (int8_t*)(data + 4);
20966         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20967         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
20968         return (uint64_t)ret_conv;
20969 }
20970
20971 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
20972         LDKPeerManager this_arg_conv;
20973         this_arg_conv.inner = (void*)(this_arg & (~1));
20974         this_arg_conv.is_owned = false;
20975         PeerManager_process_events(&this_arg_conv);
20976 }
20977
20978 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
20979         LDKPeerManager this_arg_conv;
20980         this_arg_conv.inner = (void*)(this_arg & (~1));
20981         this_arg_conv.is_owned = false;
20982         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
20983         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
20984 }
20985
20986 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
20987         LDKPeerManager this_arg_conv;
20988         this_arg_conv.inner = (void*)(this_arg & (~1));
20989         this_arg_conv.is_owned = false;
20990         LDKPublicKey node_id_ref;
20991         CHECK(*((uint32_t*)node_id) == 33);
20992         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
20993         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
20994 }
20995
20996 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
20997         LDKPeerManager this_arg_conv;
20998         this_arg_conv.inner = (void*)(this_arg & (~1));
20999         this_arg_conv.is_owned = false;
21000         PeerManager_timer_tick_occurred(&this_arg_conv);
21001 }
21002
21003 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
21004         unsigned char commitment_seed_arr[32];
21005         CHECK(*((uint32_t*)commitment_seed) == 32);
21006         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
21007         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
21008         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21009         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
21010         return ret_arr;
21011 }
21012
21013 int8_tArray  __attribute__((visibility("default"))) TS_build_closing_transaction(int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, uint32_t funding_outpoint) {
21014         LDKCVec_u8Z to_holder_script_ref;
21015         to_holder_script_ref.datalen = *((uint32_t*)to_holder_script);
21016         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
21017         memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen);
21018         LDKCVec_u8Z to_counterparty_script_ref;
21019         to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script);
21020         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
21021         memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen);
21022         LDKOutPoint funding_outpoint_conv;
21023         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
21024         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
21025         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
21026         LDKTransaction ret_var = build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
21027         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21028         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21029         Transaction_free(ret_var);
21030         return ret_arr;
21031 }
21032
21033 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
21034         LDKPublicKey per_commitment_point_ref;
21035         CHECK(*((uint32_t*)per_commitment_point) == 33);
21036         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21037         unsigned char base_secret_arr[32];
21038         CHECK(*((uint32_t*)base_secret) == 32);
21039         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
21040         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
21041         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21042         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
21043         return (uint64_t)ret_conv;
21044 }
21045
21046 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
21047         LDKPublicKey per_commitment_point_ref;
21048         CHECK(*((uint32_t*)per_commitment_point) == 33);
21049         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21050         LDKPublicKey base_point_ref;
21051         CHECK(*((uint32_t*)base_point) == 33);
21052         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
21053         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21054         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
21055         return (uint64_t)ret_conv;
21056 }
21057
21058 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
21059         unsigned char per_commitment_secret_arr[32];
21060         CHECK(*((uint32_t*)per_commitment_secret) == 32);
21061         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
21062         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
21063         unsigned char countersignatory_revocation_base_secret_arr[32];
21064         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
21065         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
21066         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
21067         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21068         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
21069         return (uint64_t)ret_conv;
21070 }
21071
21072 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
21073         LDKPublicKey per_commitment_point_ref;
21074         CHECK(*((uint32_t*)per_commitment_point) == 33);
21075         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21076         LDKPublicKey countersignatory_revocation_base_point_ref;
21077         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
21078         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
21079         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21080         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
21081         return (uint64_t)ret_conv;
21082 }
21083
21084 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
21085         LDKTxCreationKeys this_obj_conv;
21086         this_obj_conv.inner = (void*)(this_obj & (~1));
21087         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21088         TxCreationKeys_free(this_obj_conv);
21089 }
21090
21091 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
21092         LDKTxCreationKeys this_ptr_conv;
21093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21094         this_ptr_conv.is_owned = false;
21095         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21096         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
21097         return ret_arr;
21098 }
21099
21100 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
21101         LDKTxCreationKeys this_ptr_conv;
21102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21103         this_ptr_conv.is_owned = false;
21104         LDKPublicKey val_ref;
21105         CHECK(*((uint32_t*)val) == 33);
21106         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21107         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
21108 }
21109
21110 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
21111         LDKTxCreationKeys this_ptr_conv;
21112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21113         this_ptr_conv.is_owned = false;
21114         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21115         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
21116         return ret_arr;
21117 }
21118
21119 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
21120         LDKTxCreationKeys this_ptr_conv;
21121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21122         this_ptr_conv.is_owned = false;
21123         LDKPublicKey val_ref;
21124         CHECK(*((uint32_t*)val) == 33);
21125         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21126         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
21127 }
21128
21129 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
21130         LDKTxCreationKeys this_ptr_conv;
21131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21132         this_ptr_conv.is_owned = false;
21133         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21134         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
21135         return ret_arr;
21136 }
21137
21138 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
21139         LDKTxCreationKeys this_ptr_conv;
21140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21141         this_ptr_conv.is_owned = false;
21142         LDKPublicKey val_ref;
21143         CHECK(*((uint32_t*)val) == 33);
21144         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21145         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
21146 }
21147
21148 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
21149         LDKTxCreationKeys this_ptr_conv;
21150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21151         this_ptr_conv.is_owned = false;
21152         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21153         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
21154         return ret_arr;
21155 }
21156
21157 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
21158         LDKTxCreationKeys this_ptr_conv;
21159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21160         this_ptr_conv.is_owned = false;
21161         LDKPublicKey val_ref;
21162         CHECK(*((uint32_t*)val) == 33);
21163         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21164         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
21165 }
21166
21167 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
21168         LDKTxCreationKeys this_ptr_conv;
21169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21170         this_ptr_conv.is_owned = false;
21171         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21172         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
21173         return ret_arr;
21174 }
21175
21176 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
21177         LDKTxCreationKeys this_ptr_conv;
21178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21179         this_ptr_conv.is_owned = false;
21180         LDKPublicKey val_ref;
21181         CHECK(*((uint32_t*)val) == 33);
21182         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21183         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
21184 }
21185
21186 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) {
21187         LDKPublicKey per_commitment_point_arg_ref;
21188         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
21189         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
21190         LDKPublicKey revocation_key_arg_ref;
21191         CHECK(*((uint32_t*)revocation_key_arg) == 33);
21192         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
21193         LDKPublicKey broadcaster_htlc_key_arg_ref;
21194         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
21195         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
21196         LDKPublicKey countersignatory_htlc_key_arg_ref;
21197         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
21198         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
21199         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
21200         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
21201         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
21202         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);
21203         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21204         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21205         uint64_t ret_ref = (uint64_t)ret_var.inner;
21206         if (ret_var.is_owned) {
21207                 ret_ref |= 1;
21208         }
21209         return ret_ref;
21210 }
21211
21212 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
21213         LDKTxCreationKeys orig_conv;
21214         orig_conv.inner = (void*)(orig & (~1));
21215         orig_conv.is_owned = false;
21216         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
21217         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21218         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21219         uint64_t ret_ref = (uint64_t)ret_var.inner;
21220         if (ret_var.is_owned) {
21221                 ret_ref |= 1;
21222         }
21223         return ret_ref;
21224 }
21225
21226 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
21227         LDKTxCreationKeys obj_conv;
21228         obj_conv.inner = (void*)(obj & (~1));
21229         obj_conv.is_owned = false;
21230         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
21231         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21232         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21233         CVec_u8Z_free(ret_var);
21234         return ret_arr;
21235 }
21236
21237 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
21238         LDKu8slice ser_ref;
21239         ser_ref.datalen = *((uint32_t*)ser);
21240         ser_ref.data = (int8_t*)(ser + 4);
21241         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
21242         *ret_conv = TxCreationKeys_read(ser_ref);
21243         return (uint64_t)ret_conv;
21244 }
21245
21246 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
21247         LDKChannelPublicKeys this_obj_conv;
21248         this_obj_conv.inner = (void*)(this_obj & (~1));
21249         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21250         ChannelPublicKeys_free(this_obj_conv);
21251 }
21252
21253 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
21254         LDKChannelPublicKeys this_ptr_conv;
21255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21256         this_ptr_conv.is_owned = false;
21257         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21258         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
21259         return ret_arr;
21260 }
21261
21262 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
21263         LDKChannelPublicKeys this_ptr_conv;
21264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21265         this_ptr_conv.is_owned = false;
21266         LDKPublicKey val_ref;
21267         CHECK(*((uint32_t*)val) == 33);
21268         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21269         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
21270 }
21271
21272 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
21273         LDKChannelPublicKeys this_ptr_conv;
21274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21275         this_ptr_conv.is_owned = false;
21276         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21277         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
21278         return ret_arr;
21279 }
21280
21281 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
21282         LDKChannelPublicKeys this_ptr_conv;
21283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21284         this_ptr_conv.is_owned = false;
21285         LDKPublicKey val_ref;
21286         CHECK(*((uint32_t*)val) == 33);
21287         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21288         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
21289 }
21290
21291 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
21292         LDKChannelPublicKeys this_ptr_conv;
21293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21294         this_ptr_conv.is_owned = false;
21295         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21296         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
21297         return ret_arr;
21298 }
21299
21300 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
21301         LDKChannelPublicKeys this_ptr_conv;
21302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21303         this_ptr_conv.is_owned = false;
21304         LDKPublicKey val_ref;
21305         CHECK(*((uint32_t*)val) == 33);
21306         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21307         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
21308 }
21309
21310 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
21311         LDKChannelPublicKeys this_ptr_conv;
21312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21313         this_ptr_conv.is_owned = false;
21314         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21315         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
21316         return ret_arr;
21317 }
21318
21319 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
21320         LDKChannelPublicKeys this_ptr_conv;
21321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21322         this_ptr_conv.is_owned = false;
21323         LDKPublicKey val_ref;
21324         CHECK(*((uint32_t*)val) == 33);
21325         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21326         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
21327 }
21328
21329 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
21330         LDKChannelPublicKeys this_ptr_conv;
21331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21332         this_ptr_conv.is_owned = false;
21333         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21334         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
21335         return ret_arr;
21336 }
21337
21338 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
21339         LDKChannelPublicKeys this_ptr_conv;
21340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21341         this_ptr_conv.is_owned = false;
21342         LDKPublicKey val_ref;
21343         CHECK(*((uint32_t*)val) == 33);
21344         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21345         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
21346 }
21347
21348 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) {
21349         LDKPublicKey funding_pubkey_arg_ref;
21350         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
21351         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
21352         LDKPublicKey revocation_basepoint_arg_ref;
21353         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
21354         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
21355         LDKPublicKey payment_point_arg_ref;
21356         CHECK(*((uint32_t*)payment_point_arg) == 33);
21357         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
21358         LDKPublicKey delayed_payment_basepoint_arg_ref;
21359         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
21360         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
21361         LDKPublicKey htlc_basepoint_arg_ref;
21362         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
21363         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
21364         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);
21365         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21366         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21367         uint64_t ret_ref = (uint64_t)ret_var.inner;
21368         if (ret_var.is_owned) {
21369                 ret_ref |= 1;
21370         }
21371         return ret_ref;
21372 }
21373
21374 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
21375         LDKChannelPublicKeys orig_conv;
21376         orig_conv.inner = (void*)(orig & (~1));
21377         orig_conv.is_owned = false;
21378         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
21379         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21380         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21381         uint64_t ret_ref = (uint64_t)ret_var.inner;
21382         if (ret_var.is_owned) {
21383                 ret_ref |= 1;
21384         }
21385         return ret_ref;
21386 }
21387
21388 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
21389         LDKChannelPublicKeys obj_conv;
21390         obj_conv.inner = (void*)(obj & (~1));
21391         obj_conv.is_owned = false;
21392         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
21393         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21394         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21395         CVec_u8Z_free(ret_var);
21396         return ret_arr;
21397 }
21398
21399 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
21400         LDKu8slice ser_ref;
21401         ser_ref.datalen = *((uint32_t*)ser);
21402         ser_ref.data = (int8_t*)(ser + 4);
21403         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
21404         *ret_conv = ChannelPublicKeys_read(ser_ref);
21405         return (uint64_t)ret_conv;
21406 }
21407
21408 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) {
21409         LDKPublicKey per_commitment_point_ref;
21410         CHECK(*((uint32_t*)per_commitment_point) == 33);
21411         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21412         LDKPublicKey broadcaster_delayed_payment_base_ref;
21413         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
21414         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
21415         LDKPublicKey broadcaster_htlc_base_ref;
21416         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
21417         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
21418         LDKPublicKey countersignatory_revocation_base_ref;
21419         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
21420         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
21421         LDKPublicKey countersignatory_htlc_base_ref;
21422         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
21423         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
21424         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21425         *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);
21426         return (uint64_t)ret_conv;
21427 }
21428
21429 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
21430         LDKPublicKey per_commitment_point_ref;
21431         CHECK(*((uint32_t*)per_commitment_point) == 33);
21432         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21433         LDKChannelPublicKeys broadcaster_keys_conv;
21434         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
21435         broadcaster_keys_conv.is_owned = false;
21436         LDKChannelPublicKeys countersignatory_keys_conv;
21437         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
21438         countersignatory_keys_conv.is_owned = false;
21439         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21440         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
21441         return (uint64_t)ret_conv;
21442 }
21443
21444 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
21445         LDKPublicKey revocation_key_ref;
21446         CHECK(*((uint32_t*)revocation_key) == 33);
21447         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
21448         LDKPublicKey broadcaster_delayed_payment_key_ref;
21449         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
21450         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
21451         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
21452         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21453         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21454         CVec_u8Z_free(ret_var);
21455         return ret_arr;
21456 }
21457
21458 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
21459         LDKHTLCOutputInCommitment this_obj_conv;
21460         this_obj_conv.inner = (void*)(this_obj & (~1));
21461         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21462         HTLCOutputInCommitment_free(this_obj_conv);
21463 }
21464
21465 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
21466         LDKHTLCOutputInCommitment this_ptr_conv;
21467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21468         this_ptr_conv.is_owned = false;
21469         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
21470         return ret_val;
21471 }
21472
21473 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
21474         LDKHTLCOutputInCommitment this_ptr_conv;
21475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21476         this_ptr_conv.is_owned = false;
21477         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
21478 }
21479
21480 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
21481         LDKHTLCOutputInCommitment this_ptr_conv;
21482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21483         this_ptr_conv.is_owned = false;
21484         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
21485         return ret_val;
21486 }
21487
21488 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
21489         LDKHTLCOutputInCommitment this_ptr_conv;
21490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21491         this_ptr_conv.is_owned = false;
21492         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
21493 }
21494
21495 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
21496         LDKHTLCOutputInCommitment this_ptr_conv;
21497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21498         this_ptr_conv.is_owned = false;
21499         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
21500         return ret_val;
21501 }
21502
21503 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
21504         LDKHTLCOutputInCommitment this_ptr_conv;
21505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21506         this_ptr_conv.is_owned = false;
21507         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
21508 }
21509
21510 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
21511         LDKHTLCOutputInCommitment this_ptr_conv;
21512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21513         this_ptr_conv.is_owned = false;
21514         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21515         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
21516         return ret_arr;
21517 }
21518
21519 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
21520         LDKHTLCOutputInCommitment this_ptr_conv;
21521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21522         this_ptr_conv.is_owned = false;
21523         LDKThirtyTwoBytes val_ref;
21524         CHECK(*((uint32_t*)val) == 32);
21525         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
21526         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
21527 }
21528
21529 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
21530         LDKHTLCOutputInCommitment this_ptr_conv;
21531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21532         this_ptr_conv.is_owned = false;
21533         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
21534         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
21535         uint64_t ret_ref = (uint64_t)ret_copy;
21536         return ret_ref;
21537 }
21538
21539 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
21540         LDKHTLCOutputInCommitment this_ptr_conv;
21541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21542         this_ptr_conv.is_owned = false;
21543         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
21544         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
21545         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
21546 }
21547
21548 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) {
21549         LDKThirtyTwoBytes payment_hash_arg_ref;
21550         CHECK(*((uint32_t*)payment_hash_arg) == 32);
21551         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
21552         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
21553         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
21554         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
21555         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21556         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21557         uint64_t ret_ref = (uint64_t)ret_var.inner;
21558         if (ret_var.is_owned) {
21559                 ret_ref |= 1;
21560         }
21561         return ret_ref;
21562 }
21563
21564 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
21565         LDKHTLCOutputInCommitment orig_conv;
21566         orig_conv.inner = (void*)(orig & (~1));
21567         orig_conv.is_owned = false;
21568         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
21569         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21570         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21571         uint64_t ret_ref = (uint64_t)ret_var.inner;
21572         if (ret_var.is_owned) {
21573                 ret_ref |= 1;
21574         }
21575         return ret_ref;
21576 }
21577
21578 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
21579         LDKHTLCOutputInCommitment obj_conv;
21580         obj_conv.inner = (void*)(obj & (~1));
21581         obj_conv.is_owned = false;
21582         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
21583         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21584         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21585         CVec_u8Z_free(ret_var);
21586         return ret_arr;
21587 }
21588
21589 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
21590         LDKu8slice ser_ref;
21591         ser_ref.datalen = *((uint32_t*)ser);
21592         ser_ref.data = (int8_t*)(ser + 4);
21593         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
21594         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
21595         return (uint64_t)ret_conv;
21596 }
21597
21598 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
21599         LDKHTLCOutputInCommitment htlc_conv;
21600         htlc_conv.inner = (void*)(htlc & (~1));
21601         htlc_conv.is_owned = false;
21602         LDKTxCreationKeys keys_conv;
21603         keys_conv.inner = (void*)(keys & (~1));
21604         keys_conv.is_owned = false;
21605         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
21606         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21607         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21608         CVec_u8Z_free(ret_var);
21609         return ret_arr;
21610 }
21611
21612 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
21613         LDKPublicKey broadcaster_ref;
21614         CHECK(*((uint32_t*)broadcaster) == 33);
21615         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
21616         LDKPublicKey countersignatory_ref;
21617         CHECK(*((uint32_t*)countersignatory) == 33);
21618         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
21619         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
21620         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21621         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21622         CVec_u8Z_free(ret_var);
21623         return ret_arr;
21624 }
21625
21626 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) {
21627         unsigned char commitment_txid_arr[32];
21628         CHECK(*((uint32_t*)commitment_txid) == 32);
21629         memcpy(commitment_txid_arr, (uint8_t*)(commitment_txid + 4), 32);
21630         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
21631         LDKHTLCOutputInCommitment htlc_conv;
21632         htlc_conv.inner = (void*)(htlc & (~1));
21633         htlc_conv.is_owned = false;
21634         LDKPublicKey broadcaster_delayed_payment_key_ref;
21635         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
21636         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
21637         LDKPublicKey revocation_key_ref;
21638         CHECK(*((uint32_t*)revocation_key) == 33);
21639         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
21640         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
21641         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21642         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21643         Transaction_free(ret_var);
21644         return ret_arr;
21645 }
21646
21647 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
21648         LDKChannelTransactionParameters this_obj_conv;
21649         this_obj_conv.inner = (void*)(this_obj & (~1));
21650         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21651         ChannelTransactionParameters_free(this_obj_conv);
21652 }
21653
21654 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
21655         LDKChannelTransactionParameters this_ptr_conv;
21656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21657         this_ptr_conv.is_owned = false;
21658         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_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 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
21669         LDKChannelTransactionParameters this_ptr_conv;
21670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21671         this_ptr_conv.is_owned = false;
21672         LDKChannelPublicKeys val_conv;
21673         val_conv.inner = (void*)(val & (~1));
21674         val_conv.is_owned = (val & 1) || (val == 0);
21675         val_conv = ChannelPublicKeys_clone(&val_conv);
21676         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
21677 }
21678
21679 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
21680         LDKChannelTransactionParameters this_ptr_conv;
21681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21682         this_ptr_conv.is_owned = false;
21683         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
21684         return ret_val;
21685 }
21686
21687 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
21688         LDKChannelTransactionParameters this_ptr_conv;
21689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21690         this_ptr_conv.is_owned = false;
21691         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
21692 }
21693
21694 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
21695         LDKChannelTransactionParameters this_ptr_conv;
21696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21697         this_ptr_conv.is_owned = false;
21698         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
21699         return ret_val;
21700 }
21701
21702 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
21703         LDKChannelTransactionParameters this_ptr_conv;
21704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21705         this_ptr_conv.is_owned = false;
21706         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
21707 }
21708
21709 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
21710         LDKChannelTransactionParameters this_ptr_conv;
21711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21712         this_ptr_conv.is_owned = false;
21713         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
21714         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21715         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21716         uint64_t ret_ref = (uint64_t)ret_var.inner;
21717         if (ret_var.is_owned) {
21718                 ret_ref |= 1;
21719         }
21720         return ret_ref;
21721 }
21722
21723 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
21724         LDKChannelTransactionParameters this_ptr_conv;
21725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21726         this_ptr_conv.is_owned = false;
21727         LDKCounterpartyChannelTransactionParameters val_conv;
21728         val_conv.inner = (void*)(val & (~1));
21729         val_conv.is_owned = (val & 1) || (val == 0);
21730         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
21731         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
21732 }
21733
21734 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
21735         LDKChannelTransactionParameters this_ptr_conv;
21736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21737         this_ptr_conv.is_owned = false;
21738         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
21739         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21740         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21741         uint64_t ret_ref = (uint64_t)ret_var.inner;
21742         if (ret_var.is_owned) {
21743                 ret_ref |= 1;
21744         }
21745         return ret_ref;
21746 }
21747
21748 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
21749         LDKChannelTransactionParameters this_ptr_conv;
21750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21751         this_ptr_conv.is_owned = false;
21752         LDKOutPoint val_conv;
21753         val_conv.inner = (void*)(val & (~1));
21754         val_conv.is_owned = (val & 1) || (val == 0);
21755         val_conv = OutPoint_clone(&val_conv);
21756         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
21757 }
21758
21759 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) {
21760         LDKChannelPublicKeys holder_pubkeys_arg_conv;
21761         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
21762         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
21763         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
21764         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
21765         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
21766         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
21767         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
21768         LDKOutPoint funding_outpoint_arg_conv;
21769         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
21770         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
21771         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
21772         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);
21773         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21774         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21775         uint64_t ret_ref = (uint64_t)ret_var.inner;
21776         if (ret_var.is_owned) {
21777                 ret_ref |= 1;
21778         }
21779         return ret_ref;
21780 }
21781
21782 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
21783         LDKChannelTransactionParameters orig_conv;
21784         orig_conv.inner = (void*)(orig & (~1));
21785         orig_conv.is_owned = false;
21786         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
21787         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21788         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21789         uint64_t ret_ref = (uint64_t)ret_var.inner;
21790         if (ret_var.is_owned) {
21791                 ret_ref |= 1;
21792         }
21793         return ret_ref;
21794 }
21795
21796 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
21797         LDKCounterpartyChannelTransactionParameters this_obj_conv;
21798         this_obj_conv.inner = (void*)(this_obj & (~1));
21799         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21800         CounterpartyChannelTransactionParameters_free(this_obj_conv);
21801 }
21802
21803 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
21804         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21806         this_ptr_conv.is_owned = false;
21807         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
21808         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21809         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21810         uint64_t ret_ref = (uint64_t)ret_var.inner;
21811         if (ret_var.is_owned) {
21812                 ret_ref |= 1;
21813         }
21814         return ret_ref;
21815 }
21816
21817 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
21818         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21820         this_ptr_conv.is_owned = false;
21821         LDKChannelPublicKeys val_conv;
21822         val_conv.inner = (void*)(val & (~1));
21823         val_conv.is_owned = (val & 1) || (val == 0);
21824         val_conv = ChannelPublicKeys_clone(&val_conv);
21825         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
21826 }
21827
21828 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
21829         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21831         this_ptr_conv.is_owned = false;
21832         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
21833         return ret_val;
21834 }
21835
21836 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
21837         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21839         this_ptr_conv.is_owned = false;
21840         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
21841 }
21842
21843 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
21844         LDKChannelPublicKeys pubkeys_arg_conv;
21845         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
21846         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
21847         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
21848         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
21849         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21850         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21851         uint64_t ret_ref = (uint64_t)ret_var.inner;
21852         if (ret_var.is_owned) {
21853                 ret_ref |= 1;
21854         }
21855         return ret_ref;
21856 }
21857
21858 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
21859         LDKCounterpartyChannelTransactionParameters orig_conv;
21860         orig_conv.inner = (void*)(orig & (~1));
21861         orig_conv.is_owned = false;
21862         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
21863         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21864         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21865         uint64_t ret_ref = (uint64_t)ret_var.inner;
21866         if (ret_var.is_owned) {
21867                 ret_ref |= 1;
21868         }
21869         return ret_ref;
21870 }
21871
21872 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
21873         LDKChannelTransactionParameters this_arg_conv;
21874         this_arg_conv.inner = (void*)(this_arg & (~1));
21875         this_arg_conv.is_owned = false;
21876         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
21877         return ret_val;
21878 }
21879
21880 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
21881         LDKChannelTransactionParameters this_arg_conv;
21882         this_arg_conv.inner = (void*)(this_arg & (~1));
21883         this_arg_conv.is_owned = false;
21884         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
21885         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21886         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21887         uint64_t ret_ref = (uint64_t)ret_var.inner;
21888         if (ret_var.is_owned) {
21889                 ret_ref |= 1;
21890         }
21891         return ret_ref;
21892 }
21893
21894 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
21895         LDKChannelTransactionParameters this_arg_conv;
21896         this_arg_conv.inner = (void*)(this_arg & (~1));
21897         this_arg_conv.is_owned = false;
21898         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
21899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21901         uint64_t ret_ref = (uint64_t)ret_var.inner;
21902         if (ret_var.is_owned) {
21903                 ret_ref |= 1;
21904         }
21905         return ret_ref;
21906 }
21907
21908 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
21909         LDKCounterpartyChannelTransactionParameters obj_conv;
21910         obj_conv.inner = (void*)(obj & (~1));
21911         obj_conv.is_owned = false;
21912         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
21913         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21914         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21915         CVec_u8Z_free(ret_var);
21916         return ret_arr;
21917 }
21918
21919 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
21920         LDKu8slice ser_ref;
21921         ser_ref.datalen = *((uint32_t*)ser);
21922         ser_ref.data = (int8_t*)(ser + 4);
21923         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
21924         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
21925         return (uint64_t)ret_conv;
21926 }
21927
21928 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
21929         LDKChannelTransactionParameters obj_conv;
21930         obj_conv.inner = (void*)(obj & (~1));
21931         obj_conv.is_owned = false;
21932         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
21933         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21934         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21935         CVec_u8Z_free(ret_var);
21936         return ret_arr;
21937 }
21938
21939 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
21940         LDKu8slice ser_ref;
21941         ser_ref.datalen = *((uint32_t*)ser);
21942         ser_ref.data = (int8_t*)(ser + 4);
21943         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
21944         *ret_conv = ChannelTransactionParameters_read(ser_ref);
21945         return (uint64_t)ret_conv;
21946 }
21947
21948 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
21949         LDKDirectedChannelTransactionParameters this_obj_conv;
21950         this_obj_conv.inner = (void*)(this_obj & (~1));
21951         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21952         DirectedChannelTransactionParameters_free(this_obj_conv);
21953 }
21954
21955 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
21956         LDKDirectedChannelTransactionParameters this_arg_conv;
21957         this_arg_conv.inner = (void*)(this_arg & (~1));
21958         this_arg_conv.is_owned = false;
21959         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_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 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
21970         LDKDirectedChannelTransactionParameters this_arg_conv;
21971         this_arg_conv.inner = (void*)(this_arg & (~1));
21972         this_arg_conv.is_owned = false;
21973         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
21974         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21975         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21976         uint64_t ret_ref = (uint64_t)ret_var.inner;
21977         if (ret_var.is_owned) {
21978                 ret_ref |= 1;
21979         }
21980         return ret_ref;
21981 }
21982
21983 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
21984         LDKDirectedChannelTransactionParameters this_arg_conv;
21985         this_arg_conv.inner = (void*)(this_arg & (~1));
21986         this_arg_conv.is_owned = false;
21987         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
21988         return ret_val;
21989 }
21990
21991 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
21992         LDKDirectedChannelTransactionParameters this_arg_conv;
21993         this_arg_conv.inner = (void*)(this_arg & (~1));
21994         this_arg_conv.is_owned = false;
21995         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
21996         return ret_val;
21997 }
21998
21999 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
22000         LDKDirectedChannelTransactionParameters this_arg_conv;
22001         this_arg_conv.inner = (void*)(this_arg & (~1));
22002         this_arg_conv.is_owned = false;
22003         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
22004         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22005         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22006         uint64_t ret_ref = (uint64_t)ret_var.inner;
22007         if (ret_var.is_owned) {
22008                 ret_ref |= 1;
22009         }
22010         return ret_ref;
22011 }
22012
22013 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
22014         LDKHolderCommitmentTransaction this_obj_conv;
22015         this_obj_conv.inner = (void*)(this_obj & (~1));
22016         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22017         HolderCommitmentTransaction_free(this_obj_conv);
22018 }
22019
22020 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
22021         LDKHolderCommitmentTransaction this_ptr_conv;
22022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22023         this_ptr_conv.is_owned = false;
22024         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
22025         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
22026         return ret_arr;
22027 }
22028
22029 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
22030         LDKHolderCommitmentTransaction this_ptr_conv;
22031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22032         this_ptr_conv.is_owned = false;
22033         LDKSignature val_ref;
22034         CHECK(*((uint32_t*)val) == 64);
22035         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
22036         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
22037 }
22038
22039 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
22040         LDKHolderCommitmentTransaction this_ptr_conv;
22041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22042         this_ptr_conv.is_owned = false;
22043         LDKCVec_SignatureZ val_constr;
22044         val_constr.datalen = *((uint32_t*)val);
22045         if (val_constr.datalen > 0)
22046                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22047         else
22048                 val_constr.data = NULL;
22049         int8_tArray* val_vals = (int8_tArray*)(val + 4);
22050         for (size_t m = 0; m < val_constr.datalen; m++) {
22051                 int8_tArray val_conv_12 = val_vals[m];
22052                 LDKSignature val_conv_12_ref;
22053                 CHECK(*((uint32_t*)val_conv_12) == 64);
22054                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
22055                 val_constr.data[m] = val_conv_12_ref;
22056         }
22057         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
22058 }
22059
22060 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
22061         LDKHolderCommitmentTransaction orig_conv;
22062         orig_conv.inner = (void*)(orig & (~1));
22063         orig_conv.is_owned = false;
22064         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
22065         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22066         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22067         uint64_t ret_ref = (uint64_t)ret_var.inner;
22068         if (ret_var.is_owned) {
22069                 ret_ref |= 1;
22070         }
22071         return ret_ref;
22072 }
22073
22074 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
22075         LDKHolderCommitmentTransaction obj_conv;
22076         obj_conv.inner = (void*)(obj & (~1));
22077         obj_conv.is_owned = false;
22078         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
22079         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22080         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22081         CVec_u8Z_free(ret_var);
22082         return ret_arr;
22083 }
22084
22085 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
22086         LDKu8slice ser_ref;
22087         ser_ref.datalen = *((uint32_t*)ser);
22088         ser_ref.data = (int8_t*)(ser + 4);
22089         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
22090         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
22091         return (uint64_t)ret_conv;
22092 }
22093
22094 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) {
22095         LDKCommitmentTransaction commitment_tx_conv;
22096         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
22097         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
22098         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
22099         LDKSignature counterparty_sig_ref;
22100         CHECK(*((uint32_t*)counterparty_sig) == 64);
22101         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
22102         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
22103         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
22104         if (counterparty_htlc_sigs_constr.datalen > 0)
22105                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22106         else
22107                 counterparty_htlc_sigs_constr.data = NULL;
22108         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
22109         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
22110                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
22111                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
22112                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
22113                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
22114                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
22115         }
22116         LDKPublicKey holder_funding_key_ref;
22117         CHECK(*((uint32_t*)holder_funding_key) == 33);
22118         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
22119         LDKPublicKey counterparty_funding_key_ref;
22120         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
22121         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
22122         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
22123         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22124         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22125         uint64_t ret_ref = (uint64_t)ret_var.inner;
22126         if (ret_var.is_owned) {
22127                 ret_ref |= 1;
22128         }
22129         return ret_ref;
22130 }
22131
22132 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
22133         LDKBuiltCommitmentTransaction this_obj_conv;
22134         this_obj_conv.inner = (void*)(this_obj & (~1));
22135         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22136         BuiltCommitmentTransaction_free(this_obj_conv);
22137 }
22138
22139 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
22140         LDKBuiltCommitmentTransaction this_ptr_conv;
22141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22142         this_ptr_conv.is_owned = false;
22143         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
22144         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22145         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22146         Transaction_free(ret_var);
22147         return ret_arr;
22148 }
22149
22150 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
22151         LDKBuiltCommitmentTransaction this_ptr_conv;
22152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22153         this_ptr_conv.is_owned = false;
22154         LDKTransaction val_ref;
22155         val_ref.datalen = *((uint32_t*)val);
22156         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
22157         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
22158         val_ref.data_is_owned = true;
22159         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
22160 }
22161
22162 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
22163         LDKBuiltCommitmentTransaction this_ptr_conv;
22164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22165         this_ptr_conv.is_owned = false;
22166         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22167         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
22168         return ret_arr;
22169 }
22170
22171 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
22172         LDKBuiltCommitmentTransaction this_ptr_conv;
22173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22174         this_ptr_conv.is_owned = false;
22175         LDKThirtyTwoBytes val_ref;
22176         CHECK(*((uint32_t*)val) == 32);
22177         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22178         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
22179 }
22180
22181 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
22182         LDKTransaction transaction_arg_ref;
22183         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
22184         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
22185         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
22186         transaction_arg_ref.data_is_owned = true;
22187         LDKThirtyTwoBytes txid_arg_ref;
22188         CHECK(*((uint32_t*)txid_arg) == 32);
22189         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
22190         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
22191         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22192         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22193         uint64_t ret_ref = (uint64_t)ret_var.inner;
22194         if (ret_var.is_owned) {
22195                 ret_ref |= 1;
22196         }
22197         return ret_ref;
22198 }
22199
22200 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
22201         LDKBuiltCommitmentTransaction orig_conv;
22202         orig_conv.inner = (void*)(orig & (~1));
22203         orig_conv.is_owned = false;
22204         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
22205         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22206         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22207         uint64_t ret_ref = (uint64_t)ret_var.inner;
22208         if (ret_var.is_owned) {
22209                 ret_ref |= 1;
22210         }
22211         return ret_ref;
22212 }
22213
22214 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
22215         LDKBuiltCommitmentTransaction obj_conv;
22216         obj_conv.inner = (void*)(obj & (~1));
22217         obj_conv.is_owned = false;
22218         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
22219         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22220         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22221         CVec_u8Z_free(ret_var);
22222         return ret_arr;
22223 }
22224
22225 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
22226         LDKu8slice ser_ref;
22227         ser_ref.datalen = *((uint32_t*)ser);
22228         ser_ref.data = (int8_t*)(ser + 4);
22229         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
22230         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
22231         return (uint64_t)ret_conv;
22232 }
22233
22234 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
22235         LDKBuiltCommitmentTransaction this_arg_conv;
22236         this_arg_conv.inner = (void*)(this_arg & (~1));
22237         this_arg_conv.is_owned = false;
22238         LDKu8slice funding_redeemscript_ref;
22239         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
22240         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
22241         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22242         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
22243         return ret_arr;
22244 }
22245
22246 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) {
22247         LDKBuiltCommitmentTransaction this_arg_conv;
22248         this_arg_conv.inner = (void*)(this_arg & (~1));
22249         this_arg_conv.is_owned = false;
22250         unsigned char funding_key_arr[32];
22251         CHECK(*((uint32_t*)funding_key) == 32);
22252         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
22253         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
22254         LDKu8slice funding_redeemscript_ref;
22255         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
22256         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
22257         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
22258         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
22259         return ret_arr;
22260 }
22261
22262 void  __attribute__((visibility("default"))) TS_ClosingTransaction_free(uint32_t this_obj) {
22263         LDKClosingTransaction this_obj_conv;
22264         this_obj_conv.inner = (void*)(this_obj & (~1));
22265         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22266         ClosingTransaction_free(this_obj_conv);
22267 }
22268
22269 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_new(int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, uint32_t funding_outpoint) {
22270         LDKCVec_u8Z to_holder_script_ref;
22271         to_holder_script_ref.datalen = *((uint32_t*)to_holder_script);
22272         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
22273         memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen);
22274         LDKCVec_u8Z to_counterparty_script_ref;
22275         to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script);
22276         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
22277         memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen);
22278         LDKOutPoint funding_outpoint_conv;
22279         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
22280         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
22281         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
22282         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
22283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22285         uint64_t ret_ref = (uint64_t)ret_var.inner;
22286         if (ret_var.is_owned) {
22287                 ret_ref |= 1;
22288         }
22289         return ret_ref;
22290 }
22291
22292 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
22293         LDKClosingTransaction this_arg_conv;
22294         this_arg_conv.inner = (void*)(this_arg & (~1));
22295         this_arg_conv.is_owned = false;
22296         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
22297         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22298         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22299         uint64_t ret_ref = (uint64_t)ret_var.inner;
22300         if (ret_var.is_owned) {
22301                 ret_ref |= 1;
22302         }
22303         return ret_ref;
22304 }
22305
22306 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
22307         LDKClosingTransaction this_arg_conv;
22308         this_arg_conv.inner = (void*)(this_arg & (~1));
22309         this_arg_conv.is_owned = false;
22310         LDKOutPoint funding_outpoint_conv;
22311         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
22312         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
22313         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
22314         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
22315         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
22316         return (uint64_t)ret_conv;
22317 }
22318
22319 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
22320         LDKClosingTransaction this_arg_conv;
22321         this_arg_conv.inner = (void*)(this_arg & (~1));
22322         this_arg_conv.is_owned = false;
22323         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
22324         return ret_val;
22325 }
22326
22327 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
22328         LDKClosingTransaction this_arg_conv;
22329         this_arg_conv.inner = (void*)(this_arg & (~1));
22330         this_arg_conv.is_owned = false;
22331         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
22332         return ret_val;
22333 }
22334
22335 int8_tArray  __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
22336         LDKClosingTransaction this_arg_conv;
22337         this_arg_conv.inner = (void*)(this_arg & (~1));
22338         this_arg_conv.is_owned = false;
22339         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
22340         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22341         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22342         return ret_arr;
22343 }
22344
22345 int8_tArray  __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
22346         LDKClosingTransaction this_arg_conv;
22347         this_arg_conv.inner = (void*)(this_arg & (~1));
22348         this_arg_conv.is_owned = false;
22349         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
22350         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22351         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22352         return ret_arr;
22353 }
22354
22355 void  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
22356         LDKTrustedClosingTransaction this_obj_conv;
22357         this_obj_conv.inner = (void*)(this_obj & (~1));
22358         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22359         TrustedClosingTransaction_free(this_obj_conv);
22360 }
22361
22362 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
22363         LDKTrustedClosingTransaction this_arg_conv;
22364         this_arg_conv.inner = (void*)(this_arg & (~1));
22365         this_arg_conv.is_owned = false;
22366         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
22367         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22368         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22369         Transaction_free(ret_var);
22370         return ret_arr;
22371 }
22372
22373 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
22374         LDKTrustedClosingTransaction this_arg_conv;
22375         this_arg_conv.inner = (void*)(this_arg & (~1));
22376         this_arg_conv.is_owned = false;
22377         LDKu8slice funding_redeemscript_ref;
22378         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
22379         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
22380         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22381         memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
22382         return ret_arr;
22383 }
22384
22385 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_sign(uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
22386         LDKTrustedClosingTransaction this_arg_conv;
22387         this_arg_conv.inner = (void*)(this_arg & (~1));
22388         this_arg_conv.is_owned = false;
22389         unsigned char funding_key_arr[32];
22390         CHECK(*((uint32_t*)funding_key) == 32);
22391         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
22392         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
22393         LDKu8slice funding_redeemscript_ref;
22394         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
22395         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
22396         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
22397         memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
22398         return ret_arr;
22399 }
22400
22401 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
22402         LDKCommitmentTransaction this_obj_conv;
22403         this_obj_conv.inner = (void*)(this_obj & (~1));
22404         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22405         CommitmentTransaction_free(this_obj_conv);
22406 }
22407
22408 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
22409         LDKCommitmentTransaction orig_conv;
22410         orig_conv.inner = (void*)(orig & (~1));
22411         orig_conv.is_owned = false;
22412         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
22413         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22414         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22415         uint64_t ret_ref = (uint64_t)ret_var.inner;
22416         if (ret_var.is_owned) {
22417                 ret_ref |= 1;
22418         }
22419         return ret_ref;
22420 }
22421
22422 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
22423         LDKCommitmentTransaction obj_conv;
22424         obj_conv.inner = (void*)(obj & (~1));
22425         obj_conv.is_owned = false;
22426         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
22427         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22428         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22429         CVec_u8Z_free(ret_var);
22430         return ret_arr;
22431 }
22432
22433 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
22434         LDKu8slice ser_ref;
22435         ser_ref.datalen = *((uint32_t*)ser);
22436         ser_ref.data = (int8_t*)(ser + 4);
22437         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
22438         *ret_conv = CommitmentTransaction_read(ser_ref);
22439         return (uint64_t)ret_conv;
22440 }
22441
22442 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
22443         LDKCommitmentTransaction this_arg_conv;
22444         this_arg_conv.inner = (void*)(this_arg & (~1));
22445         this_arg_conv.is_owned = false;
22446         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
22447         return ret_val;
22448 }
22449
22450 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
22451         LDKCommitmentTransaction this_arg_conv;
22452         this_arg_conv.inner = (void*)(this_arg & (~1));
22453         this_arg_conv.is_owned = false;
22454         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
22455         return ret_val;
22456 }
22457
22458 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
22459         LDKCommitmentTransaction this_arg_conv;
22460         this_arg_conv.inner = (void*)(this_arg & (~1));
22461         this_arg_conv.is_owned = false;
22462         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
22463         return ret_val;
22464 }
22465
22466 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
22467         LDKCommitmentTransaction this_arg_conv;
22468         this_arg_conv.inner = (void*)(this_arg & (~1));
22469         this_arg_conv.is_owned = false;
22470         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
22471         return ret_val;
22472 }
22473
22474 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
22475         LDKCommitmentTransaction this_arg_conv;
22476         this_arg_conv.inner = (void*)(this_arg & (~1));
22477         this_arg_conv.is_owned = false;
22478         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
22479         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22480         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22481         uint64_t ret_ref = (uint64_t)ret_var.inner;
22482         if (ret_var.is_owned) {
22483                 ret_ref |= 1;
22484         }
22485         return ret_ref;
22486 }
22487
22488 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
22489         LDKCommitmentTransaction this_arg_conv;
22490         this_arg_conv.inner = (void*)(this_arg & (~1));
22491         this_arg_conv.is_owned = false;
22492         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22493         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22494         channel_parameters_conv.is_owned = false;
22495         LDKChannelPublicKeys broadcaster_keys_conv;
22496         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
22497         broadcaster_keys_conv.is_owned = false;
22498         LDKChannelPublicKeys countersignatory_keys_conv;
22499         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
22500         countersignatory_keys_conv.is_owned = false;
22501         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
22502         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
22503         return (uint64_t)ret_conv;
22504 }
22505
22506 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
22507         LDKTrustedCommitmentTransaction this_obj_conv;
22508         this_obj_conv.inner = (void*)(this_obj & (~1));
22509         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22510         TrustedCommitmentTransaction_free(this_obj_conv);
22511 }
22512
22513 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
22514         LDKTrustedCommitmentTransaction this_arg_conv;
22515         this_arg_conv.inner = (void*)(this_arg & (~1));
22516         this_arg_conv.is_owned = false;
22517         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22518         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
22519         return ret_arr;
22520 }
22521
22522 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
22523         LDKTrustedCommitmentTransaction this_arg_conv;
22524         this_arg_conv.inner = (void*)(this_arg & (~1));
22525         this_arg_conv.is_owned = false;
22526         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
22527         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22528         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22529         uint64_t ret_ref = (uint64_t)ret_var.inner;
22530         if (ret_var.is_owned) {
22531                 ret_ref |= 1;
22532         }
22533         return ret_ref;
22534 }
22535
22536 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
22537         LDKTrustedCommitmentTransaction this_arg_conv;
22538         this_arg_conv.inner = (void*)(this_arg & (~1));
22539         this_arg_conv.is_owned = false;
22540         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
22541         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22542         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22543         uint64_t ret_ref = (uint64_t)ret_var.inner;
22544         if (ret_var.is_owned) {
22545                 ret_ref |= 1;
22546         }
22547         return ret_ref;
22548 }
22549
22550 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
22551         LDKTrustedCommitmentTransaction this_arg_conv;
22552         this_arg_conv.inner = (void*)(this_arg & (~1));
22553         this_arg_conv.is_owned = false;
22554         unsigned char htlc_base_key_arr[32];
22555         CHECK(*((uint32_t*)htlc_base_key) == 32);
22556         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
22557         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
22558         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22559         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22560         channel_parameters_conv.is_owned = false;
22561         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
22562         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
22563         return (uint64_t)ret_conv;
22564 }
22565
22566 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) {
22567         LDKPublicKey broadcaster_payment_basepoint_ref;
22568         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
22569         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
22570         LDKPublicKey countersignatory_payment_basepoint_ref;
22571         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
22572         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
22573         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
22574         return ret_val;
22575 }
22576
22577 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
22578         LDKInitFeatures a_conv;
22579         a_conv.inner = (void*)(a & (~1));
22580         a_conv.is_owned = false;
22581         LDKInitFeatures b_conv;
22582         b_conv.inner = (void*)(b & (~1));
22583         b_conv.is_owned = false;
22584         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
22585         return ret_val;
22586 }
22587
22588 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
22589         LDKNodeFeatures a_conv;
22590         a_conv.inner = (void*)(a & (~1));
22591         a_conv.is_owned = false;
22592         LDKNodeFeatures b_conv;
22593         b_conv.inner = (void*)(b & (~1));
22594         b_conv.is_owned = false;
22595         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
22596         return ret_val;
22597 }
22598
22599 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
22600         LDKChannelFeatures a_conv;
22601         a_conv.inner = (void*)(a & (~1));
22602         a_conv.is_owned = false;
22603         LDKChannelFeatures b_conv;
22604         b_conv.inner = (void*)(b & (~1));
22605         b_conv.is_owned = false;
22606         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
22607         return ret_val;
22608 }
22609
22610 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
22611         LDKInvoiceFeatures a_conv;
22612         a_conv.inner = (void*)(a & (~1));
22613         a_conv.is_owned = false;
22614         LDKInvoiceFeatures b_conv;
22615         b_conv.inner = (void*)(b & (~1));
22616         b_conv.is_owned = false;
22617         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
22618         return ret_val;
22619 }
22620
22621 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
22622         LDKInitFeatures orig_conv;
22623         orig_conv.inner = (void*)(orig & (~1));
22624         orig_conv.is_owned = false;
22625         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
22626         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22627         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22628         uint64_t ret_ref = (uint64_t)ret_var.inner;
22629         if (ret_var.is_owned) {
22630                 ret_ref |= 1;
22631         }
22632         return ret_ref;
22633 }
22634
22635 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
22636         LDKNodeFeatures orig_conv;
22637         orig_conv.inner = (void*)(orig & (~1));
22638         orig_conv.is_owned = false;
22639         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
22640         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22641         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22642         uint64_t ret_ref = (uint64_t)ret_var.inner;
22643         if (ret_var.is_owned) {
22644                 ret_ref |= 1;
22645         }
22646         return ret_ref;
22647 }
22648
22649 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
22650         LDKChannelFeatures orig_conv;
22651         orig_conv.inner = (void*)(orig & (~1));
22652         orig_conv.is_owned = false;
22653         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
22654         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22655         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22656         uint64_t ret_ref = (uint64_t)ret_var.inner;
22657         if (ret_var.is_owned) {
22658                 ret_ref |= 1;
22659         }
22660         return ret_ref;
22661 }
22662
22663 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
22664         LDKInvoiceFeatures orig_conv;
22665         orig_conv.inner = (void*)(orig & (~1));
22666         orig_conv.is_owned = false;
22667         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
22668         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22669         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22670         uint64_t ret_ref = (uint64_t)ret_var.inner;
22671         if (ret_var.is_owned) {
22672                 ret_ref |= 1;
22673         }
22674         return ret_ref;
22675 }
22676
22677 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
22678         LDKInitFeatures this_obj_conv;
22679         this_obj_conv.inner = (void*)(this_obj & (~1));
22680         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22681         InitFeatures_free(this_obj_conv);
22682 }
22683
22684 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
22685         LDKNodeFeatures this_obj_conv;
22686         this_obj_conv.inner = (void*)(this_obj & (~1));
22687         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22688         NodeFeatures_free(this_obj_conv);
22689 }
22690
22691 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
22692         LDKChannelFeatures this_obj_conv;
22693         this_obj_conv.inner = (void*)(this_obj & (~1));
22694         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22695         ChannelFeatures_free(this_obj_conv);
22696 }
22697
22698 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
22699         LDKInvoiceFeatures this_obj_conv;
22700         this_obj_conv.inner = (void*)(this_obj & (~1));
22701         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22702         InvoiceFeatures_free(this_obj_conv);
22703 }
22704
22705 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
22706         LDKInitFeatures ret_var = InitFeatures_empty();
22707         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22708         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22709         uint64_t ret_ref = (uint64_t)ret_var.inner;
22710         if (ret_var.is_owned) {
22711                 ret_ref |= 1;
22712         }
22713         return ret_ref;
22714 }
22715
22716 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
22717         LDKInitFeatures ret_var = InitFeatures_known();
22718         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22719         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22720         uint64_t ret_ref = (uint64_t)ret_var.inner;
22721         if (ret_var.is_owned) {
22722                 ret_ref |= 1;
22723         }
22724         return ret_ref;
22725 }
22726
22727 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
22728         LDKInitFeatures this_arg_conv;
22729         this_arg_conv.inner = (void*)(this_arg & (~1));
22730         this_arg_conv.is_owned = false;
22731         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
22732         return ret_val;
22733 }
22734
22735 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
22736         LDKNodeFeatures ret_var = NodeFeatures_empty();
22737         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22738         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22739         uint64_t ret_ref = (uint64_t)ret_var.inner;
22740         if (ret_var.is_owned) {
22741                 ret_ref |= 1;
22742         }
22743         return ret_ref;
22744 }
22745
22746 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
22747         LDKNodeFeatures ret_var = NodeFeatures_known();
22748         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22749         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22750         uint64_t ret_ref = (uint64_t)ret_var.inner;
22751         if (ret_var.is_owned) {
22752                 ret_ref |= 1;
22753         }
22754         return ret_ref;
22755 }
22756
22757 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
22758         LDKNodeFeatures this_arg_conv;
22759         this_arg_conv.inner = (void*)(this_arg & (~1));
22760         this_arg_conv.is_owned = false;
22761         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
22762         return ret_val;
22763 }
22764
22765 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
22766         LDKChannelFeatures ret_var = ChannelFeatures_empty();
22767         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22768         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22769         uint64_t ret_ref = (uint64_t)ret_var.inner;
22770         if (ret_var.is_owned) {
22771                 ret_ref |= 1;
22772         }
22773         return ret_ref;
22774 }
22775
22776 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
22777         LDKChannelFeatures ret_var = ChannelFeatures_known();
22778         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22779         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22780         uint64_t ret_ref = (uint64_t)ret_var.inner;
22781         if (ret_var.is_owned) {
22782                 ret_ref |= 1;
22783         }
22784         return ret_ref;
22785 }
22786
22787 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
22788         LDKChannelFeatures this_arg_conv;
22789         this_arg_conv.inner = (void*)(this_arg & (~1));
22790         this_arg_conv.is_owned = false;
22791         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
22792         return ret_val;
22793 }
22794
22795 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
22796         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
22797         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22798         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22799         uint64_t ret_ref = (uint64_t)ret_var.inner;
22800         if (ret_var.is_owned) {
22801                 ret_ref |= 1;
22802         }
22803         return ret_ref;
22804 }
22805
22806 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
22807         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
22808         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22809         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22810         uint64_t ret_ref = (uint64_t)ret_var.inner;
22811         if (ret_var.is_owned) {
22812                 ret_ref |= 1;
22813         }
22814         return ret_ref;
22815 }
22816
22817 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
22818         LDKInvoiceFeatures this_arg_conv;
22819         this_arg_conv.inner = (void*)(this_arg & (~1));
22820         this_arg_conv.is_owned = false;
22821         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
22822         return ret_val;
22823 }
22824
22825 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
22826         LDKInitFeatures this_arg_conv;
22827         this_arg_conv.inner = (void*)(this_arg & (~1));
22828         this_arg_conv.is_owned = false;
22829         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
22830         return ret_val;
22831 }
22832
22833 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
22834         LDKNodeFeatures this_arg_conv;
22835         this_arg_conv.inner = (void*)(this_arg & (~1));
22836         this_arg_conv.is_owned = false;
22837         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
22838         return ret_val;
22839 }
22840
22841 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
22842         LDKInvoiceFeatures this_arg_conv;
22843         this_arg_conv.inner = (void*)(this_arg & (~1));
22844         this_arg_conv.is_owned = false;
22845         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
22846         return ret_val;
22847 }
22848
22849 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
22850         LDKInitFeatures obj_conv;
22851         obj_conv.inner = (void*)(obj & (~1));
22852         obj_conv.is_owned = false;
22853         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
22854         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22855         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22856         CVec_u8Z_free(ret_var);
22857         return ret_arr;
22858 }
22859
22860 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
22861         LDKNodeFeatures obj_conv;
22862         obj_conv.inner = (void*)(obj & (~1));
22863         obj_conv.is_owned = false;
22864         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
22865         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22866         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22867         CVec_u8Z_free(ret_var);
22868         return ret_arr;
22869 }
22870
22871 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
22872         LDKChannelFeatures obj_conv;
22873         obj_conv.inner = (void*)(obj & (~1));
22874         obj_conv.is_owned = false;
22875         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
22876         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22877         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22878         CVec_u8Z_free(ret_var);
22879         return ret_arr;
22880 }
22881
22882 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
22883         LDKInvoiceFeatures obj_conv;
22884         obj_conv.inner = (void*)(obj & (~1));
22885         obj_conv.is_owned = false;
22886         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
22887         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22888         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22889         CVec_u8Z_free(ret_var);
22890         return ret_arr;
22891 }
22892
22893 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
22894         LDKu8slice ser_ref;
22895         ser_ref.datalen = *((uint32_t*)ser);
22896         ser_ref.data = (int8_t*)(ser + 4);
22897         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
22898         *ret_conv = InitFeatures_read(ser_ref);
22899         return (uint64_t)ret_conv;
22900 }
22901
22902 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
22903         LDKu8slice ser_ref;
22904         ser_ref.datalen = *((uint32_t*)ser);
22905         ser_ref.data = (int8_t*)(ser + 4);
22906         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
22907         *ret_conv = NodeFeatures_read(ser_ref);
22908         return (uint64_t)ret_conv;
22909 }
22910
22911 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
22912         LDKu8slice ser_ref;
22913         ser_ref.datalen = *((uint32_t*)ser);
22914         ser_ref.data = (int8_t*)(ser + 4);
22915         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
22916         *ret_conv = ChannelFeatures_read(ser_ref);
22917         return (uint64_t)ret_conv;
22918 }
22919
22920 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
22921         LDKu8slice ser_ref;
22922         ser_ref.datalen = *((uint32_t*)ser);
22923         ser_ref.data = (int8_t*)(ser + 4);
22924         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
22925         *ret_conv = InvoiceFeatures_read(ser_ref);
22926         return (uint64_t)ret_conv;
22927 }
22928
22929 void  __attribute__((visibility("default"))) TS_ShutdownScript_free(uint32_t this_obj) {
22930         LDKShutdownScript this_obj_conv;
22931         this_obj_conv.inner = (void*)(this_obj & (~1));
22932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22933         ShutdownScript_free(this_obj_conv);
22934 }
22935
22936 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_clone(uint32_t orig) {
22937         LDKShutdownScript orig_conv;
22938         orig_conv.inner = (void*)(orig & (~1));
22939         orig_conv.is_owned = false;
22940         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
22941         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22942         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22943         uint64_t ret_ref = (uint64_t)ret_var.inner;
22944         if (ret_var.is_owned) {
22945                 ret_ref |= 1;
22946         }
22947         return ret_ref;
22948 }
22949
22950 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
22951         LDKInvalidShutdownScript this_obj_conv;
22952         this_obj_conv.inner = (void*)(this_obj & (~1));
22953         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22954         InvalidShutdownScript_free(this_obj_conv);
22955 }
22956
22957 int8_tArray  __attribute__((visibility("default"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
22958         LDKInvalidShutdownScript this_ptr_conv;
22959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22960         this_ptr_conv.is_owned = false;
22961         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
22962         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22963         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22964         return ret_arr;
22965 }
22966
22967 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
22968         LDKInvalidShutdownScript this_ptr_conv;
22969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22970         this_ptr_conv.is_owned = false;
22971         LDKCVec_u8Z val_ref;
22972         val_ref.datalen = *((uint32_t*)val);
22973         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
22974         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
22975         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
22976 }
22977
22978 uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
22979         LDKCVec_u8Z script_arg_ref;
22980         script_arg_ref.datalen = *((uint32_t*)script_arg);
22981         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
22982         memcpy(script_arg_ref.data, (uint8_t*)(script_arg + 4), script_arg_ref.datalen);
22983         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
22984         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22985         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22986         uint64_t ret_ref = (uint64_t)ret_var.inner;
22987         if (ret_var.is_owned) {
22988                 ret_ref |= 1;
22989         }
22990         return ret_ref;
22991 }
22992
22993 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_write(uint32_t obj) {
22994         LDKShutdownScript obj_conv;
22995         obj_conv.inner = (void*)(obj & (~1));
22996         obj_conv.is_owned = false;
22997         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
22998         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22999         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23000         CVec_u8Z_free(ret_var);
23001         return ret_arr;
23002 }
23003
23004 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_read(int8_tArray ser) {
23005         LDKu8slice ser_ref;
23006         ser_ref.datalen = *((uint32_t*)ser);
23007         ser_ref.data = (int8_t*)(ser + 4);
23008         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
23009         *ret_conv = ShutdownScript_read(ser_ref);
23010         return (uint64_t)ret_conv;
23011 }
23012
23013 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2pkh(int8_tArray pubkey_hash) {
23014         unsigned char pubkey_hash_arr[20];
23015         CHECK(*((uint32_t*)pubkey_hash) == 20);
23016         memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20);
23017         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
23018         LDKShutdownScript ret_var = ShutdownScript_new_p2pkh(pubkey_hash_ref);
23019         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23020         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23021         uint64_t ret_ref = (uint64_t)ret_var.inner;
23022         if (ret_var.is_owned) {
23023                 ret_ref |= 1;
23024         }
23025         return ret_ref;
23026 }
23027
23028 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2sh(int8_tArray script_hash) {
23029         unsigned char script_hash_arr[20];
23030         CHECK(*((uint32_t*)script_hash) == 20);
23031         memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 20);
23032         unsigned char (*script_hash_ref)[20] = &script_hash_arr;
23033         LDKShutdownScript ret_var = ShutdownScript_new_p2sh(script_hash_ref);
23034         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23035         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23036         uint64_t ret_ref = (uint64_t)ret_var.inner;
23037         if (ret_var.is_owned) {
23038                 ret_ref |= 1;
23039         }
23040         return ret_ref;
23041 }
23042
23043 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
23044         unsigned char pubkey_hash_arr[20];
23045         CHECK(*((uint32_t*)pubkey_hash) == 20);
23046         memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20);
23047         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
23048         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
23049         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23050         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23051         uint64_t ret_ref = (uint64_t)ret_var.inner;
23052         if (ret_var.is_owned) {
23053                 ret_ref |= 1;
23054         }
23055         return ret_ref;
23056 }
23057
23058 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
23059         unsigned char script_hash_arr[32];
23060         CHECK(*((uint32_t*)script_hash) == 32);
23061         memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 32);
23062         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
23063         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
23064         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23065         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23066         uint64_t ret_ref = (uint64_t)ret_var.inner;
23067         if (ret_var.is_owned) {
23068                 ret_ref |= 1;
23069         }
23070         return ret_ref;
23071 }
23072
23073 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
23074         LDKu8slice program_ref;
23075         program_ref.datalen = *((uint32_t*)program);
23076         program_ref.data = (int8_t*)(program + 4);
23077         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
23078         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
23079         return (uint64_t)ret_conv;
23080 }
23081
23082 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
23083         LDKShutdownScript this_arg_conv;
23084         this_arg_conv.inner = (void*)(this_arg & (~1));
23085         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
23086         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
23087         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
23088         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23089         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23090         CVec_u8Z_free(ret_var);
23091         return ret_arr;
23092 }
23093
23094 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
23095         LDKShutdownScript this_arg_conv;
23096         this_arg_conv.inner = (void*)(this_arg & (~1));
23097         this_arg_conv.is_owned = false;
23098         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23099         memcpy((uint8_t*)(ret_arr + 4), ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
23100         return ret_arr;
23101 }
23102
23103 jboolean  __attribute__((visibility("default"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
23104         LDKShutdownScript this_arg_conv;
23105         this_arg_conv.inner = (void*)(this_arg & (~1));
23106         this_arg_conv.is_owned = false;
23107         LDKInitFeatures features_conv;
23108         features_conv.inner = (void*)(features & (~1));
23109         features_conv.is_owned = false;
23110         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
23111         return ret_val;
23112 }
23113
23114 void  __attribute__((visibility("default"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
23115         if ((this_ptr & 1) != 0) return;
23116         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(((uint64_t)this_ptr) & ~1);
23117         FREE((void*)this_ptr);
23118         CustomMessageReader_free(this_ptr_conv);
23119 }
23120
23121 uint32_t  __attribute__((visibility("default"))) TS_Type_clone(uint32_t orig) {
23122         LDKType* orig_conv = (LDKType*)(((uint64_t)orig) & ~1);
23123         LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
23124         *ret_ret = Type_clone(orig_conv);
23125         return (uint64_t)ret_ret;
23126 }
23127
23128 void  __attribute__((visibility("default"))) TS_Type_free(uint32_t this_ptr) {
23129         if ((this_ptr & 1) != 0) return;
23130         LDKType this_ptr_conv = *(LDKType*)(((uint64_t)this_ptr) & ~1);
23131         FREE((void*)this_ptr);
23132         Type_free(this_ptr_conv);
23133 }
23134
23135 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
23136         LDKRouteHop this_obj_conv;
23137         this_obj_conv.inner = (void*)(this_obj & (~1));
23138         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23139         RouteHop_free(this_obj_conv);
23140 }
23141
23142 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
23143         LDKRouteHop this_ptr_conv;
23144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23145         this_ptr_conv.is_owned = false;
23146         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23147         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
23148         return ret_arr;
23149 }
23150
23151 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
23152         LDKRouteHop this_ptr_conv;
23153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23154         this_ptr_conv.is_owned = false;
23155         LDKPublicKey val_ref;
23156         CHECK(*((uint32_t*)val) == 33);
23157         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23158         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
23159 }
23160
23161 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
23162         LDKRouteHop this_ptr_conv;
23163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23164         this_ptr_conv.is_owned = false;
23165         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
23166         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23167         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23168         uint64_t ret_ref = (uint64_t)ret_var.inner;
23169         if (ret_var.is_owned) {
23170                 ret_ref |= 1;
23171         }
23172         return ret_ref;
23173 }
23174
23175 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
23176         LDKRouteHop this_ptr_conv;
23177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23178         this_ptr_conv.is_owned = false;
23179         LDKNodeFeatures val_conv;
23180         val_conv.inner = (void*)(val & (~1));
23181         val_conv.is_owned = (val & 1) || (val == 0);
23182         val_conv = NodeFeatures_clone(&val_conv);
23183         RouteHop_set_node_features(&this_ptr_conv, val_conv);
23184 }
23185
23186 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
23187         LDKRouteHop this_ptr_conv;
23188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23189         this_ptr_conv.is_owned = false;
23190         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
23191         return ret_val;
23192 }
23193
23194 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
23195         LDKRouteHop this_ptr_conv;
23196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23197         this_ptr_conv.is_owned = false;
23198         RouteHop_set_short_channel_id(&this_ptr_conv, val);
23199 }
23200
23201 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
23202         LDKRouteHop this_ptr_conv;
23203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23204         this_ptr_conv.is_owned = false;
23205         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
23206         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23207         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23208         uint64_t ret_ref = (uint64_t)ret_var.inner;
23209         if (ret_var.is_owned) {
23210                 ret_ref |= 1;
23211         }
23212         return ret_ref;
23213 }
23214
23215 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
23216         LDKRouteHop this_ptr_conv;
23217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23218         this_ptr_conv.is_owned = false;
23219         LDKChannelFeatures val_conv;
23220         val_conv.inner = (void*)(val & (~1));
23221         val_conv.is_owned = (val & 1) || (val == 0);
23222         val_conv = ChannelFeatures_clone(&val_conv);
23223         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
23224 }
23225
23226 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
23227         LDKRouteHop this_ptr_conv;
23228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23229         this_ptr_conv.is_owned = false;
23230         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
23231         return ret_val;
23232 }
23233
23234 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
23235         LDKRouteHop this_ptr_conv;
23236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23237         this_ptr_conv.is_owned = false;
23238         RouteHop_set_fee_msat(&this_ptr_conv, val);
23239 }
23240
23241 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
23242         LDKRouteHop this_ptr_conv;
23243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23244         this_ptr_conv.is_owned = false;
23245         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
23246         return ret_val;
23247 }
23248
23249 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
23250         LDKRouteHop this_ptr_conv;
23251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23252         this_ptr_conv.is_owned = false;
23253         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23254 }
23255
23256 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) {
23257         LDKPublicKey pubkey_arg_ref;
23258         CHECK(*((uint32_t*)pubkey_arg) == 33);
23259         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
23260         LDKNodeFeatures node_features_arg_conv;
23261         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
23262         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
23263         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
23264         LDKChannelFeatures channel_features_arg_conv;
23265         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
23266         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
23267         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
23268         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);
23269         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23270         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23271         uint64_t ret_ref = (uint64_t)ret_var.inner;
23272         if (ret_var.is_owned) {
23273                 ret_ref |= 1;
23274         }
23275         return ret_ref;
23276 }
23277
23278 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
23279         LDKRouteHop orig_conv;
23280         orig_conv.inner = (void*)(orig & (~1));
23281         orig_conv.is_owned = false;
23282         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
23283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23285         uint64_t ret_ref = (uint64_t)ret_var.inner;
23286         if (ret_var.is_owned) {
23287                 ret_ref |= 1;
23288         }
23289         return ret_ref;
23290 }
23291
23292 int64_t  __attribute__((visibility("default"))) TS_RouteHop_hash(uint32_t o) {
23293         LDKRouteHop o_conv;
23294         o_conv.inner = (void*)(o & (~1));
23295         o_conv.is_owned = false;
23296         int64_t ret_val = RouteHop_hash(&o_conv);
23297         return ret_val;
23298 }
23299
23300 jboolean  __attribute__((visibility("default"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
23301         LDKRouteHop a_conv;
23302         a_conv.inner = (void*)(a & (~1));
23303         a_conv.is_owned = false;
23304         LDKRouteHop b_conv;
23305         b_conv.inner = (void*)(b & (~1));
23306         b_conv.is_owned = false;
23307         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
23308         return ret_val;
23309 }
23310
23311 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) {
23312         LDKRouteHop obj_conv;
23313         obj_conv.inner = (void*)(obj & (~1));
23314         obj_conv.is_owned = false;
23315         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
23316         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23317         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23318         CVec_u8Z_free(ret_var);
23319         return ret_arr;
23320 }
23321
23322 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_read(int8_tArray ser) {
23323         LDKu8slice ser_ref;
23324         ser_ref.datalen = *((uint32_t*)ser);
23325         ser_ref.data = (int8_t*)(ser + 4);
23326         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
23327         *ret_conv = RouteHop_read(ser_ref);
23328         return (uint64_t)ret_conv;
23329 }
23330
23331 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
23332         LDKRoute this_obj_conv;
23333         this_obj_conv.inner = (void*)(this_obj & (~1));
23334         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23335         Route_free(this_obj_conv);
23336 }
23337
23338 ptrArray  __attribute__((visibility("default"))) TS_Route_get_paths(uint32_t this_ptr) {
23339         LDKRoute this_ptr_conv;
23340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23341         this_ptr_conv.is_owned = false;
23342         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
23343         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
23344         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(ret_arr + 4);
23345         for (size_t m = 0; m < ret_var.datalen; m++) {
23346                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
23347                 uint32_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
23348                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(ret_conv_12_arr + 4);
23349                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
23350                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
23351                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23352                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23353                         uint64_t ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
23354                         if (ret_conv_12_conv_10_var.is_owned) {
23355                                 ret_conv_12_conv_10_ref |= 1;
23356                         }
23357                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
23358                 }
23359                 FREE(ret_conv_12_var.data);
23360                 ret_arr_ptr[m] = ret_conv_12_arr;
23361         }
23362         FREE(ret_var.data);
23363         return ret_arr;
23364 }
23365
23366 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
23367         LDKRoute this_ptr_conv;
23368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23369         this_ptr_conv.is_owned = false;
23370         LDKCVec_CVec_RouteHopZZ val_constr;
23371         val_constr.datalen = *((uint32_t*)val);
23372         if (val_constr.datalen > 0)
23373                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
23374         else
23375                 val_constr.data = NULL;
23376         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
23377         for (size_t m = 0; m < val_constr.datalen; m++) {
23378                 uint32_tArray val_conv_12 = val_vals[m];
23379                 LDKCVec_RouteHopZ val_conv_12_constr;
23380                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
23381                 if (val_conv_12_constr.datalen > 0)
23382                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23383                 else
23384                         val_conv_12_constr.data = NULL;
23385                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
23386                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
23387                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
23388                         LDKRouteHop val_conv_12_conv_10_conv;
23389                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
23390                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
23391                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
23392                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
23393                 }
23394                 val_constr.data[m] = val_conv_12_constr;
23395         }
23396         Route_set_paths(&this_ptr_conv, val_constr);
23397 }
23398
23399 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
23400         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
23401         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
23402         if (paths_arg_constr.datalen > 0)
23403                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
23404         else
23405                 paths_arg_constr.data = NULL;
23406         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
23407         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
23408                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
23409                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
23410                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
23411                 if (paths_arg_conv_12_constr.datalen > 0)
23412                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23413                 else
23414                         paths_arg_conv_12_constr.data = NULL;
23415                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
23416                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
23417                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
23418                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
23419                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
23420                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
23421                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
23422                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
23423                 }
23424                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
23425         }
23426         LDKRoute ret_var = Route_new(paths_arg_constr);
23427         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23428         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23429         uint64_t ret_ref = (uint64_t)ret_var.inner;
23430         if (ret_var.is_owned) {
23431                 ret_ref |= 1;
23432         }
23433         return ret_ref;
23434 }
23435
23436 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
23437         LDKRoute orig_conv;
23438         orig_conv.inner = (void*)(orig & (~1));
23439         orig_conv.is_owned = false;
23440         LDKRoute ret_var = Route_clone(&orig_conv);
23441         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23442         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23443         uint64_t ret_ref = (uint64_t)ret_var.inner;
23444         if (ret_var.is_owned) {
23445                 ret_ref |= 1;
23446         }
23447         return ret_ref;
23448 }
23449
23450 int64_t  __attribute__((visibility("default"))) TS_Route_hash(uint32_t o) {
23451         LDKRoute o_conv;
23452         o_conv.inner = (void*)(o & (~1));
23453         o_conv.is_owned = false;
23454         int64_t ret_val = Route_hash(&o_conv);
23455         return ret_val;
23456 }
23457
23458 jboolean  __attribute__((visibility("default"))) TS_Route_eq(uint32_t a, uint32_t b) {
23459         LDKRoute a_conv;
23460         a_conv.inner = (void*)(a & (~1));
23461         a_conv.is_owned = false;
23462         LDKRoute b_conv;
23463         b_conv.inner = (void*)(b & (~1));
23464         b_conv.is_owned = false;
23465         jboolean ret_val = Route_eq(&a_conv, &b_conv);
23466         return ret_val;
23467 }
23468
23469 int64_t  __attribute__((visibility("default"))) TS_Route_get_total_fees(uint32_t this_arg) {
23470         LDKRoute this_arg_conv;
23471         this_arg_conv.inner = (void*)(this_arg & (~1));
23472         this_arg_conv.is_owned = false;
23473         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
23474         return ret_val;
23475 }
23476
23477 int64_t  __attribute__((visibility("default"))) TS_Route_get_total_amount(uint32_t this_arg) {
23478         LDKRoute this_arg_conv;
23479         this_arg_conv.inner = (void*)(this_arg & (~1));
23480         this_arg_conv.is_owned = false;
23481         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
23482         return ret_val;
23483 }
23484
23485 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
23486         LDKRoute obj_conv;
23487         obj_conv.inner = (void*)(obj & (~1));
23488         obj_conv.is_owned = false;
23489         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
23490         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23491         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23492         CVec_u8Z_free(ret_var);
23493         return ret_arr;
23494 }
23495
23496 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
23497         LDKu8slice ser_ref;
23498         ser_ref.datalen = *((uint32_t*)ser);
23499         ser_ref.data = (int8_t*)(ser + 4);
23500         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
23501         *ret_conv = Route_read(ser_ref);
23502         return (uint64_t)ret_conv;
23503 }
23504
23505 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
23506         LDKRouteHint this_obj_conv;
23507         this_obj_conv.inner = (void*)(this_obj & (~1));
23508         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23509         RouteHint_free(this_obj_conv);
23510 }
23511
23512 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
23513         LDKRouteHint orig_conv;
23514         orig_conv.inner = (void*)(orig & (~1));
23515         orig_conv.is_owned = false;
23516         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
23517         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23518         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23519         uint64_t ret_ref = (uint64_t)ret_var.inner;
23520         if (ret_var.is_owned) {
23521                 ret_ref |= 1;
23522         }
23523         return ret_ref;
23524 }
23525
23526 int64_t  __attribute__((visibility("default"))) TS_RouteHint_hash(uint32_t o) {
23527         LDKRouteHint o_conv;
23528         o_conv.inner = (void*)(o & (~1));
23529         o_conv.is_owned = false;
23530         int64_t ret_val = RouteHint_hash(&o_conv);
23531         return ret_val;
23532 }
23533
23534 jboolean  __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
23535         LDKRouteHint a_conv;
23536         a_conv.inner = (void*)(a & (~1));
23537         a_conv.is_owned = false;
23538         LDKRouteHint b_conv;
23539         b_conv.inner = (void*)(b & (~1));
23540         b_conv.is_owned = false;
23541         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
23542         return ret_val;
23543 }
23544
23545 void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
23546         LDKRouteHintHop this_obj_conv;
23547         this_obj_conv.inner = (void*)(this_obj & (~1));
23548         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23549         RouteHintHop_free(this_obj_conv);
23550 }
23551
23552 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
23553         LDKRouteHintHop this_ptr_conv;
23554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23555         this_ptr_conv.is_owned = false;
23556         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23557         memcpy((uint8_t*)(ret_arr + 4), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
23558         return ret_arr;
23559 }
23560
23561 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
23562         LDKRouteHintHop this_ptr_conv;
23563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23564         this_ptr_conv.is_owned = false;
23565         LDKPublicKey val_ref;
23566         CHECK(*((uint32_t*)val) == 33);
23567         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23568         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
23569 }
23570
23571 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
23572         LDKRouteHintHop this_ptr_conv;
23573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23574         this_ptr_conv.is_owned = false;
23575         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
23576         return ret_val;
23577 }
23578
23579 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
23580         LDKRouteHintHop this_ptr_conv;
23581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23582         this_ptr_conv.is_owned = false;
23583         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
23584 }
23585
23586 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
23587         LDKRouteHintHop this_ptr_conv;
23588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23589         this_ptr_conv.is_owned = false;
23590         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
23591         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23592         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23593         uint64_t ret_ref = (uint64_t)ret_var.inner;
23594         if (ret_var.is_owned) {
23595                 ret_ref |= 1;
23596         }
23597         return ret_ref;
23598 }
23599
23600 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
23601         LDKRouteHintHop this_ptr_conv;
23602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23603         this_ptr_conv.is_owned = false;
23604         LDKRoutingFees val_conv;
23605         val_conv.inner = (void*)(val & (~1));
23606         val_conv.is_owned = (val & 1) || (val == 0);
23607         val_conv = RoutingFees_clone(&val_conv);
23608         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
23609 }
23610
23611 int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
23612         LDKRouteHintHop this_ptr_conv;
23613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23614         this_ptr_conv.is_owned = false;
23615         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
23616         return ret_val;
23617 }
23618
23619 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
23620         LDKRouteHintHop this_ptr_conv;
23621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23622         this_ptr_conv.is_owned = false;
23623         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23624 }
23625
23626 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
23627         LDKRouteHintHop this_ptr_conv;
23628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23629         this_ptr_conv.is_owned = false;
23630         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23631         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
23632         uint64_t ret_ref = (uint64_t)ret_copy;
23633         return ret_ref;
23634 }
23635
23636 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
23637         LDKRouteHintHop this_ptr_conv;
23638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23639         this_ptr_conv.is_owned = false;
23640         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23641         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
23642         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
23643 }
23644
23645 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
23646         LDKRouteHintHop this_ptr_conv;
23647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23648         this_ptr_conv.is_owned = false;
23649         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23650         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
23651         uint64_t ret_ref = (uint64_t)ret_copy;
23652         return ret_ref;
23653 }
23654
23655 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
23656         LDKRouteHintHop this_ptr_conv;
23657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23658         this_ptr_conv.is_owned = false;
23659         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23660         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
23661         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
23662 }
23663
23664 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) {
23665         LDKPublicKey src_node_id_arg_ref;
23666         CHECK(*((uint32_t*)src_node_id_arg) == 33);
23667         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
23668         LDKRoutingFees fees_arg_conv;
23669         fees_arg_conv.inner = (void*)(fees_arg & (~1));
23670         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
23671         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
23672         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
23673         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
23674         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
23675         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
23676         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);
23677         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23678         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23679         uint64_t ret_ref = (uint64_t)ret_var.inner;
23680         if (ret_var.is_owned) {
23681                 ret_ref |= 1;
23682         }
23683         return ret_ref;
23684 }
23685
23686 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) {
23687         LDKRouteHintHop orig_conv;
23688         orig_conv.inner = (void*)(orig & (~1));
23689         orig_conv.is_owned = false;
23690         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
23691         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23692         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23693         uint64_t ret_ref = (uint64_t)ret_var.inner;
23694         if (ret_var.is_owned) {
23695                 ret_ref |= 1;
23696         }
23697         return ret_ref;
23698 }
23699
23700 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_hash(uint32_t o) {
23701         LDKRouteHintHop o_conv;
23702         o_conv.inner = (void*)(o & (~1));
23703         o_conv.is_owned = false;
23704         int64_t ret_val = RouteHintHop_hash(&o_conv);
23705         return ret_val;
23706 }
23707
23708 jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
23709         LDKRouteHintHop a_conv;
23710         a_conv.inner = (void*)(a & (~1));
23711         a_conv.is_owned = false;
23712         LDKRouteHintHop b_conv;
23713         b_conv.inner = (void*)(b & (~1));
23714         b_conv.is_owned = false;
23715         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
23716         return ret_val;
23717 }
23718
23719 uint32_t  __attribute__((visibility("default"))) TS_get_keysend_route(int8_tArray our_node_id, uint32_t network, int8_tArray payee, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) {
23720         LDKPublicKey our_node_id_ref;
23721         CHECK(*((uint32_t*)our_node_id) == 33);
23722         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
23723         LDKNetworkGraph network_conv;
23724         network_conv.inner = (void*)(network & (~1));
23725         network_conv.is_owned = false;
23726         LDKPublicKey payee_ref;
23727         CHECK(*((uint32_t*)payee) == 33);
23728         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
23729         LDKCVec_ChannelDetailsZ first_hops_constr;
23730         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
23731         if (first_hops != 0) {
23732                 first_hops_constr.datalen = *((uint32_t*)first_hops);
23733                 if (first_hops_constr.datalen > 0)
23734                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23735                 else
23736                         first_hops_constr.data = NULL;
23737                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
23738                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
23739                         uint32_t first_hops_conv_16 = first_hops_vals[q];
23740                         LDKChannelDetails first_hops_conv_16_conv;
23741                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
23742                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
23743                         first_hops_constr.data[q] = first_hops_conv_16_conv;
23744                 }
23745                 first_hops_ptr = &first_hops_constr;
23746         }
23747         LDKCVec_RouteHintZ last_hops_constr;
23748         last_hops_constr.datalen = *((uint32_t*)last_hops);
23749         if (last_hops_constr.datalen > 0)
23750                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
23751         else
23752                 last_hops_constr.data = NULL;
23753         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
23754         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
23755                 uint32_t last_hops_conv_11 = last_hops_vals[l];
23756                 LDKRouteHint last_hops_conv_11_conv;
23757                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
23758                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
23759                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
23760                 last_hops_constr.data[l] = last_hops_conv_11_conv;
23761         }
23762         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23763         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
23764         *ret_conv = get_keysend_route(our_node_id_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
23765         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
23766         return (uint64_t)ret_conv;
23767 }
23768
23769 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) {
23770         LDKPublicKey our_node_id_ref;
23771         CHECK(*((uint32_t*)our_node_id) == 33);
23772         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
23773         LDKNetworkGraph network_conv;
23774         network_conv.inner = (void*)(network & (~1));
23775         network_conv.is_owned = false;
23776         LDKPublicKey payee_ref;
23777         CHECK(*((uint32_t*)payee) == 33);
23778         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
23779         LDKInvoiceFeatures payee_features_conv;
23780         payee_features_conv.inner = (void*)(payee_features & (~1));
23781         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
23782         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
23783         LDKCVec_ChannelDetailsZ first_hops_constr;
23784         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
23785         if (first_hops != 0) {
23786                 first_hops_constr.datalen = *((uint32_t*)first_hops);
23787                 if (first_hops_constr.datalen > 0)
23788                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23789                 else
23790                         first_hops_constr.data = NULL;
23791                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
23792                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
23793                         uint32_t first_hops_conv_16 = first_hops_vals[q];
23794                         LDKChannelDetails first_hops_conv_16_conv;
23795                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
23796                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
23797                         first_hops_constr.data[q] = first_hops_conv_16_conv;
23798                 }
23799                 first_hops_ptr = &first_hops_constr;
23800         }
23801         LDKCVec_RouteHintZ last_hops_constr;
23802         last_hops_constr.datalen = *((uint32_t*)last_hops);
23803         if (last_hops_constr.datalen > 0)
23804                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
23805         else
23806                 last_hops_constr.data = NULL;
23807         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
23808         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
23809                 uint32_t last_hops_conv_11 = last_hops_vals[l];
23810                 LDKRouteHint last_hops_conv_11_conv;
23811                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
23812                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
23813                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
23814                 last_hops_constr.data[l] = last_hops_conv_11_conv;
23815         }
23816         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23817         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
23818         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
23819         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
23820         return (uint64_t)ret_conv;
23821 }
23822
23823 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
23824         LDKNetworkGraph this_obj_conv;
23825         this_obj_conv.inner = (void*)(this_obj & (~1));
23826         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23827         NetworkGraph_free(this_obj_conv);
23828 }
23829
23830 void  __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
23831         LDKReadOnlyNetworkGraph this_obj_conv;
23832         this_obj_conv.inner = (void*)(this_obj & (~1));
23833         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23834         ReadOnlyNetworkGraph_free(this_obj_conv);
23835 }
23836
23837 void  __attribute__((visibility("default"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
23838         if ((this_ptr & 1) != 0) return;
23839         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(((uint64_t)this_ptr) & ~1);
23840         FREE((void*)this_ptr);
23841         NetworkUpdate_free(this_ptr_conv);
23842 }
23843
23844 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_clone(uint32_t orig) {
23845         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
23846         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
23847         *ret_copy = NetworkUpdate_clone(orig_conv);
23848         uint64_t ret_ref = (uint64_t)ret_copy;
23849         return ret_ref;
23850 }
23851
23852 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
23853         LDKChannelUpdate msg_conv;
23854         msg_conv.inner = (void*)(msg & (~1));
23855         msg_conv.is_owned = (msg & 1) || (msg == 0);
23856         msg_conv = ChannelUpdate_clone(&msg_conv);
23857         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
23858         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
23859         uint64_t ret_ref = (uint64_t)ret_copy;
23860         return ret_ref;
23861 }
23862
23863 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
23864         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
23865         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
23866         uint64_t ret_ref = (uint64_t)ret_copy;
23867         return ret_ref;
23868 }
23869
23870 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
23871         LDKPublicKey node_id_ref;
23872         CHECK(*((uint32_t*)node_id) == 33);
23873         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
23874         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
23875         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
23876         uint64_t ret_ref = (uint64_t)ret_copy;
23877         return ret_ref;
23878 }
23879
23880 int8_tArray  __attribute__((visibility("default"))) TS_NetworkUpdate_write(uint32_t obj) {
23881         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
23882         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
23883         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23884         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23885         CVec_u8Z_free(ret_var);
23886         return ret_arr;
23887 }
23888
23889 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
23890         LDKNetGraphMsgHandler this_arg_conv;
23891         this_arg_conv.inner = (void*)(this_arg & (~1));
23892         this_arg_conv.is_owned = false;
23893         LDKEventHandler* ret_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
23894         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
23895         return (uint64_t)ret_ret;
23896 }
23897
23898 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
23899         LDKNetGraphMsgHandler this_obj_conv;
23900         this_obj_conv.inner = (void*)(this_obj & (~1));
23901         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23902         NetGraphMsgHandler_free(this_obj_conv);
23903 }
23904
23905 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_get_network_graph(uint32_t this_ptr) {
23906         LDKNetGraphMsgHandler this_ptr_conv;
23907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23908         this_ptr_conv.is_owned = false;
23909         LDKNetworkGraph ret_var = NetGraphMsgHandler_get_network_graph(&this_ptr_conv);
23910         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23911         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23912         uint64_t ret_ref = (uint64_t)ret_var.inner;
23913         if (ret_var.is_owned) {
23914                 ret_ref |= 1;
23915         }
23916         return ret_ref;
23917 }
23918
23919 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_set_network_graph(uint32_t this_ptr, uint32_t val) {
23920         LDKNetGraphMsgHandler this_ptr_conv;
23921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23922         this_ptr_conv.is_owned = false;
23923         LDKNetworkGraph val_conv;
23924         val_conv.inner = (void*)(val & (~1));
23925         val_conv.is_owned = (val & 1) || (val == 0);
23926         // Warning: we need a move here but no clone is available for LDKNetworkGraph
23927         NetGraphMsgHandler_set_network_graph(&this_ptr_conv, val_conv);
23928 }
23929
23930 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
23931         LDKNetworkGraph network_graph_conv;
23932         network_graph_conv.inner = (void*)(network_graph & (~1));
23933         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
23934         // Warning: we need a move here but no clone is available for LDKNetworkGraph
23935         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
23936         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
23937         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
23938                 // Manually implement clone for Java trait instances
23939         }
23940         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23941         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(network_graph_conv, chain_access_conv, logger_conv);
23942         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23943         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23944         uint64_t ret_ref = (uint64_t)ret_var.inner;
23945         if (ret_var.is_owned) {
23946                 ret_ref |= 1;
23947         }
23948         return ret_ref;
23949 }
23950
23951 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
23952         LDKNetGraphMsgHandler this_arg_conv;
23953         this_arg_conv.inner = (void*)(this_arg & (~1));
23954         this_arg_conv.is_owned = false;
23955         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
23956         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
23957         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
23958                 // Manually implement clone for Java trait instances
23959         }
23960         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
23961 }
23962
23963 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
23964         LDKNetGraphMsgHandler this_arg_conv;
23965         this_arg_conv.inner = (void*)(this_arg & (~1));
23966         this_arg_conv.is_owned = false;
23967         LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
23968         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
23969         return (uint64_t)ret_ret;
23970 }
23971
23972 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
23973         LDKNetGraphMsgHandler this_arg_conv;
23974         this_arg_conv.inner = (void*)(this_arg & (~1));
23975         this_arg_conv.is_owned = false;
23976         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
23977         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
23978         return (uint64_t)ret_ret;
23979 }
23980
23981 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
23982         LDKDirectionalChannelInfo this_obj_conv;
23983         this_obj_conv.inner = (void*)(this_obj & (~1));
23984         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23985         DirectionalChannelInfo_free(this_obj_conv);
23986 }
23987
23988 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
23989         LDKDirectionalChannelInfo this_ptr_conv;
23990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23991         this_ptr_conv.is_owned = false;
23992         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
23993         return ret_val;
23994 }
23995
23996 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
23997         LDKDirectionalChannelInfo this_ptr_conv;
23998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23999         this_ptr_conv.is_owned = false;
24000         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
24001 }
24002
24003 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
24004         LDKDirectionalChannelInfo this_ptr_conv;
24005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24006         this_ptr_conv.is_owned = false;
24007         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
24008         return ret_val;
24009 }
24010
24011 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
24012         LDKDirectionalChannelInfo this_ptr_conv;
24013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24014         this_ptr_conv.is_owned = false;
24015         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
24016 }
24017
24018 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
24019         LDKDirectionalChannelInfo this_ptr_conv;
24020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24021         this_ptr_conv.is_owned = false;
24022         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
24023         return ret_val;
24024 }
24025
24026 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
24027         LDKDirectionalChannelInfo this_ptr_conv;
24028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24029         this_ptr_conv.is_owned = false;
24030         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24031 }
24032
24033 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
24034         LDKDirectionalChannelInfo this_ptr_conv;
24035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24036         this_ptr_conv.is_owned = false;
24037         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
24038         return ret_val;
24039 }
24040
24041 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
24042         LDKDirectionalChannelInfo this_ptr_conv;
24043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24044         this_ptr_conv.is_owned = false;
24045         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
24046 }
24047
24048 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
24049         LDKDirectionalChannelInfo this_ptr_conv;
24050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24051         this_ptr_conv.is_owned = false;
24052         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24053         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
24054         uint64_t ret_ref = (uint64_t)ret_copy;
24055         return ret_ref;
24056 }
24057
24058 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
24059         LDKDirectionalChannelInfo this_ptr_conv;
24060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24061         this_ptr_conv.is_owned = false;
24062         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24063         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
24064         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
24065 }
24066
24067 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
24068         LDKDirectionalChannelInfo this_ptr_conv;
24069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24070         this_ptr_conv.is_owned = false;
24071         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
24072         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24073         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24074         uint64_t ret_ref = (uint64_t)ret_var.inner;
24075         if (ret_var.is_owned) {
24076                 ret_ref |= 1;
24077         }
24078         return ret_ref;
24079 }
24080
24081 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
24082         LDKDirectionalChannelInfo this_ptr_conv;
24083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24084         this_ptr_conv.is_owned = false;
24085         LDKRoutingFees val_conv;
24086         val_conv.inner = (void*)(val & (~1));
24087         val_conv.is_owned = (val & 1) || (val == 0);
24088         val_conv = RoutingFees_clone(&val_conv);
24089         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
24090 }
24091
24092 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
24093         LDKDirectionalChannelInfo this_ptr_conv;
24094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24095         this_ptr_conv.is_owned = false;
24096         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
24097         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24098         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24099         uint64_t ret_ref = (uint64_t)ret_var.inner;
24100         if (ret_var.is_owned) {
24101                 ret_ref |= 1;
24102         }
24103         return ret_ref;
24104 }
24105
24106 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
24107         LDKDirectionalChannelInfo this_ptr_conv;
24108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24109         this_ptr_conv.is_owned = false;
24110         LDKChannelUpdate val_conv;
24111         val_conv.inner = (void*)(val & (~1));
24112         val_conv.is_owned = (val & 1) || (val == 0);
24113         val_conv = ChannelUpdate_clone(&val_conv);
24114         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
24115 }
24116
24117 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) {
24118         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
24119         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
24120         LDKRoutingFees fees_arg_conv;
24121         fees_arg_conv.inner = (void*)(fees_arg & (~1));
24122         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
24123         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
24124         LDKChannelUpdate last_update_message_arg_conv;
24125         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
24126         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
24127         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
24128         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);
24129         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24130         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24131         uint64_t ret_ref = (uint64_t)ret_var.inner;
24132         if (ret_var.is_owned) {
24133                 ret_ref |= 1;
24134         }
24135         return ret_ref;
24136 }
24137
24138 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
24139         LDKDirectionalChannelInfo orig_conv;
24140         orig_conv.inner = (void*)(orig & (~1));
24141         orig_conv.is_owned = false;
24142         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
24143         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24144         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24145         uint64_t ret_ref = (uint64_t)ret_var.inner;
24146         if (ret_var.is_owned) {
24147                 ret_ref |= 1;
24148         }
24149         return ret_ref;
24150 }
24151
24152 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
24153         LDKDirectionalChannelInfo obj_conv;
24154         obj_conv.inner = (void*)(obj & (~1));
24155         obj_conv.is_owned = false;
24156         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
24157         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24158         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24159         CVec_u8Z_free(ret_var);
24160         return ret_arr;
24161 }
24162
24163 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
24164         LDKu8slice ser_ref;
24165         ser_ref.datalen = *((uint32_t*)ser);
24166         ser_ref.data = (int8_t*)(ser + 4);
24167         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
24168         *ret_conv = DirectionalChannelInfo_read(ser_ref);
24169         return (uint64_t)ret_conv;
24170 }
24171
24172 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
24173         LDKChannelInfo this_obj_conv;
24174         this_obj_conv.inner = (void*)(this_obj & (~1));
24175         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24176         ChannelInfo_free(this_obj_conv);
24177 }
24178
24179 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
24180         LDKChannelInfo this_ptr_conv;
24181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24182         this_ptr_conv.is_owned = false;
24183         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
24184         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24185         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24186         uint64_t ret_ref = (uint64_t)ret_var.inner;
24187         if (ret_var.is_owned) {
24188                 ret_ref |= 1;
24189         }
24190         return ret_ref;
24191 }
24192
24193 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
24194         LDKChannelInfo this_ptr_conv;
24195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24196         this_ptr_conv.is_owned = false;
24197         LDKChannelFeatures val_conv;
24198         val_conv.inner = (void*)(val & (~1));
24199         val_conv.is_owned = (val & 1) || (val == 0);
24200         val_conv = ChannelFeatures_clone(&val_conv);
24201         ChannelInfo_set_features(&this_ptr_conv, val_conv);
24202 }
24203
24204 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
24205         LDKChannelInfo this_ptr_conv;
24206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24207         this_ptr_conv.is_owned = false;
24208         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24209         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
24210         return ret_arr;
24211 }
24212
24213 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
24214         LDKChannelInfo this_ptr_conv;
24215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24216         this_ptr_conv.is_owned = false;
24217         LDKPublicKey val_ref;
24218         CHECK(*((uint32_t*)val) == 33);
24219         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
24220         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
24221 }
24222
24223 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
24224         LDKChannelInfo this_ptr_conv;
24225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24226         this_ptr_conv.is_owned = false;
24227         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
24228         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24229         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24230         uint64_t ret_ref = (uint64_t)ret_var.inner;
24231         if (ret_var.is_owned) {
24232                 ret_ref |= 1;
24233         }
24234         return ret_ref;
24235 }
24236
24237 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
24238         LDKChannelInfo this_ptr_conv;
24239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24240         this_ptr_conv.is_owned = false;
24241         LDKDirectionalChannelInfo val_conv;
24242         val_conv.inner = (void*)(val & (~1));
24243         val_conv.is_owned = (val & 1) || (val == 0);
24244         val_conv = DirectionalChannelInfo_clone(&val_conv);
24245         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
24246 }
24247
24248 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
24249         LDKChannelInfo this_ptr_conv;
24250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24251         this_ptr_conv.is_owned = false;
24252         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24253         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
24254         return ret_arr;
24255 }
24256
24257 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
24258         LDKChannelInfo this_ptr_conv;
24259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24260         this_ptr_conv.is_owned = false;
24261         LDKPublicKey val_ref;
24262         CHECK(*((uint32_t*)val) == 33);
24263         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
24264         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
24265 }
24266
24267 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
24268         LDKChannelInfo this_ptr_conv;
24269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24270         this_ptr_conv.is_owned = false;
24271         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
24272         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24273         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24274         uint64_t ret_ref = (uint64_t)ret_var.inner;
24275         if (ret_var.is_owned) {
24276                 ret_ref |= 1;
24277         }
24278         return ret_ref;
24279 }
24280
24281 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
24282         LDKChannelInfo this_ptr_conv;
24283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24284         this_ptr_conv.is_owned = false;
24285         LDKDirectionalChannelInfo val_conv;
24286         val_conv.inner = (void*)(val & (~1));
24287         val_conv.is_owned = (val & 1) || (val == 0);
24288         val_conv = DirectionalChannelInfo_clone(&val_conv);
24289         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
24290 }
24291
24292 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
24293         LDKChannelInfo this_ptr_conv;
24294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24295         this_ptr_conv.is_owned = false;
24296         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24297         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
24298         uint64_t ret_ref = (uint64_t)ret_copy;
24299         return ret_ref;
24300 }
24301
24302 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
24303         LDKChannelInfo this_ptr_conv;
24304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24305         this_ptr_conv.is_owned = false;
24306         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24307         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
24308         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
24309 }
24310
24311 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
24312         LDKChannelInfo this_ptr_conv;
24313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24314         this_ptr_conv.is_owned = false;
24315         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
24316         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24317         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24318         uint64_t ret_ref = (uint64_t)ret_var.inner;
24319         if (ret_var.is_owned) {
24320                 ret_ref |= 1;
24321         }
24322         return ret_ref;
24323 }
24324
24325 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
24326         LDKChannelInfo this_ptr_conv;
24327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24328         this_ptr_conv.is_owned = false;
24329         LDKChannelAnnouncement val_conv;
24330         val_conv.inner = (void*)(val & (~1));
24331         val_conv.is_owned = (val & 1) || (val == 0);
24332         val_conv = ChannelAnnouncement_clone(&val_conv);
24333         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
24334 }
24335
24336 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) {
24337         LDKChannelFeatures features_arg_conv;
24338         features_arg_conv.inner = (void*)(features_arg & (~1));
24339         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24340         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
24341         LDKPublicKey node_one_arg_ref;
24342         CHECK(*((uint32_t*)node_one_arg) == 33);
24343         memcpy(node_one_arg_ref.compressed_form, (uint8_t*)(node_one_arg + 4), 33);
24344         LDKDirectionalChannelInfo one_to_two_arg_conv;
24345         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
24346         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
24347         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
24348         LDKPublicKey node_two_arg_ref;
24349         CHECK(*((uint32_t*)node_two_arg) == 33);
24350         memcpy(node_two_arg_ref.compressed_form, (uint8_t*)(node_two_arg + 4), 33);
24351         LDKDirectionalChannelInfo two_to_one_arg_conv;
24352         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
24353         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
24354         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
24355         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
24356         capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1));
24357         LDKChannelAnnouncement announcement_message_arg_conv;
24358         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24359         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24360         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
24361         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);
24362         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24363         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24364         uint64_t ret_ref = (uint64_t)ret_var.inner;
24365         if (ret_var.is_owned) {
24366                 ret_ref |= 1;
24367         }
24368         return ret_ref;
24369 }
24370
24371 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
24372         LDKChannelInfo orig_conv;
24373         orig_conv.inner = (void*)(orig & (~1));
24374         orig_conv.is_owned = false;
24375         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
24376         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24377         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24378         uint64_t ret_ref = (uint64_t)ret_var.inner;
24379         if (ret_var.is_owned) {
24380                 ret_ref |= 1;
24381         }
24382         return ret_ref;
24383 }
24384
24385 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
24386         LDKChannelInfo obj_conv;
24387         obj_conv.inner = (void*)(obj & (~1));
24388         obj_conv.is_owned = false;
24389         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
24390         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24391         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24392         CVec_u8Z_free(ret_var);
24393         return ret_arr;
24394 }
24395
24396 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
24397         LDKu8slice ser_ref;
24398         ser_ref.datalen = *((uint32_t*)ser);
24399         ser_ref.data = (int8_t*)(ser + 4);
24400         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
24401         *ret_conv = ChannelInfo_read(ser_ref);
24402         return (uint64_t)ret_conv;
24403 }
24404
24405 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
24406         LDKRoutingFees this_obj_conv;
24407         this_obj_conv.inner = (void*)(this_obj & (~1));
24408         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24409         RoutingFees_free(this_obj_conv);
24410 }
24411
24412 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
24413         LDKRoutingFees this_ptr_conv;
24414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24415         this_ptr_conv.is_owned = false;
24416         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
24417         return ret_val;
24418 }
24419
24420 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
24421         LDKRoutingFees this_ptr_conv;
24422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24423         this_ptr_conv.is_owned = false;
24424         RoutingFees_set_base_msat(&this_ptr_conv, val);
24425 }
24426
24427 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
24428         LDKRoutingFees this_ptr_conv;
24429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24430         this_ptr_conv.is_owned = false;
24431         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
24432         return ret_val;
24433 }
24434
24435 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
24436         LDKRoutingFees this_ptr_conv;
24437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24438         this_ptr_conv.is_owned = false;
24439         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
24440 }
24441
24442 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
24443         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
24444         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24445         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24446         uint64_t ret_ref = (uint64_t)ret_var.inner;
24447         if (ret_var.is_owned) {
24448                 ret_ref |= 1;
24449         }
24450         return ret_ref;
24451 }
24452
24453 jboolean  __attribute__((visibility("default"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
24454         LDKRoutingFees a_conv;
24455         a_conv.inner = (void*)(a & (~1));
24456         a_conv.is_owned = false;
24457         LDKRoutingFees b_conv;
24458         b_conv.inner = (void*)(b & (~1));
24459         b_conv.is_owned = false;
24460         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
24461         return ret_val;
24462 }
24463
24464 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
24465         LDKRoutingFees orig_conv;
24466         orig_conv.inner = (void*)(orig & (~1));
24467         orig_conv.is_owned = false;
24468         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
24469         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24470         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24471         uint64_t ret_ref = (uint64_t)ret_var.inner;
24472         if (ret_var.is_owned) {
24473                 ret_ref |= 1;
24474         }
24475         return ret_ref;
24476 }
24477
24478 int64_t  __attribute__((visibility("default"))) TS_RoutingFees_hash(uint32_t o) {
24479         LDKRoutingFees o_conv;
24480         o_conv.inner = (void*)(o & (~1));
24481         o_conv.is_owned = false;
24482         int64_t ret_val = RoutingFees_hash(&o_conv);
24483         return ret_val;
24484 }
24485
24486 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
24487         LDKRoutingFees obj_conv;
24488         obj_conv.inner = (void*)(obj & (~1));
24489         obj_conv.is_owned = false;
24490         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
24491         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24492         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24493         CVec_u8Z_free(ret_var);
24494         return ret_arr;
24495 }
24496
24497 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
24498         LDKu8slice ser_ref;
24499         ser_ref.datalen = *((uint32_t*)ser);
24500         ser_ref.data = (int8_t*)(ser + 4);
24501         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
24502         *ret_conv = RoutingFees_read(ser_ref);
24503         return (uint64_t)ret_conv;
24504 }
24505
24506 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
24507         LDKNodeAnnouncementInfo this_obj_conv;
24508         this_obj_conv.inner = (void*)(this_obj & (~1));
24509         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24510         NodeAnnouncementInfo_free(this_obj_conv);
24511 }
24512
24513 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
24514         LDKNodeAnnouncementInfo this_ptr_conv;
24515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24516         this_ptr_conv.is_owned = false;
24517         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
24518         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24519         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24520         uint64_t ret_ref = (uint64_t)ret_var.inner;
24521         if (ret_var.is_owned) {
24522                 ret_ref |= 1;
24523         }
24524         return ret_ref;
24525 }
24526
24527 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
24528         LDKNodeAnnouncementInfo this_ptr_conv;
24529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24530         this_ptr_conv.is_owned = false;
24531         LDKNodeFeatures val_conv;
24532         val_conv.inner = (void*)(val & (~1));
24533         val_conv.is_owned = (val & 1) || (val == 0);
24534         val_conv = NodeFeatures_clone(&val_conv);
24535         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
24536 }
24537
24538 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
24539         LDKNodeAnnouncementInfo this_ptr_conv;
24540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24541         this_ptr_conv.is_owned = false;
24542         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
24543         return ret_val;
24544 }
24545
24546 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
24547         LDKNodeAnnouncementInfo this_ptr_conv;
24548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24549         this_ptr_conv.is_owned = false;
24550         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
24551 }
24552
24553 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
24554         LDKNodeAnnouncementInfo this_ptr_conv;
24555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24556         this_ptr_conv.is_owned = false;
24557         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
24558         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
24559         return ret_arr;
24560 }
24561
24562 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
24563         LDKNodeAnnouncementInfo this_ptr_conv;
24564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24565         this_ptr_conv.is_owned = false;
24566         LDKThreeBytes val_ref;
24567         CHECK(*((uint32_t*)val) == 3);
24568         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
24569         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
24570 }
24571
24572 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
24573         LDKNodeAnnouncementInfo this_ptr_conv;
24574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24575         this_ptr_conv.is_owned = false;
24576         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24577         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
24578         return ret_arr;
24579 }
24580
24581 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
24582         LDKNodeAnnouncementInfo this_ptr_conv;
24583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24584         this_ptr_conv.is_owned = false;
24585         LDKThirtyTwoBytes val_ref;
24586         CHECK(*((uint32_t*)val) == 32);
24587         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24588         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
24589 }
24590
24591 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
24592         LDKNodeAnnouncementInfo this_ptr_conv;
24593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24594         this_ptr_conv.is_owned = false;
24595         LDKCVec_NetAddressZ val_constr;
24596         val_constr.datalen = *((uint32_t*)val);
24597         if (val_constr.datalen > 0)
24598                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24599         else
24600                 val_constr.data = NULL;
24601         uint32_t* val_vals = (uint32_t*)(val + 4);
24602         for (size_t m = 0; m < val_constr.datalen; m++) {
24603                 uint32_t val_conv_12 = val_vals[m];
24604                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
24605                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
24606                 val_constr.data[m] = val_conv_12_conv;
24607         }
24608         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
24609 }
24610
24611 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
24612         LDKNodeAnnouncementInfo this_ptr_conv;
24613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24614         this_ptr_conv.is_owned = false;
24615         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
24616         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24617         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24618         uint64_t ret_ref = (uint64_t)ret_var.inner;
24619         if (ret_var.is_owned) {
24620                 ret_ref |= 1;
24621         }
24622         return ret_ref;
24623 }
24624
24625 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
24626         LDKNodeAnnouncementInfo this_ptr_conv;
24627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24628         this_ptr_conv.is_owned = false;
24629         LDKNodeAnnouncement val_conv;
24630         val_conv.inner = (void*)(val & (~1));
24631         val_conv.is_owned = (val & 1) || (val == 0);
24632         val_conv = NodeAnnouncement_clone(&val_conv);
24633         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
24634 }
24635
24636 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) {
24637         LDKNodeFeatures features_arg_conv;
24638         features_arg_conv.inner = (void*)(features_arg & (~1));
24639         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24640         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
24641         LDKThreeBytes rgb_arg_ref;
24642         CHECK(*((uint32_t*)rgb_arg) == 3);
24643         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
24644         LDKThirtyTwoBytes alias_arg_ref;
24645         CHECK(*((uint32_t*)alias_arg) == 32);
24646         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
24647         LDKCVec_NetAddressZ addresses_arg_constr;
24648         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
24649         if (addresses_arg_constr.datalen > 0)
24650                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24651         else
24652                 addresses_arg_constr.data = NULL;
24653         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
24654         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
24655                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
24656                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
24657                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
24658         }
24659         LDKNodeAnnouncement announcement_message_arg_conv;
24660         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24661         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24662         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
24663         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
24664         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24665         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24666         uint64_t ret_ref = (uint64_t)ret_var.inner;
24667         if (ret_var.is_owned) {
24668                 ret_ref |= 1;
24669         }
24670         return ret_ref;
24671 }
24672
24673 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
24674         LDKNodeAnnouncementInfo orig_conv;
24675         orig_conv.inner = (void*)(orig & (~1));
24676         orig_conv.is_owned = false;
24677         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
24678         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24679         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24680         uint64_t ret_ref = (uint64_t)ret_var.inner;
24681         if (ret_var.is_owned) {
24682                 ret_ref |= 1;
24683         }
24684         return ret_ref;
24685 }
24686
24687 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
24688         LDKNodeAnnouncementInfo obj_conv;
24689         obj_conv.inner = (void*)(obj & (~1));
24690         obj_conv.is_owned = false;
24691         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
24692         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24693         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24694         CVec_u8Z_free(ret_var);
24695         return ret_arr;
24696 }
24697
24698 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
24699         LDKu8slice ser_ref;
24700         ser_ref.datalen = *((uint32_t*)ser);
24701         ser_ref.data = (int8_t*)(ser + 4);
24702         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
24703         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
24704         return (uint64_t)ret_conv;
24705 }
24706
24707 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
24708         LDKNodeInfo this_obj_conv;
24709         this_obj_conv.inner = (void*)(this_obj & (~1));
24710         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24711         NodeInfo_free(this_obj_conv);
24712 }
24713
24714 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
24715         LDKNodeInfo this_ptr_conv;
24716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24717         this_ptr_conv.is_owned = false;
24718         LDKCVec_u64Z val_constr;
24719         val_constr.datalen = *((uint32_t*)val);
24720         if (val_constr.datalen > 0)
24721                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24722         else
24723                 val_constr.data = NULL;
24724         int64_t* val_vals = (int64_t*)(val + 4);
24725         for (size_t i = 0; i < val_constr.datalen; i++) {
24726                 int64_t val_conv_8 = val_vals[i];
24727                 val_constr.data[i] = val_conv_8;
24728         }
24729         NodeInfo_set_channels(&this_ptr_conv, val_constr);
24730 }
24731
24732 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
24733         LDKNodeInfo this_ptr_conv;
24734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24735         this_ptr_conv.is_owned = false;
24736         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
24737         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24738         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24739         uint64_t ret_ref = (uint64_t)ret_var.inner;
24740         if (ret_var.is_owned) {
24741                 ret_ref |= 1;
24742         }
24743         return ret_ref;
24744 }
24745
24746 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
24747         LDKNodeInfo this_ptr_conv;
24748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24749         this_ptr_conv.is_owned = false;
24750         LDKRoutingFees val_conv;
24751         val_conv.inner = (void*)(val & (~1));
24752         val_conv.is_owned = (val & 1) || (val == 0);
24753         val_conv = RoutingFees_clone(&val_conv);
24754         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
24755 }
24756
24757 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
24758         LDKNodeInfo this_ptr_conv;
24759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24760         this_ptr_conv.is_owned = false;
24761         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
24762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24764         uint64_t ret_ref = (uint64_t)ret_var.inner;
24765         if (ret_var.is_owned) {
24766                 ret_ref |= 1;
24767         }
24768         return ret_ref;
24769 }
24770
24771 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
24772         LDKNodeInfo this_ptr_conv;
24773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24774         this_ptr_conv.is_owned = false;
24775         LDKNodeAnnouncementInfo val_conv;
24776         val_conv.inner = (void*)(val & (~1));
24777         val_conv.is_owned = (val & 1) || (val == 0);
24778         val_conv = NodeAnnouncementInfo_clone(&val_conv);
24779         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
24780 }
24781
24782 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
24783         LDKCVec_u64Z channels_arg_constr;
24784         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
24785         if (channels_arg_constr.datalen > 0)
24786                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24787         else
24788                 channels_arg_constr.data = NULL;
24789         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
24790         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
24791                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
24792                 channels_arg_constr.data[i] = channels_arg_conv_8;
24793         }
24794         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
24795         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
24796         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
24797         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
24798         LDKNodeAnnouncementInfo announcement_info_arg_conv;
24799         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
24800         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
24801         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
24802         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
24803         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24804         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24805         uint64_t ret_ref = (uint64_t)ret_var.inner;
24806         if (ret_var.is_owned) {
24807                 ret_ref |= 1;
24808         }
24809         return ret_ref;
24810 }
24811
24812 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
24813         LDKNodeInfo orig_conv;
24814         orig_conv.inner = (void*)(orig & (~1));
24815         orig_conv.is_owned = false;
24816         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
24817         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24818         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24819         uint64_t ret_ref = (uint64_t)ret_var.inner;
24820         if (ret_var.is_owned) {
24821                 ret_ref |= 1;
24822         }
24823         return ret_ref;
24824 }
24825
24826 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
24827         LDKNodeInfo obj_conv;
24828         obj_conv.inner = (void*)(obj & (~1));
24829         obj_conv.is_owned = false;
24830         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
24831         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24832         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24833         CVec_u8Z_free(ret_var);
24834         return ret_arr;
24835 }
24836
24837 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
24838         LDKu8slice ser_ref;
24839         ser_ref.datalen = *((uint32_t*)ser);
24840         ser_ref.data = (int8_t*)(ser + 4);
24841         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
24842         *ret_conv = NodeInfo_read(ser_ref);
24843         return (uint64_t)ret_conv;
24844 }
24845
24846 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
24847         LDKNetworkGraph obj_conv;
24848         obj_conv.inner = (void*)(obj & (~1));
24849         obj_conv.is_owned = false;
24850         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
24851         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24852         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24853         CVec_u8Z_free(ret_var);
24854         return ret_arr;
24855 }
24856
24857 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
24858         LDKu8slice ser_ref;
24859         ser_ref.datalen = *((uint32_t*)ser);
24860         ser_ref.data = (int8_t*)(ser + 4);
24861         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
24862         *ret_conv = NetworkGraph_read(ser_ref);
24863         return (uint64_t)ret_conv;
24864 }
24865
24866 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
24867         LDKThirtyTwoBytes genesis_hash_ref;
24868         CHECK(*((uint32_t*)genesis_hash) == 32);
24869         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
24870         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
24871         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24872         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24873         uint64_t ret_ref = (uint64_t)ret_var.inner;
24874         if (ret_var.is_owned) {
24875                 ret_ref |= 1;
24876         }
24877         return ret_ref;
24878 }
24879
24880 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
24881         LDKNetworkGraph this_arg_conv;
24882         this_arg_conv.inner = (void*)(this_arg & (~1));
24883         this_arg_conv.is_owned = false;
24884         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
24885         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24886         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24887         uint64_t ret_ref = (uint64_t)ret_var.inner;
24888         if (ret_var.is_owned) {
24889                 ret_ref |= 1;
24890         }
24891         return ret_ref;
24892 }
24893
24894 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
24895         LDKNetworkGraph this_arg_conv;
24896         this_arg_conv.inner = (void*)(this_arg & (~1));
24897         this_arg_conv.is_owned = false;
24898         LDKNodeAnnouncement msg_conv;
24899         msg_conv.inner = (void*)(msg & (~1));
24900         msg_conv.is_owned = false;
24901         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24902         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
24903         return (uint64_t)ret_conv;
24904 }
24905
24906 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
24907         LDKNetworkGraph this_arg_conv;
24908         this_arg_conv.inner = (void*)(this_arg & (~1));
24909         this_arg_conv.is_owned = false;
24910         LDKUnsignedNodeAnnouncement msg_conv;
24911         msg_conv.inner = (void*)(msg & (~1));
24912         msg_conv.is_owned = false;
24913         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24914         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
24915         return (uint64_t)ret_conv;
24916 }
24917
24918 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
24919         LDKNetworkGraph this_arg_conv;
24920         this_arg_conv.inner = (void*)(this_arg & (~1));
24921         this_arg_conv.is_owned = false;
24922         LDKChannelAnnouncement msg_conv;
24923         msg_conv.inner = (void*)(msg & (~1));
24924         msg_conv.is_owned = false;
24925         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
24926         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
24927         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
24928                 // Manually implement clone for Java trait instances
24929         }
24930         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24931         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
24932         return (uint64_t)ret_conv;
24933 }
24934
24935 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
24936         LDKNetworkGraph this_arg_conv;
24937         this_arg_conv.inner = (void*)(this_arg & (~1));
24938         this_arg_conv.is_owned = false;
24939         LDKUnsignedChannelAnnouncement msg_conv;
24940         msg_conv.inner = (void*)(msg & (~1));
24941         msg_conv.is_owned = false;
24942         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
24943         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
24944         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
24945                 // Manually implement clone for Java trait instances
24946         }
24947         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24948         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
24949         return (uint64_t)ret_conv;
24950 }
24951
24952 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
24953         LDKNetworkGraph this_arg_conv;
24954         this_arg_conv.inner = (void*)(this_arg & (~1));
24955         this_arg_conv.is_owned = false;
24956         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
24957 }
24958
24959 void  __attribute__((visibility("default"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
24960         LDKNetworkGraph this_arg_conv;
24961         this_arg_conv.inner = (void*)(this_arg & (~1));
24962         this_arg_conv.is_owned = false;
24963         LDKPublicKey _node_id_ref;
24964         CHECK(*((uint32_t*)_node_id) == 33);
24965         memcpy(_node_id_ref.compressed_form, (uint8_t*)(_node_id + 4), 33);
24966         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
24967 }
24968
24969 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
24970         LDKNetworkGraph this_arg_conv;
24971         this_arg_conv.inner = (void*)(this_arg & (~1));
24972         this_arg_conv.is_owned = false;
24973         LDKChannelUpdate msg_conv;
24974         msg_conv.inner = (void*)(msg & (~1));
24975         msg_conv.is_owned = false;
24976         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24977         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
24978         return (uint64_t)ret_conv;
24979 }
24980
24981 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
24982         LDKNetworkGraph this_arg_conv;
24983         this_arg_conv.inner = (void*)(this_arg & (~1));
24984         this_arg_conv.is_owned = false;
24985         LDKUnsignedChannelUpdate msg_conv;
24986         msg_conv.inner = (void*)(msg & (~1));
24987         msg_conv.is_owned = false;
24988         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
24989         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
24990         return (uint64_t)ret_conv;
24991 }
24992
24993 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
24994         LDKFilesystemPersister this_obj_conv;
24995         this_obj_conv.inner = (void*)(this_obj & (~1));
24996         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24997         FilesystemPersister_free(this_obj_conv);
24998 }
24999
25000 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
25001         LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
25002         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
25003         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25004         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25005         uint64_t ret_ref = (uint64_t)ret_var.inner;
25006         if (ret_var.is_owned) {
25007                 ret_ref |= 1;
25008         }
25009         return ret_ref;
25010 }
25011
25012 jstring  __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_dir(uint32_t this_arg) {
25013         LDKFilesystemPersister this_arg_conv;
25014         this_arg_conv.inner = (void*)(this_arg & (~1));
25015         this_arg_conv.is_owned = false;
25016         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
25017         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
25018         Str_free(ret_str);
25019         return ret_conv;
25020 }
25021
25022 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_persist_manager(jstring data_dir, uint32_t manager) {
25023         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
25024         LDKChannelManager manager_conv;
25025         manager_conv.inner = (void*)(manager & (~1));
25026         manager_conv.is_owned = false;
25027         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25028         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
25029         return (uint64_t)ret_conv;
25030 }
25031
25032 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_channelmonitors(uint32_t this_arg, uint32_t keys_manager) {
25033         LDKFilesystemPersister this_arg_conv;
25034         this_arg_conv.inner = (void*)(this_arg & (~1));
25035         this_arg_conv.is_owned = false;
25036         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
25037         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
25038         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
25039         return (uint64_t)ret_conv;
25040 }
25041
25042 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persist(uint32_t this_arg) {
25043         LDKFilesystemPersister this_arg_conv;
25044         this_arg_conv.inner = (void*)(this_arg & (~1));
25045         this_arg_conv.is_owned = false;
25046         LDKPersist* ret_ret =MALLOC(sizeof(LDKPersist), "LDKPersist");
25047         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
25048         return (uint64_t)ret_ret;
25049 }
25050
25051 void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) {
25052         LDKBackgroundProcessor this_obj_conv;
25053         this_obj_conv.inner = (void*)(this_obj & (~1));
25054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25055         BackgroundProcessor_free(this_obj_conv);
25056 }
25057
25058 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
25059         if ((this_ptr & 1) != 0) return;
25060         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
25061         FREE((void*)this_ptr);
25062         ChannelManagerPersister_free(this_ptr_conv);
25063 }
25064
25065 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 net_graph_msg_handler, uint32_t peer_manager, uint32_t logger) {
25066         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
25067         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
25068         LDKChainMonitor chain_monitor_conv;
25069         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
25070         chain_monitor_conv.is_owned = false;
25071         LDKChannelManager channel_manager_conv;
25072         channel_manager_conv.inner = (void*)(channel_manager & (~1));
25073         channel_manager_conv.is_owned = false;
25074         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
25075         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
25076         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
25077         LDKPeerManager peer_manager_conv;
25078         peer_manager_conv.inner = (void*)(peer_manager & (~1));
25079         peer_manager_conv.is_owned = false;
25080         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25081         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv);
25082         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25083         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25084         uint64_t ret_ref = (uint64_t)ret_var.inner;
25085         if (ret_var.is_owned) {
25086                 ret_ref |= 1;
25087         }
25088         return ret_ref;
25089 }
25090
25091 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_join(uint32_t this_arg) {
25092         LDKBackgroundProcessor this_arg_conv;
25093         this_arg_conv.inner = (void*)(this_arg & (~1));
25094         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25095         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
25096         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25097         *ret_conv = BackgroundProcessor_join(this_arg_conv);
25098         return (uint64_t)ret_conv;
25099 }
25100
25101 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_stop(uint32_t this_arg) {
25102         LDKBackgroundProcessor this_arg_conv;
25103         this_arg_conv.inner = (void*)(this_arg & (~1));
25104         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25105         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
25106         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25107         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
25108         return (uint64_t)ret_conv;
25109 }
25110
25111 void  __attribute__((visibility("default"))) TS_check_platform() {
25112         check_platform();
25113 }
25114
25115 void  __attribute__((visibility("default"))) TS_Invoice_free(uint32_t this_obj) {
25116         LDKInvoice this_obj_conv;
25117         this_obj_conv.inner = (void*)(this_obj & (~1));
25118         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25119         Invoice_free(this_obj_conv);
25120 }
25121
25122 jboolean  __attribute__((visibility("default"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
25123         LDKInvoice a_conv;
25124         a_conv.inner = (void*)(a & (~1));
25125         a_conv.is_owned = false;
25126         LDKInvoice b_conv;
25127         b_conv.inner = (void*)(b & (~1));
25128         b_conv.is_owned = false;
25129         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
25130         return ret_val;
25131 }
25132
25133 uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig) {
25134         LDKInvoice orig_conv;
25135         orig_conv.inner = (void*)(orig & (~1));
25136         orig_conv.is_owned = false;
25137         LDKInvoice ret_var = Invoice_clone(&orig_conv);
25138         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25139         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25140         uint64_t ret_ref = (uint64_t)ret_var.inner;
25141         if (ret_var.is_owned) {
25142                 ret_ref |= 1;
25143         }
25144         return ret_ref;
25145 }
25146
25147 void  __attribute__((visibility("default"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
25148         LDKSignedRawInvoice this_obj_conv;
25149         this_obj_conv.inner = (void*)(this_obj & (~1));
25150         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25151         SignedRawInvoice_free(this_obj_conv);
25152 }
25153
25154 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
25155         LDKSignedRawInvoice a_conv;
25156         a_conv.inner = (void*)(a & (~1));
25157         a_conv.is_owned = false;
25158         LDKSignedRawInvoice b_conv;
25159         b_conv.inner = (void*)(b & (~1));
25160         b_conv.is_owned = false;
25161         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
25162         return ret_val;
25163 }
25164
25165 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint32_t orig) {
25166         LDKSignedRawInvoice orig_conv;
25167         orig_conv.inner = (void*)(orig & (~1));
25168         orig_conv.is_owned = false;
25169         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
25170         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25171         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25172         uint64_t ret_ref = (uint64_t)ret_var.inner;
25173         if (ret_var.is_owned) {
25174                 ret_ref |= 1;
25175         }
25176         return ret_ref;
25177 }
25178
25179 void  __attribute__((visibility("default"))) TS_RawInvoice_free(uint32_t this_obj) {
25180         LDKRawInvoice this_obj_conv;
25181         this_obj_conv.inner = (void*)(this_obj & (~1));
25182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25183         RawInvoice_free(this_obj_conv);
25184 }
25185
25186 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
25187         LDKRawInvoice this_ptr_conv;
25188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25189         this_ptr_conv.is_owned = false;
25190         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
25191         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25192         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25193         uint64_t ret_ref = (uint64_t)ret_var.inner;
25194         if (ret_var.is_owned) {
25195                 ret_ref |= 1;
25196         }
25197         return ret_ref;
25198 }
25199
25200 void  __attribute__((visibility("default"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
25201         LDKRawInvoice this_ptr_conv;
25202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25203         this_ptr_conv.is_owned = false;
25204         LDKRawDataPart val_conv;
25205         val_conv.inner = (void*)(val & (~1));
25206         val_conv.is_owned = (val & 1) || (val == 0);
25207         val_conv = RawDataPart_clone(&val_conv);
25208         RawInvoice_set_data(&this_ptr_conv, val_conv);
25209 }
25210
25211 jboolean  __attribute__((visibility("default"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
25212         LDKRawInvoice a_conv;
25213         a_conv.inner = (void*)(a & (~1));
25214         a_conv.is_owned = false;
25215         LDKRawInvoice b_conv;
25216         b_conv.inner = (void*)(b & (~1));
25217         b_conv.is_owned = false;
25218         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
25219         return ret_val;
25220 }
25221
25222 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t orig) {
25223         LDKRawInvoice orig_conv;
25224         orig_conv.inner = (void*)(orig & (~1));
25225         orig_conv.is_owned = false;
25226         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
25227         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25228         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25229         uint64_t ret_ref = (uint64_t)ret_var.inner;
25230         if (ret_var.is_owned) {
25231                 ret_ref |= 1;
25232         }
25233         return ret_ref;
25234 }
25235
25236 void  __attribute__((visibility("default"))) TS_RawDataPart_free(uint32_t this_obj) {
25237         LDKRawDataPart this_obj_conv;
25238         this_obj_conv.inner = (void*)(this_obj & (~1));
25239         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25240         RawDataPart_free(this_obj_conv);
25241 }
25242
25243 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
25244         LDKRawDataPart this_ptr_conv;
25245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25246         this_ptr_conv.is_owned = false;
25247         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
25248         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25249         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25250         uint64_t ret_ref = (uint64_t)ret_var.inner;
25251         if (ret_var.is_owned) {
25252                 ret_ref |= 1;
25253         }
25254         return ret_ref;
25255 }
25256
25257 void  __attribute__((visibility("default"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
25258         LDKRawDataPart this_ptr_conv;
25259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25260         this_ptr_conv.is_owned = false;
25261         LDKPositiveTimestamp val_conv;
25262         val_conv.inner = (void*)(val & (~1));
25263         val_conv.is_owned = (val & 1) || (val == 0);
25264         val_conv = PositiveTimestamp_clone(&val_conv);
25265         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
25266 }
25267
25268 jboolean  __attribute__((visibility("default"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
25269         LDKRawDataPart a_conv;
25270         a_conv.inner = (void*)(a & (~1));
25271         a_conv.is_owned = false;
25272         LDKRawDataPart b_conv;
25273         b_conv.inner = (void*)(b & (~1));
25274         b_conv.is_owned = false;
25275         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
25276         return ret_val;
25277 }
25278
25279 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t orig) {
25280         LDKRawDataPart orig_conv;
25281         orig_conv.inner = (void*)(orig & (~1));
25282         orig_conv.is_owned = false;
25283         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
25284         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25285         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25286         uint64_t ret_ref = (uint64_t)ret_var.inner;
25287         if (ret_var.is_owned) {
25288                 ret_ref |= 1;
25289         }
25290         return ret_ref;
25291 }
25292
25293 void  __attribute__((visibility("default"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
25294         LDKPositiveTimestamp this_obj_conv;
25295         this_obj_conv.inner = (void*)(this_obj & (~1));
25296         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25297         PositiveTimestamp_free(this_obj_conv);
25298 }
25299
25300 jboolean  __attribute__((visibility("default"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
25301         LDKPositiveTimestamp a_conv;
25302         a_conv.inner = (void*)(a & (~1));
25303         a_conv.is_owned = false;
25304         LDKPositiveTimestamp b_conv;
25305         b_conv.inner = (void*)(b & (~1));
25306         b_conv.is_owned = false;
25307         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
25308         return ret_val;
25309 }
25310
25311 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint32_t orig) {
25312         LDKPositiveTimestamp orig_conv;
25313         orig_conv.inner = (void*)(orig & (~1));
25314         orig_conv.is_owned = false;
25315         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
25316         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25317         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25318         uint64_t ret_ref = (uint64_t)ret_var.inner;
25319         if (ret_var.is_owned) {
25320                 ret_ref |= 1;
25321         }
25322         return ret_ref;
25323 }
25324
25325 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_clone(uint32_t orig) {
25326         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
25327         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
25328         return ret_conv;
25329 }
25330
25331 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_milli() {
25332         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
25333         return ret_conv;
25334 }
25335
25336 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_micro() {
25337         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
25338         return ret_conv;
25339 }
25340
25341 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_nano() {
25342         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
25343         return ret_conv;
25344 }
25345
25346 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_pico() {
25347         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
25348         return ret_conv;
25349 }
25350
25351 jboolean  __attribute__((visibility("default"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
25352         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
25353         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
25354         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
25355         return ret_val;
25356 }
25357
25358 int64_t  __attribute__((visibility("default"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
25359         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
25360         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
25361         return ret_val;
25362 }
25363
25364 uint32_t  __attribute__((visibility("default"))) TS_Currency_clone(uint32_t orig) {
25365         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
25366         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
25367         return ret_conv;
25368 }
25369
25370 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin() {
25371         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
25372         return ret_conv;
25373 }
25374
25375 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin_testnet() {
25376         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
25377         return ret_conv;
25378 }
25379
25380 uint32_t  __attribute__((visibility("default"))) TS_Currency_regtest() {
25381         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
25382         return ret_conv;
25383 }
25384
25385 uint32_t  __attribute__((visibility("default"))) TS_Currency_simnet() {
25386         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
25387         return ret_conv;
25388 }
25389
25390 uint32_t  __attribute__((visibility("default"))) TS_Currency_signet() {
25391         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
25392         return ret_conv;
25393 }
25394
25395 int64_t  __attribute__((visibility("default"))) TS_Currency_hash(uint32_t o) {
25396         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
25397         int64_t ret_val = Currency_hash(o_conv);
25398         return ret_val;
25399 }
25400
25401 jboolean  __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) {
25402         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
25403         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
25404         jboolean ret_val = Currency_eq(a_conv, b_conv);
25405         return ret_val;
25406 }
25407
25408 void  __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) {
25409         LDKSha256 this_obj_conv;
25410         this_obj_conv.inner = (void*)(this_obj & (~1));
25411         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25412         Sha256_free(this_obj_conv);
25413 }
25414
25415 uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) {
25416         LDKSha256 orig_conv;
25417         orig_conv.inner = (void*)(orig & (~1));
25418         orig_conv.is_owned = false;
25419         LDKSha256 ret_var = Sha256_clone(&orig_conv);
25420         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25421         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25422         uint64_t ret_ref = (uint64_t)ret_var.inner;
25423         if (ret_var.is_owned) {
25424                 ret_ref |= 1;
25425         }
25426         return ret_ref;
25427 }
25428
25429 int64_t  __attribute__((visibility("default"))) TS_Sha256_hash(uint32_t o) {
25430         LDKSha256 o_conv;
25431         o_conv.inner = (void*)(o & (~1));
25432         o_conv.is_owned = false;
25433         int64_t ret_val = Sha256_hash(&o_conv);
25434         return ret_val;
25435 }
25436
25437 jboolean  __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
25438         LDKSha256 a_conv;
25439         a_conv.inner = (void*)(a & (~1));
25440         a_conv.is_owned = false;
25441         LDKSha256 b_conv;
25442         b_conv.inner = (void*)(b & (~1));
25443         b_conv.is_owned = false;
25444         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
25445         return ret_val;
25446 }
25447
25448 void  __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) {
25449         LDKDescription this_obj_conv;
25450         this_obj_conv.inner = (void*)(this_obj & (~1));
25451         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25452         Description_free(this_obj_conv);
25453 }
25454
25455 uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) {
25456         LDKDescription orig_conv;
25457         orig_conv.inner = (void*)(orig & (~1));
25458         orig_conv.is_owned = false;
25459         LDKDescription ret_var = Description_clone(&orig_conv);
25460         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25461         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25462         uint64_t ret_ref = (uint64_t)ret_var.inner;
25463         if (ret_var.is_owned) {
25464                 ret_ref |= 1;
25465         }
25466         return ret_ref;
25467 }
25468
25469 int64_t  __attribute__((visibility("default"))) TS_Description_hash(uint32_t o) {
25470         LDKDescription o_conv;
25471         o_conv.inner = (void*)(o & (~1));
25472         o_conv.is_owned = false;
25473         int64_t ret_val = Description_hash(&o_conv);
25474         return ret_val;
25475 }
25476
25477 jboolean  __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) {
25478         LDKDescription a_conv;
25479         a_conv.inner = (void*)(a & (~1));
25480         a_conv.is_owned = false;
25481         LDKDescription b_conv;
25482         b_conv.inner = (void*)(b & (~1));
25483         b_conv.is_owned = false;
25484         jboolean ret_val = Description_eq(&a_conv, &b_conv);
25485         return ret_val;
25486 }
25487
25488 void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) {
25489         LDKPayeePubKey this_obj_conv;
25490         this_obj_conv.inner = (void*)(this_obj & (~1));
25491         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25492         PayeePubKey_free(this_obj_conv);
25493 }
25494
25495 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) {
25496         LDKPayeePubKey orig_conv;
25497         orig_conv.inner = (void*)(orig & (~1));
25498         orig_conv.is_owned = false;
25499         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
25500         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25501         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25502         uint64_t ret_ref = (uint64_t)ret_var.inner;
25503         if (ret_var.is_owned) {
25504                 ret_ref |= 1;
25505         }
25506         return ret_ref;
25507 }
25508
25509 int64_t  __attribute__((visibility("default"))) TS_PayeePubKey_hash(uint32_t o) {
25510         LDKPayeePubKey o_conv;
25511         o_conv.inner = (void*)(o & (~1));
25512         o_conv.is_owned = false;
25513         int64_t ret_val = PayeePubKey_hash(&o_conv);
25514         return ret_val;
25515 }
25516
25517 jboolean  __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
25518         LDKPayeePubKey a_conv;
25519         a_conv.inner = (void*)(a & (~1));
25520         a_conv.is_owned = false;
25521         LDKPayeePubKey b_conv;
25522         b_conv.inner = (void*)(b & (~1));
25523         b_conv.is_owned = false;
25524         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
25525         return ret_val;
25526 }
25527
25528 void  __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) {
25529         LDKExpiryTime this_obj_conv;
25530         this_obj_conv.inner = (void*)(this_obj & (~1));
25531         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25532         ExpiryTime_free(this_obj_conv);
25533 }
25534
25535 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) {
25536         LDKExpiryTime orig_conv;
25537         orig_conv.inner = (void*)(orig & (~1));
25538         orig_conv.is_owned = false;
25539         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
25540         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25541         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25542         uint64_t ret_ref = (uint64_t)ret_var.inner;
25543         if (ret_var.is_owned) {
25544                 ret_ref |= 1;
25545         }
25546         return ret_ref;
25547 }
25548
25549 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_hash(uint32_t o) {
25550         LDKExpiryTime o_conv;
25551         o_conv.inner = (void*)(o & (~1));
25552         o_conv.is_owned = false;
25553         int64_t ret_val = ExpiryTime_hash(&o_conv);
25554         return ret_val;
25555 }
25556
25557 jboolean  __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
25558         LDKExpiryTime a_conv;
25559         a_conv.inner = (void*)(a & (~1));
25560         a_conv.is_owned = false;
25561         LDKExpiryTime b_conv;
25562         b_conv.inner = (void*)(b & (~1));
25563         b_conv.is_owned = false;
25564         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
25565         return ret_val;
25566 }
25567
25568 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
25569         LDKMinFinalCltvExpiry this_obj_conv;
25570         this_obj_conv.inner = (void*)(this_obj & (~1));
25571         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25572         MinFinalCltvExpiry_free(this_obj_conv);
25573 }
25574
25575 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
25576         LDKMinFinalCltvExpiry orig_conv;
25577         orig_conv.inner = (void*)(orig & (~1));
25578         orig_conv.is_owned = false;
25579         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
25580         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25581         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25582         uint64_t ret_ref = (uint64_t)ret_var.inner;
25583         if (ret_var.is_owned) {
25584                 ret_ref |= 1;
25585         }
25586         return ret_ref;
25587 }
25588
25589 int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
25590         LDKMinFinalCltvExpiry o_conv;
25591         o_conv.inner = (void*)(o & (~1));
25592         o_conv.is_owned = false;
25593         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
25594         return ret_val;
25595 }
25596
25597 jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
25598         LDKMinFinalCltvExpiry a_conv;
25599         a_conv.inner = (void*)(a & (~1));
25600         a_conv.is_owned = false;
25601         LDKMinFinalCltvExpiry b_conv;
25602         b_conv.inner = (void*)(b & (~1));
25603         b_conv.is_owned = false;
25604         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
25605         return ret_val;
25606 }
25607
25608 void  __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) {
25609         if ((this_ptr & 1) != 0) return;
25610         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
25611         FREE((void*)this_ptr);
25612         Fallback_free(this_ptr_conv);
25613 }
25614
25615 uint32_t  __attribute__((visibility("default"))) TS_Fallback_clone(uint32_t orig) {
25616         LDKFallback* orig_conv = (LDKFallback*)orig;
25617         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
25618         *ret_copy = Fallback_clone(orig_conv);
25619         uint64_t ret_ref = (uint64_t)ret_copy;
25620         return ret_ref;
25621 }
25622
25623 uint32_t  __attribute__((visibility("default"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
25624         
25625         LDKCVec_u8Z program_ref;
25626         program_ref.datalen = *((uint32_t*)program);
25627         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
25628         memcpy(program_ref.data, (uint8_t*)(program + 4), program_ref.datalen);
25629         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
25630         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
25631         uint64_t ret_ref = (uint64_t)ret_copy;
25632         return ret_ref;
25633 }
25634
25635 uint32_t  __attribute__((visibility("default"))) TS_Fallback_pub_key_hash(int8_tArray a) {
25636         LDKTwentyBytes a_ref;
25637         CHECK(*((uint32_t*)a) == 20);
25638         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
25639         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
25640         *ret_copy = Fallback_pub_key_hash(a_ref);
25641         uint64_t ret_ref = (uint64_t)ret_copy;
25642         return ret_ref;
25643 }
25644
25645 uint32_t  __attribute__((visibility("default"))) TS_Fallback_script_hash(int8_tArray a) {
25646         LDKTwentyBytes a_ref;
25647         CHECK(*((uint32_t*)a) == 20);
25648         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
25649         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
25650         *ret_copy = Fallback_script_hash(a_ref);
25651         uint64_t ret_ref = (uint64_t)ret_copy;
25652         return ret_ref;
25653 }
25654
25655 int64_t  __attribute__((visibility("default"))) TS_Fallback_hash(uint32_t o) {
25656         LDKFallback* o_conv = (LDKFallback*)o;
25657         int64_t ret_val = Fallback_hash(o_conv);
25658         return ret_val;
25659 }
25660
25661 jboolean  __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
25662         LDKFallback* a_conv = (LDKFallback*)a;
25663         LDKFallback* b_conv = (LDKFallback*)b;
25664         jboolean ret_val = Fallback_eq(a_conv, b_conv);
25665         return ret_val;
25666 }
25667
25668 void  __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t this_obj) {
25669         LDKInvoiceSignature this_obj_conv;
25670         this_obj_conv.inner = (void*)(this_obj & (~1));
25671         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25672         InvoiceSignature_free(this_obj_conv);
25673 }
25674
25675 uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) {
25676         LDKInvoiceSignature orig_conv;
25677         orig_conv.inner = (void*)(orig & (~1));
25678         orig_conv.is_owned = false;
25679         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
25680         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25681         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25682         uint64_t ret_ref = (uint64_t)ret_var.inner;
25683         if (ret_var.is_owned) {
25684                 ret_ref |= 1;
25685         }
25686         return ret_ref;
25687 }
25688
25689 jboolean  __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
25690         LDKInvoiceSignature a_conv;
25691         a_conv.inner = (void*)(a & (~1));
25692         a_conv.is_owned = false;
25693         LDKInvoiceSignature b_conv;
25694         b_conv.inner = (void*)(b & (~1));
25695         b_conv.is_owned = false;
25696         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
25697         return ret_val;
25698 }
25699
25700 void  __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) {
25701         LDKPrivateRoute this_obj_conv;
25702         this_obj_conv.inner = (void*)(this_obj & (~1));
25703         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25704         PrivateRoute_free(this_obj_conv);
25705 }
25706
25707 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) {
25708         LDKPrivateRoute orig_conv;
25709         orig_conv.inner = (void*)(orig & (~1));
25710         orig_conv.is_owned = false;
25711         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
25712         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25713         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25714         uint64_t ret_ref = (uint64_t)ret_var.inner;
25715         if (ret_var.is_owned) {
25716                 ret_ref |= 1;
25717         }
25718         return ret_ref;
25719 }
25720
25721 int64_t  __attribute__((visibility("default"))) TS_PrivateRoute_hash(uint32_t o) {
25722         LDKPrivateRoute o_conv;
25723         o_conv.inner = (void*)(o & (~1));
25724         o_conv.is_owned = false;
25725         int64_t ret_val = PrivateRoute_hash(&o_conv);
25726         return ret_val;
25727 }
25728
25729 jboolean  __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
25730         LDKPrivateRoute a_conv;
25731         a_conv.inner = (void*)(a & (~1));
25732         a_conv.is_owned = false;
25733         LDKPrivateRoute b_conv;
25734         b_conv.inner = (void*)(b & (~1));
25735         b_conv.is_owned = false;
25736         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
25737         return ret_val;
25738 }
25739
25740 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
25741         LDKSignedRawInvoice this_arg_conv;
25742         this_arg_conv.inner = (void*)(this_arg & (~1));
25743         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25744         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
25745         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
25746         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
25747         return (uint64_t)ret_ref;
25748 }
25749
25750 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
25751         LDKSignedRawInvoice this_arg_conv;
25752         this_arg_conv.inner = (void*)(this_arg & (~1));
25753         this_arg_conv.is_owned = false;
25754         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
25755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25757         uint64_t ret_ref = (uint64_t)ret_var.inner;
25758         if (ret_var.is_owned) {
25759                 ret_ref |= 1;
25760         }
25761         return ret_ref;
25762 }
25763
25764 int8_tArray  __attribute__((visibility("default"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
25765         LDKSignedRawInvoice this_arg_conv;
25766         this_arg_conv.inner = (void*)(this_arg & (~1));
25767         this_arg_conv.is_owned = false;
25768         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25769         memcpy((uint8_t*)(ret_arr + 4), *SignedRawInvoice_hash(&this_arg_conv), 32);
25770         return ret_arr;
25771 }
25772
25773 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
25774         LDKSignedRawInvoice this_arg_conv;
25775         this_arg_conv.inner = (void*)(this_arg & (~1));
25776         this_arg_conv.is_owned = false;
25777         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
25778         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25779         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25780         uint64_t ret_ref = (uint64_t)ret_var.inner;
25781         if (ret_var.is_owned) {
25782                 ret_ref |= 1;
25783         }
25784         return ret_ref;
25785 }
25786
25787 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
25788         LDKSignedRawInvoice this_arg_conv;
25789         this_arg_conv.inner = (void*)(this_arg & (~1));
25790         this_arg_conv.is_owned = false;
25791         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
25792         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
25793         return (uint64_t)ret_conv;
25794 }
25795
25796 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
25797         LDKSignedRawInvoice this_arg_conv;
25798         this_arg_conv.inner = (void*)(this_arg & (~1));
25799         this_arg_conv.is_owned = false;
25800         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
25801         return ret_val;
25802 }
25803
25804 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_hash(uint32_t this_arg) {
25805         LDKRawInvoice this_arg_conv;
25806         this_arg_conv.inner = (void*)(this_arg & (~1));
25807         this_arg_conv.is_owned = false;
25808         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25809         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_hash(&this_arg_conv).data, 32);
25810         return ret_arr;
25811 }
25812
25813 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
25814         LDKRawInvoice this_arg_conv;
25815         this_arg_conv.inner = (void*)(this_arg & (~1));
25816         this_arg_conv.is_owned = false;
25817         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
25818         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25819         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25820         uint64_t ret_ref = (uint64_t)ret_var.inner;
25821         if (ret_var.is_owned) {
25822                 ret_ref |= 1;
25823         }
25824         return ret_ref;
25825 }
25826
25827 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint32_t this_arg) {
25828         LDKRawInvoice this_arg_conv;
25829         this_arg_conv.inner = (void*)(this_arg & (~1));
25830         this_arg_conv.is_owned = false;
25831         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
25832         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25833         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25834         uint64_t ret_ref = (uint64_t)ret_var.inner;
25835         if (ret_var.is_owned) {
25836                 ret_ref |= 1;
25837         }
25838         return ret_ref;
25839 }
25840
25841 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
25842         LDKRawInvoice this_arg_conv;
25843         this_arg_conv.inner = (void*)(this_arg & (~1));
25844         this_arg_conv.is_owned = false;
25845         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
25846         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25847         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25848         uint64_t ret_ref = (uint64_t)ret_var.inner;
25849         if (ret_var.is_owned) {
25850                 ret_ref |= 1;
25851         }
25852         return ret_ref;
25853 }
25854
25855 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
25856         LDKRawInvoice this_arg_conv;
25857         this_arg_conv.inner = (void*)(this_arg & (~1));
25858         this_arg_conv.is_owned = false;
25859         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
25860         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25861         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25862         uint64_t ret_ref = (uint64_t)ret_var.inner;
25863         if (ret_var.is_owned) {
25864                 ret_ref |= 1;
25865         }
25866         return ret_ref;
25867 }
25868
25869 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
25870         LDKRawInvoice this_arg_conv;
25871         this_arg_conv.inner = (void*)(this_arg & (~1));
25872         this_arg_conv.is_owned = false;
25873         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
25874         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25875         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25876         uint64_t ret_ref = (uint64_t)ret_var.inner;
25877         if (ret_var.is_owned) {
25878                 ret_ref |= 1;
25879         }
25880         return ret_ref;
25881 }
25882
25883 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
25884         LDKRawInvoice this_arg_conv;
25885         this_arg_conv.inner = (void*)(this_arg & (~1));
25886         this_arg_conv.is_owned = false;
25887         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
25888         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25889         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25890         uint64_t ret_ref = (uint64_t)ret_var.inner;
25891         if (ret_var.is_owned) {
25892                 ret_ref |= 1;
25893         }
25894         return ret_ref;
25895 }
25896
25897 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
25898         LDKRawInvoice this_arg_conv;
25899         this_arg_conv.inner = (void*)(this_arg & (~1));
25900         this_arg_conv.is_owned = false;
25901         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25902         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_payment_secret(&this_arg_conv).data, 32);
25903         return ret_arr;
25904 }
25905
25906 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t this_arg) {
25907         LDKRawInvoice this_arg_conv;
25908         this_arg_conv.inner = (void*)(this_arg & (~1));
25909         this_arg_conv.is_owned = false;
25910         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
25911         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25912         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25913         uint64_t ret_ref = (uint64_t)ret_var.inner;
25914         if (ret_var.is_owned) {
25915                 ret_ref |= 1;
25916         }
25917         return ret_ref;
25918 }
25919
25920 uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
25921         LDKRawInvoice this_arg_conv;
25922         this_arg_conv.inner = (void*)(this_arg & (~1));
25923         this_arg_conv.is_owned = false;
25924         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
25925         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
25926         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
25927         for (size_t o = 0; o < ret_var.datalen; o++) {
25928                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
25929                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25930                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25931                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
25932                 if (ret_conv_14_var.is_owned) {
25933                         ret_conv_14_ref |= 1;
25934                 }
25935                 ret_arr_ptr[o] = ret_conv_14_ref;
25936         }
25937         FREE(ret_var.data);
25938         return ret_arr;
25939 }
25940
25941 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
25942         LDKRawInvoice this_arg_conv;
25943         this_arg_conv.inner = (void*)(this_arg & (~1));
25944         this_arg_conv.is_owned = false;
25945         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25946         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
25947         uint64_t ret_ref = (uint64_t)ret_copy;
25948         return ret_ref;
25949 }
25950
25951 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_currency(uint32_t this_arg) {
25952         LDKRawInvoice this_arg_conv;
25953         this_arg_conv.inner = (void*)(this_arg & (~1));
25954         this_arg_conv.is_owned = false;
25955         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
25956         return ret_conv;
25957 }
25958
25959 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
25960         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
25961         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
25962         return (uint64_t)ret_conv;
25963 }
25964
25965 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_system_time(int64_t time) {
25966         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
25967         *ret_conv = PositiveTimestamp_from_system_time(time);
25968         return (uint64_t)ret_conv;
25969 }
25970
25971 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
25972         LDKPositiveTimestamp this_arg_conv;
25973         this_arg_conv.inner = (void*)(this_arg & (~1));
25974         this_arg_conv.is_owned = false;
25975         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
25976         return ret_val;
25977 }
25978
25979 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_time(uint32_t this_arg) {
25980         LDKPositiveTimestamp this_arg_conv;
25981         this_arg_conv.inner = (void*)(this_arg & (~1));
25982         this_arg_conv.is_owned = false;
25983         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
25984         return ret_val;
25985 }
25986
25987 uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
25988         LDKInvoice this_arg_conv;
25989         this_arg_conv.inner = (void*)(this_arg & (~1));
25990         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25991         this_arg_conv = Invoice_clone(&this_arg_conv);
25992         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
25993         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25994         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25995         uint64_t ret_ref = (uint64_t)ret_var.inner;
25996         if (ret_var.is_owned) {
25997                 ret_ref |= 1;
25998         }
25999         return ret_ref;
26000 }
26001
26002 uint32_t  __attribute__((visibility("default"))) TS_Invoice_check_signature(uint32_t this_arg) {
26003         LDKInvoice this_arg_conv;
26004         this_arg_conv.inner = (void*)(this_arg & (~1));
26005         this_arg_conv.is_owned = false;
26006         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
26007         *ret_conv = Invoice_check_signature(&this_arg_conv);
26008         return (uint64_t)ret_conv;
26009 }
26010
26011 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
26012         LDKSignedRawInvoice signed_invoice_conv;
26013         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
26014         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
26015         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
26016         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
26017         *ret_conv = Invoice_from_signed(signed_invoice_conv);
26018         return (uint64_t)ret_conv;
26019 }
26020
26021 int64_t  __attribute__((visibility("default"))) TS_Invoice_timestamp(uint32_t this_arg) {
26022         LDKInvoice this_arg_conv;
26023         this_arg_conv.inner = (void*)(this_arg & (~1));
26024         this_arg_conv.is_owned = false;
26025         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
26026         return ret_val;
26027 }
26028
26029 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_hash(uint32_t this_arg) {
26030         LDKInvoice this_arg_conv;
26031         this_arg_conv.inner = (void*)(this_arg & (~1));
26032         this_arg_conv.is_owned = false;
26033         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26034         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_hash(&this_arg_conv), 32);
26035         return ret_arr;
26036 }
26037
26038 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
26039         LDKInvoice this_arg_conv;
26040         this_arg_conv.inner = (void*)(this_arg & (~1));
26041         this_arg_conv.is_owned = false;
26042         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
26043         memcpy((uint8_t*)(ret_arr + 4), Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
26044         return ret_arr;
26045 }
26046
26047 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(uint32_t this_arg) {
26048         LDKInvoice this_arg_conv;
26049         this_arg_conv.inner = (void*)(this_arg & (~1));
26050         this_arg_conv.is_owned = false;
26051         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26052         memcpy((uint8_t*)(ret_arr + 4), Invoice_payment_secret(&this_arg_conv).data, 32);
26053         return ret_arr;
26054 }
26055
26056 uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t this_arg) {
26057         LDKInvoice this_arg_conv;
26058         this_arg_conv.inner = (void*)(this_arg & (~1));
26059         this_arg_conv.is_owned = false;
26060         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
26061         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26062         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26063         uint64_t ret_ref = (uint64_t)ret_var.inner;
26064         if (ret_var.is_owned) {
26065                 ret_ref |= 1;
26066         }
26067         return ret_ref;
26068 }
26069
26070 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
26071         LDKInvoice this_arg_conv;
26072         this_arg_conv.inner = (void*)(this_arg & (~1));
26073         this_arg_conv.is_owned = false;
26074         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
26075         memcpy((uint8_t*)(ret_arr + 4), Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
26076         return ret_arr;
26077 }
26078
26079 int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t this_arg) {
26080         LDKInvoice this_arg_conv;
26081         this_arg_conv.inner = (void*)(this_arg & (~1));
26082         this_arg_conv.is_owned = false;
26083         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
26084         return ret_val;
26085 }
26086
26087 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
26088         LDKInvoice this_arg_conv;
26089         this_arg_conv.inner = (void*)(this_arg & (~1));
26090         this_arg_conv.is_owned = false;
26091         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
26092         return ret_val;
26093 }
26094
26095 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(uint32_t this_arg) {
26096         LDKInvoice this_arg_conv;
26097         this_arg_conv.inner = (void*)(this_arg & (~1));
26098         this_arg_conv.is_owned = false;
26099         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
26100         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
26101         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
26102         for (size_t o = 0; o < ret_var.datalen; o++) {
26103                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
26104                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26105                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26106                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
26107                 if (ret_conv_14_var.is_owned) {
26108                         ret_conv_14_ref |= 1;
26109                 }
26110                 ret_arr_ptr[o] = ret_conv_14_ref;
26111         }
26112         FREE(ret_var.data);
26113         return ret_arr;
26114 }
26115
26116 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uint32_t this_arg) {
26117         LDKInvoice this_arg_conv;
26118         this_arg_conv.inner = (void*)(this_arg & (~1));
26119         this_arg_conv.is_owned = false;
26120         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
26121         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
26122         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
26123         for (size_t l = 0; l < ret_var.datalen; l++) {
26124                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
26125                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26126                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26127                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
26128                 if (ret_conv_11_var.is_owned) {
26129                         ret_conv_11_ref |= 1;
26130                 }
26131                 ret_arr_ptr[l] = ret_conv_11_ref;
26132         }
26133         FREE(ret_var.data);
26134         return ret_arr;
26135 }
26136
26137 uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t this_arg) {
26138         LDKInvoice this_arg_conv;
26139         this_arg_conv.inner = (void*)(this_arg & (~1));
26140         this_arg_conv.is_owned = false;
26141         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
26142         return ret_conv;
26143 }
26144
26145 uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_pico_btc(uint32_t this_arg) {
26146         LDKInvoice this_arg_conv;
26147         this_arg_conv.inner = (void*)(this_arg & (~1));
26148         this_arg_conv.is_owned = false;
26149         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26150         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
26151         uint64_t ret_ref = (uint64_t)ret_copy;
26152         return ret_ref;
26153 }
26154
26155 uint32_t  __attribute__((visibility("default"))) TS_Description_new(jstring description) {
26156         LDKStr description_conv = str_ref_to_owned_c(description);
26157         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
26158         *ret_conv = Description_new(description_conv);
26159         return (uint64_t)ret_conv;
26160 }
26161
26162 jstring  __attribute__((visibility("default"))) TS_Description_into_inner(uint32_t this_arg) {
26163         LDKDescription this_arg_conv;
26164         this_arg_conv.inner = (void*)(this_arg & (~1));
26165         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26166         this_arg_conv = Description_clone(&this_arg_conv);
26167         LDKStr ret_str = Description_into_inner(this_arg_conv);
26168         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26169         Str_free(ret_str);
26170         return ret_conv;
26171 }
26172
26173 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
26174         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
26175         *ret_conv = ExpiryTime_from_seconds(seconds);
26176         return (uint64_t)ret_conv;
26177 }
26178
26179 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_duration(int64_t duration) {
26180         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
26181         *ret_conv = ExpiryTime_from_duration(duration);
26182         return (uint64_t)ret_conv;
26183 }
26184
26185 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
26186         LDKExpiryTime this_arg_conv;
26187         this_arg_conv.inner = (void*)(this_arg & (~1));
26188         this_arg_conv.is_owned = false;
26189         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
26190         return ret_val;
26191 }
26192
26193 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
26194         LDKExpiryTime this_arg_conv;
26195         this_arg_conv.inner = (void*)(this_arg & (~1));
26196         this_arg_conv.is_owned = false;
26197         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
26198         return ret_val;
26199 }
26200
26201 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_new(uint32_t hops) {
26202         LDKRouteHint hops_conv;
26203         hops_conv.inner = (void*)(hops & (~1));
26204         hops_conv.is_owned = (hops & 1) || (hops == 0);
26205         hops_conv = RouteHint_clone(&hops_conv);
26206         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
26207         *ret_conv = PrivateRoute_new(hops_conv);
26208         return (uint64_t)ret_conv;
26209 }
26210
26211 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
26212         LDKPrivateRoute this_arg_conv;
26213         this_arg_conv.inner = (void*)(this_arg & (~1));
26214         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26215         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
26216         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
26217         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26218         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26219         uint64_t ret_ref = (uint64_t)ret_var.inner;
26220         if (ret_var.is_owned) {
26221                 ret_ref |= 1;
26222         }
26223         return ret_ref;
26224 }
26225
26226 uint32_t  __attribute__((visibility("default"))) TS_CreationError_clone(uint32_t orig) {
26227         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
26228         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
26229         return ret_conv;
26230 }
26231
26232 uint32_t  __attribute__((visibility("default"))) TS_CreationError_description_too_long() {
26233         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
26234         return ret_conv;
26235 }
26236
26237 uint32_t  __attribute__((visibility("default"))) TS_CreationError_route_too_long() {
26238         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
26239         return ret_conv;
26240 }
26241
26242 uint32_t  __attribute__((visibility("default"))) TS_CreationError_timestamp_out_of_bounds() {
26243         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
26244         return ret_conv;
26245 }
26246
26247 uint32_t  __attribute__((visibility("default"))) TS_CreationError_expiry_time_out_of_bounds() {
26248         uint32_t ret_conv = LDKCreationError_to_js(CreationError_expiry_time_out_of_bounds());
26249         return ret_conv;
26250 }
26251
26252 jboolean  __attribute__((visibility("default"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
26253         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
26254         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
26255         jboolean ret_val = CreationError_eq(a_conv, b_conv);
26256         return ret_val;
26257 }
26258
26259 jstring  __attribute__((visibility("default"))) TS_CreationError_to_str(uint32_t o) {
26260         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
26261         LDKStr ret_str = CreationError_to_str(o_conv);
26262         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26263         Str_free(ret_str);
26264         return ret_conv;
26265 }
26266
26267 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_clone(uint32_t orig) {
26268         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
26269         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
26270         return ret_conv;
26271 }
26272
26273 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_hash() {
26274         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
26275         return ret_conv;
26276 }
26277
26278 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_hashes() {
26279         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
26280         return ret_conv;
26281 }
26282
26283 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_description() {
26284         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
26285         return ret_conv;
26286 }
26287
26288 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_descriptions() {
26289         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
26290         return ret_conv;
26291 }
26292
26293 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_secret() {
26294         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
26295         return ret_conv;
26296 }
26297
26298 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_secrets() {
26299         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
26300         return ret_conv;
26301 }
26302
26303 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_features() {
26304         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
26305         return ret_conv;
26306 }
26307
26308 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_recovery_id() {
26309         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
26310         return ret_conv;
26311 }
26312
26313 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_signature() {
26314         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
26315         return ret_conv;
26316 }
26317
26318 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_imprecise_amount() {
26319         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
26320         return ret_conv;
26321 }
26322
26323 jboolean  __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
26324         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
26325         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
26326         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
26327         return ret_val;
26328 }
26329
26330 jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t o) {
26331         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
26332         LDKStr ret_str = SemanticError_to_str(o_conv);
26333         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26334         Str_free(ret_str);
26335         return ret_conv;
26336 }
26337
26338 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
26339         if ((this_ptr & 1) != 0) return;
26340         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
26341         FREE((void*)this_ptr);
26342         SignOrCreationError_free(this_ptr_conv);
26343 }
26344
26345 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone(uint32_t orig) {
26346         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
26347         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26348         *ret_copy = SignOrCreationError_clone(orig_conv);
26349         uint64_t ret_ref = (uint64_t)ret_copy;
26350         return ret_ref;
26351 }
26352
26353 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_sign_error() {
26354         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26355         *ret_copy = SignOrCreationError_sign_error();
26356         uint64_t ret_ref = (uint64_t)ret_copy;
26357         return ret_ref;
26358 }
26359
26360 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_creation_error(uint32_t a) {
26361         LDKCreationError a_conv = LDKCreationError_from_js(a);
26362         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26363         *ret_copy = SignOrCreationError_creation_error(a_conv);
26364         uint64_t ret_ref = (uint64_t)ret_copy;
26365         return ret_ref;
26366 }
26367
26368 jboolean  __attribute__((visibility("default"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
26369         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
26370         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
26371         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
26372         return ret_val;
26373 }
26374
26375 jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(uint32_t o) {
26376         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
26377         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
26378         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26379         Str_free(ret_str);
26380         return ret_conv;
26381 }
26382
26383 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) {
26384         LDKChannelManager channelmanager_conv;
26385         channelmanager_conv.inner = (void*)(channelmanager & (~1));
26386         channelmanager_conv.is_owned = false;
26387         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
26388         LDKCurrency network_conv = LDKCurrency_from_js(network);
26389         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
26390         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
26391         LDKStr description_conv = str_ref_to_owned_c(description);
26392         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26393         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
26394         return (uint64_t)ret_conv;
26395 }
26396
26397 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
26398         LDKStr s_conv = str_ref_to_owned_c(s);
26399         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
26400         *ret_conv = SiPrefix_from_str(s_conv);
26401         return (uint64_t)ret_conv;
26402 }
26403
26404 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_str(jstring s) {
26405         LDKStr s_conv = str_ref_to_owned_c(s);
26406         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
26407         *ret_conv = Invoice_from_str(s_conv);
26408         return (uint64_t)ret_conv;
26409 }
26410
26411 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_from_str(jstring s) {
26412         LDKStr s_conv = str_ref_to_owned_c(s);
26413         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
26414         *ret_conv = SignedRawInvoice_from_str(s_conv);
26415         return (uint64_t)ret_conv;
26416 }
26417
26418 jstring  __attribute__((visibility("default"))) TS_Invoice_to_str(uint32_t o) {
26419         LDKInvoice o_conv;
26420         o_conv.inner = (void*)(o & (~1));
26421         o_conv.is_owned = false;
26422         LDKStr ret_str = Invoice_to_str(&o_conv);
26423         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26424         Str_free(ret_str);
26425         return ret_conv;
26426 }
26427
26428 jstring  __attribute__((visibility("default"))) TS_SignedRawInvoice_to_str(uint32_t o) {
26429         LDKSignedRawInvoice o_conv;
26430         o_conv.inner = (void*)(o & (~1));
26431         o_conv.is_owned = false;
26432         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
26433         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26434         Str_free(ret_str);
26435         return ret_conv;
26436 }
26437
26438 jstring  __attribute__((visibility("default"))) TS_Currency_to_str(uint32_t o) {
26439         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
26440         LDKStr ret_str = Currency_to_str(o_conv);
26441         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26442         Str_free(ret_str);
26443         return ret_conv;
26444 }
26445
26446 jstring  __attribute__((visibility("default"))) TS_SiPrefix_to_str(uint32_t o) {
26447         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
26448         LDKStr ret_str = SiPrefix_to_str(o_conv);
26449         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26450         Str_free(ret_str);
26451         return ret_conv;
26452 }
26453