Update auto-generated bindings to 0.0.103
[ldk-java] / ts / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "js-wasm.h"
4 #include <stdatomic.h>
5 #include <lightning.h>
6
7 // These should be provided...somehow...
8 void *memset(void *s, int c, size_t n);
9 void *memcpy(void *dest, const void *src, size_t n);
10 int memcmp(const void *s1, const void *s2, size_t n);
11
12 void __attribute__((noreturn)) abort(void);
13 static inline void assert(bool expression) {
14         if (!expression) { abort(); }
15 }
16
17 void *malloc(size_t size);
18 void free(void *ptr);
19
20 #define MALLOC(a, _) malloc(a)
21 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
22 #define DO_ASSERT(a) (void)(a)
23 #define CHECK(a)
24 #define CHECK_ACCESS(p)
25
26 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
27 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
28 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
29 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
30
31 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
32
33 typedef uint32_t int64_tArray;
34 typedef uint32_t int8_tArray;
35 typedef uint32_t uint32_tArray;
36 typedef uint32_t ptrArray;
37 typedef uint32_t jstring;
38
39 static inline uint32_t init_arr(size_t arr_len, size_t elem_size, const char *type_desc) {
40         uint32_t *elems = (uint32_t*)MALLOC(arr_len * elem_size + 4, type_desc);
41         elems[0] = arr_len;
42         return (uint32_t)elems;
43 }
44
45 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
46         char* err_buf = MALLOC(len + 4, "str conv buf");
47         *((uint32_t*)err_buf) = len;
48         memcpy(err_buf + 4, chars, len);
49         return (uint32_t) err_buf;
50 }
51 static inline LDKStr str_ref_to_owned_c(jstring str) {
52         uint32_t *str_len = (uint32_t*)str;
53         char* newchars = MALLOC(*str_len + 1, "String chars");
54         memcpy(newchars, (const char*)(str + 4), *str_len);
55         newchars[*str_len] = 0;
56         LDKStr res= {
57                 .chars = newchars,
58                 .len = *str_len,
59                 .chars_is_owned = true
60         };
61         return res;
62 }
63
64 typedef bool jboolean;
65
66 uint32_t __attribute__((visibility("default"))) TS_malloc(uint32_t size) {
67         return (uint32_t)MALLOC(size, "JS-Called malloc");
68 }
69 void __attribute__((visibility("default"))) TS_free(uint32_t ptr) {
70         FREE((void*)ptr);
71 }
72 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
73 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
74         switch (ord) {
75                 case 0: return LDKAccessError_UnknownChain;
76                 case 1: return LDKAccessError_UnknownTx;
77         }
78         abort();
79 }
80 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
81         switch (val) {
82                 case LDKAccessError_UnknownChain: return 0;
83                 case LDKAccessError_UnknownTx: return 1;
84                 default: abort();
85         }
86 }
87 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
88         switch (ord) {
89                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
90                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
91         }
92         abort();
93 }
94 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
95         switch (val) {
96                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
97                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
98                 default: abort();
99         }
100 }
101 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
102         switch (ord) {
103                 case 0: return LDKConfirmationTarget_Background;
104                 case 1: return LDKConfirmationTarget_Normal;
105                 case 2: return LDKConfirmationTarget_HighPriority;
106         }
107         abort();
108 }
109 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
110         switch (val) {
111                 case LDKConfirmationTarget_Background: return 0;
112                 case LDKConfirmationTarget_Normal: return 1;
113                 case LDKConfirmationTarget_HighPriority: return 2;
114                 default: abort();
115         }
116 }
117 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
118         switch (ord) {
119                 case 0: return LDKCreationError_DescriptionTooLong;
120                 case 1: return LDKCreationError_RouteTooLong;
121                 case 2: return LDKCreationError_TimestampOutOfBounds;
122                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
123         }
124         abort();
125 }
126 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
127         switch (val) {
128                 case LDKCreationError_DescriptionTooLong: return 0;
129                 case LDKCreationError_RouteTooLong: return 1;
130                 case LDKCreationError_TimestampOutOfBounds: return 2;
131                 case LDKCreationError_ExpiryTimeOutOfBounds: return 3;
132                 default: abort();
133         }
134 }
135 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
136         switch (ord) {
137                 case 0: return LDKCurrency_Bitcoin;
138                 case 1: return LDKCurrency_BitcoinTestnet;
139                 case 2: return LDKCurrency_Regtest;
140                 case 3: return LDKCurrency_Simnet;
141                 case 4: return LDKCurrency_Signet;
142         }
143         abort();
144 }
145 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
146         switch (val) {
147                 case LDKCurrency_Bitcoin: return 0;
148                 case LDKCurrency_BitcoinTestnet: return 1;
149                 case LDKCurrency_Regtest: return 2;
150                 case LDKCurrency_Simnet: return 3;
151                 case LDKCurrency_Signet: return 4;
152                 default: abort();
153         }
154 }
155 static inline LDKIOError LDKIOError_from_js(int32_t ord) {
156         switch (ord) {
157                 case 0: return LDKIOError_NotFound;
158                 case 1: return LDKIOError_PermissionDenied;
159                 case 2: return LDKIOError_ConnectionRefused;
160                 case 3: return LDKIOError_ConnectionReset;
161                 case 4: return LDKIOError_ConnectionAborted;
162                 case 5: return LDKIOError_NotConnected;
163                 case 6: return LDKIOError_AddrInUse;
164                 case 7: return LDKIOError_AddrNotAvailable;
165                 case 8: return LDKIOError_BrokenPipe;
166                 case 9: return LDKIOError_AlreadyExists;
167                 case 10: return LDKIOError_WouldBlock;
168                 case 11: return LDKIOError_InvalidInput;
169                 case 12: return LDKIOError_InvalidData;
170                 case 13: return LDKIOError_TimedOut;
171                 case 14: return LDKIOError_WriteZero;
172                 case 15: return LDKIOError_Interrupted;
173                 case 16: return LDKIOError_Other;
174                 case 17: return LDKIOError_UnexpectedEof;
175         }
176         abort();
177 }
178 static inline int32_t LDKIOError_to_js(LDKIOError val) {
179         switch (val) {
180                 case LDKIOError_NotFound: return 0;
181                 case LDKIOError_PermissionDenied: return 1;
182                 case LDKIOError_ConnectionRefused: return 2;
183                 case LDKIOError_ConnectionReset: return 3;
184                 case LDKIOError_ConnectionAborted: return 4;
185                 case LDKIOError_NotConnected: return 5;
186                 case LDKIOError_AddrInUse: return 6;
187                 case LDKIOError_AddrNotAvailable: return 7;
188                 case LDKIOError_BrokenPipe: return 8;
189                 case LDKIOError_AlreadyExists: return 9;
190                 case LDKIOError_WouldBlock: return 10;
191                 case LDKIOError_InvalidInput: return 11;
192                 case LDKIOError_InvalidData: return 12;
193                 case LDKIOError_TimedOut: return 13;
194                 case LDKIOError_WriteZero: return 14;
195                 case LDKIOError_Interrupted: return 15;
196                 case LDKIOError_Other: return 16;
197                 case LDKIOError_UnexpectedEof: return 17;
198                 default: abort();
199         }
200 }
201 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
202         switch (ord) {
203                 case 0: return LDKLevel_Trace;
204                 case 1: return LDKLevel_Debug;
205                 case 2: return LDKLevel_Info;
206                 case 3: return LDKLevel_Warn;
207                 case 4: return LDKLevel_Error;
208         }
209         abort();
210 }
211 static inline int32_t LDKLevel_to_js(LDKLevel val) {
212         switch (val) {
213                 case LDKLevel_Trace: return 0;
214                 case LDKLevel_Debug: return 1;
215                 case LDKLevel_Info: return 2;
216                 case LDKLevel_Warn: return 3;
217                 case LDKLevel_Error: return 4;
218                 default: abort();
219         }
220 }
221 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
222         switch (ord) {
223                 case 0: return LDKNetwork_Bitcoin;
224                 case 1: return LDKNetwork_Testnet;
225                 case 2: return LDKNetwork_Regtest;
226                 case 3: return LDKNetwork_Signet;
227         }
228         abort();
229 }
230 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
231         switch (val) {
232                 case LDKNetwork_Bitcoin: return 0;
233                 case LDKNetwork_Testnet: return 1;
234                 case LDKNetwork_Regtest: return 2;
235                 case LDKNetwork_Signet: return 3;
236                 default: abort();
237         }
238 }
239 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
240         switch (ord) {
241                 case 0: return LDKSecp256k1Error_IncorrectSignature;
242                 case 1: return LDKSecp256k1Error_InvalidMessage;
243                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
244                 case 3: return LDKSecp256k1Error_InvalidSignature;
245                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
246                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
247                 case 6: return LDKSecp256k1Error_InvalidTweak;
248                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
249                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
250         }
251         abort();
252 }
253 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
254         switch (val) {
255                 case LDKSecp256k1Error_IncorrectSignature: return 0;
256                 case LDKSecp256k1Error_InvalidMessage: return 1;
257                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
258                 case LDKSecp256k1Error_InvalidSignature: return 3;
259                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
260                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
261                 case LDKSecp256k1Error_InvalidTweak: return 6;
262                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
263                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
264                 default: abort();
265         }
266 }
267 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
268         switch (ord) {
269                 case 0: return LDKSemanticError_NoPaymentHash;
270                 case 1: return LDKSemanticError_MultiplePaymentHashes;
271                 case 2: return LDKSemanticError_NoDescription;
272                 case 3: return LDKSemanticError_MultipleDescriptions;
273                 case 4: return LDKSemanticError_NoPaymentSecret;
274                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
275                 case 6: return LDKSemanticError_InvalidFeatures;
276                 case 7: return LDKSemanticError_InvalidRecoveryId;
277                 case 8: return LDKSemanticError_InvalidSignature;
278                 case 9: return LDKSemanticError_ImpreciseAmount;
279         }
280         abort();
281 }
282 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
283         switch (val) {
284                 case LDKSemanticError_NoPaymentHash: return 0;
285                 case LDKSemanticError_MultiplePaymentHashes: return 1;
286                 case LDKSemanticError_NoDescription: return 2;
287                 case LDKSemanticError_MultipleDescriptions: return 3;
288                 case LDKSemanticError_NoPaymentSecret: return 4;
289                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
290                 case LDKSemanticError_InvalidFeatures: return 6;
291                 case LDKSemanticError_InvalidRecoveryId: return 7;
292                 case LDKSemanticError_InvalidSignature: return 8;
293                 case LDKSemanticError_ImpreciseAmount: return 9;
294                 default: abort();
295         }
296 }
297 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
298         switch (ord) {
299                 case 0: return LDKSiPrefix_Milli;
300                 case 1: return LDKSiPrefix_Micro;
301                 case 2: return LDKSiPrefix_Nano;
302                 case 3: return LDKSiPrefix_Pico;
303         }
304         abort();
305 }
306 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
307         switch (val) {
308                 case LDKSiPrefix_Milli: return 0;
309                 case LDKSiPrefix_Micro: return 1;
310                 case LDKSiPrefix_Nano: return 2;
311                 case LDKSiPrefix_Pico: return 3;
312                 default: abort();
313         }
314 }
315 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
316         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
317         ret->datalen = *((uint32_t*)elems);
318         if (ret->datalen == 0) {
319                 ret->data = NULL;
320         } else {
321                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
322                 int8_t *java_elems = (int8_t*)(elems + 4);
323                 for (size_t i = 0; i < ret->datalen; i++) {
324                         ret->data[i] = java_elems[i];
325                 }
326         }
327         return (uint64_t)ret;
328 }
329 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
330         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
331         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
332         return ret;
333 }
334 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) {
335         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
336         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
337         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
338         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
339         CVec_u8Z_free(ret_var);
340         return ret_arr;
341 }
342
343 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}int64_t  __attribute__((visibility("default"))) TS_TxOut_get_value(uint32_t thing) {
344         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
345         int64_t ret_val = TxOut_get_value(thing_conv);
346         return ret_val;
347 }
348
349 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_result_ok(uint32_t arg) {
350         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
351 }
352 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
353         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
354         CHECK(val->result_ok);
355         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
356         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
357         return res_arr;
358 }
359 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
360         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
361         CHECK(!val->result_ok);
362         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
363         return err_conv;
364 }
365 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_result_ok(uint32_t arg) {
366         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
367 }
368 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
369         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
370         CHECK(val->result_ok);
371         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
372         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
373         return res_arr;
374 }
375 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
376         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
377         CHECK(!val->result_ok);
378         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
379         return err_conv;
380 }
381 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_result_ok(uint32_t arg) {
382         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
383 }
384 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
385         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
386         CHECK(val->result_ok);
387         LDKTxCreationKeys res_var = (*val->contents.result);
388         uint64_t res_ref = 0;
389         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
390         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
391         res_ref = (uint64_t)res_var.inner & ~1;
392         return res_ref;
393 }
394 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
395         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
396         CHECK(!val->result_ok);
397         LDKDecodeError err_var = (*val->contents.err);
398         uint64_t err_ref = 0;
399         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
400         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
401         err_ref = (uint64_t)err_var.inner & ~1;
402         return err_ref;
403 }
404 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
405         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
406 }
407 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
408         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
409         CHECK(val->result_ok);
410         LDKChannelPublicKeys res_var = (*val->contents.result);
411         uint64_t res_ref = 0;
412         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
413         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
414         res_ref = (uint64_t)res_var.inner & ~1;
415         return res_ref;
416 }
417 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
418         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
419         CHECK(!val->result_ok);
420         LDKDecodeError err_var = (*val->contents.err);
421         uint64_t err_ref = 0;
422         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
423         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
424         err_ref = (uint64_t)err_var.inner & ~1;
425         return err_ref;
426 }
427 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
428         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
429 }
430 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
431         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
432         CHECK(val->result_ok);
433         LDKTxCreationKeys res_var = (*val->contents.result);
434         uint64_t res_ref = 0;
435         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
436         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
437         res_ref = (uint64_t)res_var.inner & ~1;
438         return res_ref;
439 }
440 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
441         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
442         CHECK(!val->result_ok);
443         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
444         return err_conv;
445 }
446 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u32Z_ref_from_ptr(uint32_t ptr) {
447         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
448         switch(obj->tag) {
449                 case LDKCOption_u32Z_Some: {
450                         return 0 /* LDKCOption_u32Z - Some */; (void) obj->some;
451                 }
452                 case LDKCOption_u32Z_None: {
453                         return 0 /* LDKCOption_u32Z - None */;
454                 }
455                 default: abort();
456         }
457 }
458 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_result_ok(uint32_t arg) {
459         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
460 }
461 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
462         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
463         CHECK(val->result_ok);
464         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
465         uint64_t res_ref = 0;
466         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
467         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
468         res_ref = (uint64_t)res_var.inner & ~1;
469         return res_ref;
470 }
471 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
472         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
473         CHECK(!val->result_ok);
474         LDKDecodeError err_var = (*val->contents.err);
475         uint64_t err_ref = 0;
476         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
477         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
478         err_ref = (uint64_t)err_var.inner & ~1;
479         return err_ref;
480 }
481 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
482         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
483 }
484 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
485         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
486         CHECK(val->result_ok);
487         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
488         uint64_t res_ref = 0;
489         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
490         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
491         res_ref = (uint64_t)res_var.inner & ~1;
492         return res_ref;
493 }
494 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
495         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
496         CHECK(!val->result_ok);
497         LDKDecodeError err_var = (*val->contents.err);
498         uint64_t err_ref = 0;
499         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
500         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
501         err_ref = (uint64_t)err_var.inner & ~1;
502         return err_ref;
503 }
504 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
505         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
506 }
507 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
508         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
509         CHECK(val->result_ok);
510         LDKChannelTransactionParameters res_var = (*val->contents.result);
511         uint64_t res_ref = 0;
512         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
513         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
514         res_ref = (uint64_t)res_var.inner & ~1;
515         return res_ref;
516 }
517 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
518         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
519         CHECK(!val->result_ok);
520         LDKDecodeError err_var = (*val->contents.err);
521         uint64_t err_ref = 0;
522         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
523         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
524         err_ref = (uint64_t)err_var.inner & ~1;
525         return err_ref;
526 }
527 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
528         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
529 }
530 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
531         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
532         CHECK(val->result_ok);
533         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
534         uint64_t res_ref = 0;
535         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
536         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
537         res_ref = (uint64_t)res_var.inner & ~1;
538         return res_ref;
539 }
540 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
541         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
542         CHECK(!val->result_ok);
543         LDKDecodeError err_var = (*val->contents.err);
544         uint64_t err_ref = 0;
545         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
546         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
547         err_ref = (uint64_t)err_var.inner & ~1;
548         return err_ref;
549 }
550 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
551         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
552 }
553 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
554         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
555         CHECK(val->result_ok);
556         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
557         uint64_t res_ref = 0;
558         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
559         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
560         res_ref = (uint64_t)res_var.inner & ~1;
561         return res_ref;
562 }
563 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
564         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
565         CHECK(!val->result_ok);
566         LDKDecodeError err_var = (*val->contents.err);
567         uint64_t err_ref = 0;
568         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
569         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
570         err_ref = (uint64_t)err_var.inner & ~1;
571         return err_ref;
572 }
573 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_result_ok(uint32_t arg) {
574         return ((LDKCResult_TrustedClosingTransactionNoneZ*)arg)->result_ok;
575 }
576 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t arg) {
577         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
578         CHECK(val->result_ok);
579         LDKTrustedClosingTransaction res_var = (*val->contents.result);
580         uint64_t res_ref = 0;
581         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
582         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
583         res_ref = (uint64_t)res_var.inner & ~1;
584         return res_ref;
585 }
586 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_err(uint32_t arg) {
587         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
588         CHECK(!val->result_ok);
589         return *val->contents.err;
590 }
591 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
592         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
593 }
594 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
595         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
596         CHECK(val->result_ok);
597         LDKCommitmentTransaction res_var = (*val->contents.result);
598         uint64_t res_ref = 0;
599         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
600         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
601         res_ref = (uint64_t)res_var.inner & ~1;
602         return res_ref;
603 }
604 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
605         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
606         CHECK(!val->result_ok);
607         LDKDecodeError err_var = (*val->contents.err);
608         uint64_t err_ref = 0;
609         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
610         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
611         err_ref = (uint64_t)err_var.inner & ~1;
612         return err_ref;
613 }
614 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
615         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
616 }
617 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
618         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
619         CHECK(val->result_ok);
620         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
621         uint64_t res_ref = 0;
622         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
623         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
624         res_ref = (uint64_t)res_var.inner & ~1;
625         return res_ref;
626 }
627 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
628         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
629         CHECK(!val->result_ok);
630         return *val->contents.err;
631 }
632 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
633         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
634 }
635 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
636         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
637         CHECK(val->result_ok);
638         LDKCVec_SignatureZ res_var = (*val->contents.result);
639         ptrArray res_arr = NULL;
640         res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
641         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
642         for (size_t m = 0; m < res_var.datalen; m++) {
643                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
644                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
645                 res_arr_ptr[m] = res_conv_12_arr;
646         }
647         
648         return res_arr;
649 }
650 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
651         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
652         CHECK(!val->result_ok);
653         return *val->contents.err;
654 }
655 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_result_ok(uint32_t arg) {
656         return ((LDKCResult_ShutdownScriptDecodeErrorZ*)arg)->result_ok;
657 }
658 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t arg) {
659         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
660         CHECK(val->result_ok);
661         LDKShutdownScript res_var = (*val->contents.result);
662         uint64_t res_ref = 0;
663         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
664         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
665         res_ref = (uint64_t)res_var.inner & ~1;
666         return res_ref;
667 }
668 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t arg) {
669         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
670         CHECK(!val->result_ok);
671         LDKDecodeError err_var = (*val->contents.err);
672         uint64_t err_ref = 0;
673         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
674         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
675         err_ref = (uint64_t)err_var.inner & ~1;
676         return err_ref;
677 }
678 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_result_ok(uint32_t arg) {
679         return ((LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)arg)->result_ok;
680 }
681 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t arg) {
682         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
683         CHECK(val->result_ok);
684         LDKShutdownScript res_var = (*val->contents.result);
685         uint64_t res_ref = 0;
686         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
687         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
688         res_ref = (uint64_t)res_var.inner & ~1;
689         return res_ref;
690 }
691 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t arg) {
692         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
693         CHECK(!val->result_ok);
694         LDKInvalidShutdownScript err_var = (*val->contents.err);
695         uint64_t err_ref = 0;
696         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
697         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
698         err_ref = (uint64_t)err_var.inner & ~1;
699         return err_ref;
700 }
701 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_result_ok(uint32_t arg) {
702         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
703 }
704 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_ok(uint32_t arg) {
705         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
706         CHECK(val->result_ok);
707         return *val->contents.result;
708 }
709 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_err(uint32_t arg) {
710         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
711         CHECK(!val->result_ok);
712         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
713         return err_conv;
714 }
715 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_result_ok(uint32_t arg) {
716         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
717 }
718 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_ok(uint32_t arg) {
719         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
720         CHECK(val->result_ok);
721         LDKRouteHop res_var = (*val->contents.result);
722         uint64_t res_ref = 0;
723         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
724         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
725         res_ref = (uint64_t)res_var.inner & ~1;
726         return res_ref;
727 }
728 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_err(uint32_t arg) {
729         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
730         CHECK(!val->result_ok);
731         LDKDecodeError err_var = (*val->contents.err);
732         uint64_t err_ref = 0;
733         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
734         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
735         err_ref = (uint64_t)err_var.inner & ~1;
736         return err_ref;
737 }
738 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
739         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
740         ret->datalen = *((uint32_t*)elems);
741         if (ret->datalen == 0) {
742                 ret->data = NULL;
743         } else {
744                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
745                 uint32_t *java_elems = (uint32_t*)(elems + 4);
746                 for (size_t i = 0; i < ret->datalen; i++) {
747                         uint32_t arr_elem = java_elems[i];
748                         LDKRouteHop arr_elem_conv;
749                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
750                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
751                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
752                         ret->data[i] = arr_elem_conv;
753                 }
754         }
755         return (uint64_t)ret;
756 }
757 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
758         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
759         for (size_t i = 0; i < ret.datalen; i++) {
760                 ret.data[i] = RouteHop_clone(&orig->data[i]);
761         }
762         return ret;
763 }
764 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
765         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
766         for (size_t i = 0; i < ret.datalen; i++) {
767                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
768         }
769         return ret;
770 }
771 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
772         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
773 }
774 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
775         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
776         CHECK(val->result_ok);
777         LDKRoute res_var = (*val->contents.result);
778         uint64_t res_ref = 0;
779         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
780         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
781         res_ref = (uint64_t)res_var.inner & ~1;
782         return res_ref;
783 }
784 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
785         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
786         CHECK(!val->result_ok);
787         LDKDecodeError err_var = (*val->contents.err);
788         uint64_t err_ref = 0;
789         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
790         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
791         err_ref = (uint64_t)err_var.inner & ~1;
792         return err_ref;
793 }
794 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_result_ok(uint32_t arg) {
795         return ((LDKCResult_RouteParametersDecodeErrorZ*)arg)->result_ok;
796 }
797 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_get_ok(uint32_t arg) {
798         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
799         CHECK(val->result_ok);
800         LDKRouteParameters res_var = (*val->contents.result);
801         uint64_t res_ref = 0;
802         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
803         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
804         res_ref = (uint64_t)res_var.inner & ~1;
805         return res_ref;
806 }
807 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_get_err(uint32_t arg) {
808         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
809         CHECK(!val->result_ok);
810         LDKDecodeError err_var = (*val->contents.err);
811         uint64_t err_ref = 0;
812         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
813         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
814         err_ref = (uint64_t)err_var.inner & ~1;
815         return err_ref;
816 }
817 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
818         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
819         ret->datalen = *((uint32_t*)elems);
820         if (ret->datalen == 0) {
821                 ret->data = NULL;
822         } else {
823                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
824                 uint32_t *java_elems = (uint32_t*)(elems + 4);
825                 for (size_t i = 0; i < ret->datalen; i++) {
826                         uint32_t arr_elem = java_elems[i];
827                         LDKRouteHint arr_elem_conv;
828                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
829                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
830                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
831                         ret->data[i] = arr_elem_conv;
832                 }
833         }
834         return (uint64_t)ret;
835 }
836 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
837         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
838         for (size_t i = 0; i < ret.datalen; i++) {
839                 ret.data[i] = RouteHint_clone(&orig->data[i]);
840         }
841         return ret;
842 }
843 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
844         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
845         switch(obj->tag) {
846                 case LDKCOption_u64Z_Some: {
847                         return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
848                 }
849                 case LDKCOption_u64Z_None: {
850                         return 0 /* LDKCOption_u64Z - None */;
851                 }
852                 default: abort();
853         }
854 }
855 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_result_ok(uint32_t arg) {
856         return ((LDKCResult_PayeeDecodeErrorZ*)arg)->result_ok;
857 }
858 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_get_ok(uint32_t arg) {
859         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
860         CHECK(val->result_ok);
861         LDKPayee res_var = (*val->contents.result);
862         uint64_t res_ref = 0;
863         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
864         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
865         res_ref = (uint64_t)res_var.inner & ~1;
866         return res_ref;
867 }
868 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_get_err(uint32_t arg) {
869         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
870         CHECK(!val->result_ok);
871         LDKDecodeError err_var = (*val->contents.err);
872         uint64_t err_ref = 0;
873         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
874         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
875         err_ref = (uint64_t)err_var.inner & ~1;
876         return err_ref;
877 }
878 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintHopZ_new(uint32_tArray elems) {
879         LDKCVec_RouteHintHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHintHopZ), "LDKCVec_RouteHintHopZ");
880         ret->datalen = *((uint32_t*)elems);
881         if (ret->datalen == 0) {
882                 ret->data = NULL;
883         } else {
884                 ret->data = MALLOC(sizeof(LDKRouteHintHop) * ret->datalen, "LDKCVec_RouteHintHopZ Data");
885                 uint32_t *java_elems = (uint32_t*)(elems + 4);
886                 for (size_t i = 0; i < ret->datalen; i++) {
887                         uint32_t arr_elem = java_elems[i];
888                         LDKRouteHintHop arr_elem_conv;
889                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
890                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
891                         arr_elem_conv = RouteHintHop_clone(&arr_elem_conv);
892                         ret->data[i] = arr_elem_conv;
893                 }
894         }
895         return (uint64_t)ret;
896 }
897 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
898         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
899         for (size_t i = 0; i < ret.datalen; i++) {
900                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
901         }
902         return ret;
903 }
904 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_result_ok(uint32_t arg) {
905         return ((LDKCResult_RouteHintDecodeErrorZ*)arg)->result_ok;
906 }
907 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_get_ok(uint32_t arg) {
908         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
909         CHECK(val->result_ok);
910         LDKRouteHint res_var = (*val->contents.result);
911         uint64_t res_ref = 0;
912         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
913         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
914         res_ref = (uint64_t)res_var.inner & ~1;
915         return res_ref;
916 }
917 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_get_err(uint32_t arg) {
918         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
919         CHECK(!val->result_ok);
920         LDKDecodeError err_var = (*val->contents.err);
921         uint64_t err_ref = 0;
922         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
923         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
924         err_ref = (uint64_t)err_var.inner & ~1;
925         return err_ref;
926 }
927 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_result_ok(uint32_t arg) {
928         return ((LDKCResult_RouteHintHopDecodeErrorZ*)arg)->result_ok;
929 }
930 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t arg) {
931         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
932         CHECK(val->result_ok);
933         LDKRouteHintHop res_var = (*val->contents.result);
934         uint64_t res_ref = 0;
935         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
936         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
937         res_ref = (uint64_t)res_var.inner & ~1;
938         return res_ref;
939 }
940 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_get_err(uint32_t arg) {
941         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
942         CHECK(!val->result_ok);
943         LDKDecodeError err_var = (*val->contents.err);
944         uint64_t err_ref = 0;
945         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
946         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
947         err_ref = (uint64_t)err_var.inner & ~1;
948         return err_ref;
949 }
950 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
951         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
952         ret->datalen = *((uint32_t*)elems);
953         if (ret->datalen == 0) {
954                 ret->data = NULL;
955         } else {
956                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
957                 uint32_t *java_elems = (uint32_t*)(elems + 4);
958                 for (size_t i = 0; i < ret->datalen; i++) {
959                         uint32_t arr_elem = java_elems[i];
960                         LDKChannelDetails arr_elem_conv;
961                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
962                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
963                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
964                         ret->data[i] = arr_elem_conv;
965                 }
966         }
967         return (uint64_t)ret;
968 }
969 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
970         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
971         for (size_t i = 0; i < ret.datalen; i++) {
972                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
973         }
974         return ret;
975 }
976 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
977         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
978 }
979 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
980         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
981         CHECK(val->result_ok);
982         LDKRoute res_var = (*val->contents.result);
983         uint64_t res_ref = 0;
984         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
985         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
986         res_ref = (uint64_t)res_var.inner & ~1;
987         return res_ref;
988 }
989 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
990         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
991         CHECK(!val->result_ok);
992         LDKLightningError err_var = (*val->contents.err);
993         uint64_t err_ref = 0;
994         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
995         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
996         err_ref = (uint64_t)err_var.inner & ~1;
997         return err_ref;
998 }
999 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
1000         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1001 }
1002 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
1003         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1004         CHECK(val->result_ok);
1005         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1006         return (uint64_t)res_ref;
1007 }
1008 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
1009         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1010         CHECK(!val->result_ok);
1011         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
1012         return err_conv;
1013 }
1014 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1015         return tuple->a;
1016 }
1017 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t tuple) {
1018         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1019         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(tuple_conv);
1020         return ret_val;
1021 }
1022
1023 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1024         return tuple->b;
1025 }
1026 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t tuple) {
1027         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1028         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(tuple_conv);
1029         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1030         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
1031         Transaction_free(ret_var);
1032         return ret_arr;
1033 }
1034
1035 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
1036         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1037         ret->datalen = *((uint32_t*)elems);
1038         if (ret->datalen == 0) {
1039                 ret->data = NULL;
1040         } else {
1041                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1042                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1043                 for (size_t i = 0; i < ret->datalen; i++) {
1044                         uint32_t arr_elem = java_elems[i];
1045                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
1046                         CHECK_ACCESS(arr_elem_ptr);
1047                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(arr_elem_ptr);
1048                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1049                         ret->data[i] = arr_elem_conv;
1050                 }
1051         }
1052         return (uint64_t)ret;
1053 }
1054 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1055         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1056         for (size_t i = 0; i < ret.datalen; i++) {
1057                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1058         }
1059         return ret;
1060 }
1061 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1062         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1063         for (size_t i = 0; i < ret.datalen; i++) {
1064                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1065         }
1066         return ret;
1067 }
1068 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
1069         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1070 }
1071 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
1072         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1073         CHECK(val->result_ok);
1074         return *val->contents.result;
1075 }
1076 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
1077         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1078         CHECK(!val->result_ok);
1079         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
1080         return err_conv;
1081 }
1082 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
1083         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1084         switch(obj->tag) {
1085                 case LDKMonitorEvent_HTLCEvent: {
1086                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1087                         uint64_t htlc_event_ref = 0;
1088                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1089                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1090                         htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1091                         return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
1092                 }
1093                 case LDKMonitorEvent_CommitmentTxConfirmed: {
1094                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1095                         uint64_t commitment_tx_confirmed_ref = 0;
1096                         CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1097                         CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1098                         commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
1099                         return 0 /* LDKMonitorEvent - CommitmentTxConfirmed */; (void) commitment_tx_confirmed_ref;
1100                 }
1101                 case LDKMonitorEvent_UpdateCompleted: {
1102                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1103                         uint64_t funding_txo_ref = 0;
1104                         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1105                         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1106                         funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
1107                         return 0 /* LDKMonitorEvent - UpdateCompleted */; (void) funding_txo_ref; (void) obj->update_completed.monitor_update_id;
1108                 }
1109                 case LDKMonitorEvent_UpdateFailed: {
1110                         LDKOutPoint update_failed_var = obj->update_failed;
1111                         uint64_t update_failed_ref = 0;
1112                         CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1113                         CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1114                         update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
1115                         return 0 /* LDKMonitorEvent - UpdateFailed */; (void) update_failed_ref;
1116                 }
1117                 default: abort();
1118         }
1119 }
1120 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
1121         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1122         ret->datalen = *((uint32_t*)elems);
1123         if (ret->datalen == 0) {
1124                 ret->data = NULL;
1125         } else {
1126                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1127                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1128                 for (size_t i = 0; i < ret->datalen; i++) {
1129                         uint32_t arr_elem = java_elems[i];
1130                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
1131                         CHECK_ACCESS(arr_elem_ptr);
1132                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(arr_elem_ptr);
1133                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1134                         ret->data[i] = arr_elem_conv;
1135                 }
1136         }
1137         return (uint64_t)ret;
1138 }
1139 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1140         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1141         for (size_t i = 0; i < ret.datalen; i++) {
1142                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1143         }
1144         return ret;
1145 }
1146 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(uint32_t ptr) {
1147         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1148         switch(obj->tag) {
1149                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1150                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1151                         *some_conv = obj->some;
1152                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1153                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - Some */; (void) ((uint64_t)some_conv);
1154                 }
1155                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1156                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - None */;
1157                 }
1158                 default: abort();
1159         }
1160 }
1161 uint32_t __attribute__((visibility("default"))) TS_LDKNetworkUpdate_ref_from_ptr(uint32_t ptr) {
1162         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1163         switch(obj->tag) {
1164                 case LDKNetworkUpdate_ChannelUpdateMessage: {
1165                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1166                         uint64_t msg_ref = 0;
1167                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1168                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1169                         msg_ref = (uint64_t)msg_var.inner & ~1;
1170                         return 0 /* LDKNetworkUpdate - ChannelUpdateMessage */; (void) msg_ref;
1171                 }
1172                 case LDKNetworkUpdate_ChannelClosed: {
1173                         return 0 /* LDKNetworkUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
1174                 }
1175                 case LDKNetworkUpdate_NodeFailure: {
1176                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1177                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
1178                         return 0 /* LDKNetworkUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
1179                 }
1180                 default: abort();
1181         }
1182 }
1183 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_NetworkUpdateZ_ref_from_ptr(uint32_t ptr) {
1184         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1185         switch(obj->tag) {
1186                 case LDKCOption_NetworkUpdateZ_Some: {
1187                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1188                         return 0 /* LDKCOption_NetworkUpdateZ - Some */; (void) some_ref;
1189                 }
1190                 case LDKCOption_NetworkUpdateZ_None: {
1191                         return 0 /* LDKCOption_NetworkUpdateZ - None */;
1192                 }
1193                 default: abort();
1194         }
1195 }
1196 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
1197         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1198         switch(obj->tag) {
1199                 case LDKSpendableOutputDescriptor_StaticOutput: {
1200                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1201                         uint64_t outpoint_ref = 0;
1202                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1203                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1204                         outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1205                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1206                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
1207                 }
1208                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1209                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1210                         uint64_t delayed_payment_output_ref = 0;
1211                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1212                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1213                         delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1214                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
1215                 }
1216                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1217                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1218                         uint64_t static_payment_output_ref = 0;
1219                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1220                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1221                         static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1222                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
1223                 }
1224                 default: abort();
1225         }
1226 }
1227 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
1228         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1229         ret->datalen = *((uint32_t*)elems);
1230         if (ret->datalen == 0) {
1231                 ret->data = NULL;
1232         } else {
1233                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1234                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1235                 for (size_t i = 0; i < ret->datalen; i++) {
1236                         uint32_t arr_elem = java_elems[i];
1237                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
1238                         CHECK_ACCESS(arr_elem_ptr);
1239                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(arr_elem_ptr);
1240                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1241                         ret->data[i] = arr_elem_conv;
1242                 }
1243         }
1244         return (uint64_t)ret;
1245 }
1246 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1247         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1248         for (size_t i = 0; i < ret.datalen; i++) {
1249                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1250         }
1251         return ret;
1252 }
1253 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
1254         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1255         switch(obj->tag) {
1256                 case LDKErrorAction_DisconnectPeer: {
1257                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1258                         uint64_t msg_ref = 0;
1259                         if ((uint64_t)msg_var.inner > 4096) {
1260                                 CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1261                                 CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1262                                 msg_ref = (uint64_t)msg_var.inner & ~1;
1263                         }
1264                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
1265                 }
1266                 case LDKErrorAction_IgnoreError: {
1267                         return 0 /* LDKErrorAction - IgnoreError */;
1268                 }
1269                 case LDKErrorAction_IgnoreAndLog: {
1270                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1271                         return 0 /* LDKErrorAction - IgnoreAndLog */; (void) ignore_and_log_conv;
1272                 }
1273                 case LDKErrorAction_SendErrorMessage: {
1274                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1275                         uint64_t msg_ref = 0;
1276                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1277                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1278                         msg_ref = (uint64_t)msg_var.inner & ~1;
1279                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
1280                 }
1281                 default: abort();
1282         }
1283 }
1284 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
1285         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1286         switch(obj->tag) {
1287                 case LDKMessageSendEvent_SendAcceptChannel: {
1288                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1289                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
1290                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1291                         uint64_t msg_ref = 0;
1292                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1293                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1294                         msg_ref = (uint64_t)msg_var.inner & ~1;
1295                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
1296                 }
1297                 case LDKMessageSendEvent_SendOpenChannel: {
1298                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1299                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
1300                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1301                         uint64_t msg_ref = 0;
1302                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1303                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1304                         msg_ref = (uint64_t)msg_var.inner & ~1;
1305                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
1306                 }
1307                 case LDKMessageSendEvent_SendFundingCreated: {
1308                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1309                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
1310                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1311                         uint64_t msg_ref = 0;
1312                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1313                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1314                         msg_ref = (uint64_t)msg_var.inner & ~1;
1315                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
1316                 }
1317                 case LDKMessageSendEvent_SendFundingSigned: {
1318                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1319                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
1320                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1321                         uint64_t msg_ref = 0;
1322                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1323                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1324                         msg_ref = (uint64_t)msg_var.inner & ~1;
1325                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
1326                 }
1327                 case LDKMessageSendEvent_SendFundingLocked: {
1328                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1329                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
1330                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1331                         uint64_t msg_ref = 0;
1332                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1333                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1334                         msg_ref = (uint64_t)msg_var.inner & ~1;
1335                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
1336                 }
1337                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1338                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1339                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
1340                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1341                         uint64_t msg_ref = 0;
1342                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1343                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1344                         msg_ref = (uint64_t)msg_var.inner & ~1;
1345                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
1346                 }
1347                 case LDKMessageSendEvent_UpdateHTLCs: {
1348                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1349                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
1350                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1351                         uint64_t updates_ref = 0;
1352                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1353                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1354                         updates_ref = (uint64_t)updates_var.inner & ~1;
1355                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
1356                 }
1357                 case LDKMessageSendEvent_SendRevokeAndACK: {
1358                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1359                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
1360                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1361                         uint64_t msg_ref = 0;
1362                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1363                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1364                         msg_ref = (uint64_t)msg_var.inner & ~1;
1365                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
1366                 }
1367                 case LDKMessageSendEvent_SendClosingSigned: {
1368                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1369                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
1370                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1371                         uint64_t msg_ref = 0;
1372                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1373                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1374                         msg_ref = (uint64_t)msg_var.inner & ~1;
1375                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
1376                 }
1377                 case LDKMessageSendEvent_SendShutdown: {
1378                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1379                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
1380                         LDKShutdown msg_var = obj->send_shutdown.msg;
1381                         uint64_t msg_ref = 0;
1382                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1383                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1384                         msg_ref = (uint64_t)msg_var.inner & ~1;
1385                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
1386                 }
1387                 case LDKMessageSendEvent_SendChannelReestablish: {
1388                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1389                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
1390                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1391                         uint64_t msg_ref = 0;
1392                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1393                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1394                         msg_ref = (uint64_t)msg_var.inner & ~1;
1395                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
1396                 }
1397                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1398                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1399                         uint64_t msg_ref = 0;
1400                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1401                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1402                         msg_ref = (uint64_t)msg_var.inner & ~1;
1403                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1404                         uint64_t update_msg_ref = 0;
1405                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1406                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1407                         update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1408                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
1409                 }
1410                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1411                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1412                         uint64_t msg_ref = 0;
1413                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1414                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1415                         msg_ref = (uint64_t)msg_var.inner & ~1;
1416                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
1417                 }
1418                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1419                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1420                         uint64_t msg_ref = 0;
1421                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1422                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1423                         msg_ref = (uint64_t)msg_var.inner & ~1;
1424                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
1425                 }
1426                 case LDKMessageSendEvent_SendChannelUpdate: {
1427                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1428                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_update.node_id.compressed_form, 33);
1429                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1430                         uint64_t msg_ref = 0;
1431                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1432                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1433                         msg_ref = (uint64_t)msg_var.inner & ~1;
1434                         return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref;
1435                 }
1436                 case LDKMessageSendEvent_HandleError: {
1437                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1438                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
1439                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1440                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
1441                 }
1442                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1443                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1444                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
1445                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1446                         uint64_t msg_ref = 0;
1447                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1448                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1449                         msg_ref = (uint64_t)msg_var.inner & ~1;
1450                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
1451                 }
1452                 case LDKMessageSendEvent_SendShortIdsQuery: {
1453                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1454                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
1455                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1456                         uint64_t msg_ref = 0;
1457                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1458                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1459                         msg_ref = (uint64_t)msg_var.inner & ~1;
1460                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
1461                 }
1462                 case LDKMessageSendEvent_SendReplyChannelRange: {
1463                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1464                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
1465                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1466                         uint64_t msg_ref = 0;
1467                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1468                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1469                         msg_ref = (uint64_t)msg_var.inner & ~1;
1470                         return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
1471                 }
1472                 default: abort();
1473         }
1474 }
1475 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
1476         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1477         ret->datalen = *((uint32_t*)elems);
1478         if (ret->datalen == 0) {
1479                 ret->data = NULL;
1480         } else {
1481                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1482                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1483                 for (size_t i = 0; i < ret->datalen; i++) {
1484                         uint32_t arr_elem = java_elems[i];
1485                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
1486                         CHECK_ACCESS(arr_elem_ptr);
1487                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(arr_elem_ptr);
1488                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1489                         ret->data[i] = arr_elem_conv;
1490                 }
1491         }
1492         return (uint64_t)ret;
1493 }
1494 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1495         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1496         for (size_t i = 0; i < ret.datalen; i++) {
1497                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1498         }
1499         return ret;
1500 }
1501 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1502         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1503 }
1504 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1505         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1506         CHECK(val->result_ok);
1507         LDKInitFeatures res_var = (*val->contents.result);
1508         uint64_t res_ref = 0;
1509         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1510         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1511         res_ref = (uint64_t)res_var.inner & ~1;
1512         return res_ref;
1513 }
1514 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1515         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1516         CHECK(!val->result_ok);
1517         LDKDecodeError err_var = (*val->contents.err);
1518         uint64_t err_ref = 0;
1519         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1520         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1521         err_ref = (uint64_t)err_var.inner & ~1;
1522         return err_ref;
1523 }
1524 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1525         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1526 }
1527 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1528         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1529         CHECK(val->result_ok);
1530         LDKNodeFeatures res_var = (*val->contents.result);
1531         uint64_t res_ref = 0;
1532         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1533         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1534         res_ref = (uint64_t)res_var.inner & ~1;
1535         return res_ref;
1536 }
1537 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1538         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1539         CHECK(!val->result_ok);
1540         LDKDecodeError err_var = (*val->contents.err);
1541         uint64_t err_ref = 0;
1542         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1543         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1544         err_ref = (uint64_t)err_var.inner & ~1;
1545         return err_ref;
1546 }
1547 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1548         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1549 }
1550 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1551         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1552         CHECK(val->result_ok);
1553         LDKChannelFeatures res_var = (*val->contents.result);
1554         uint64_t res_ref = 0;
1555         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1556         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1557         res_ref = (uint64_t)res_var.inner & ~1;
1558         return res_ref;
1559 }
1560 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1561         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1562         CHECK(!val->result_ok);
1563         LDKDecodeError err_var = (*val->contents.err);
1564         uint64_t err_ref = 0;
1565         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1566         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1567         err_ref = (uint64_t)err_var.inner & ~1;
1568         return err_ref;
1569 }
1570 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1571         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1572 }
1573 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1574         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1575         CHECK(val->result_ok);
1576         LDKInvoiceFeatures res_var = (*val->contents.result);
1577         uint64_t res_ref = 0;
1578         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1579         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1580         res_ref = (uint64_t)res_var.inner & ~1;
1581         return res_ref;
1582 }
1583 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1584         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1585         CHECK(!val->result_ok);
1586         LDKDecodeError err_var = (*val->contents.err);
1587         uint64_t err_ref = 0;
1588         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1589         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1590         err_ref = (uint64_t)err_var.inner & ~1;
1591         return err_ref;
1592 }
1593 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_result_ok(uint32_t arg) {
1594         return ((LDKCResult_ScoringParametersDecodeErrorZ*)arg)->result_ok;
1595 }
1596 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t arg) {
1597         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
1598         CHECK(val->result_ok);
1599         LDKScoringParameters res_var = (*val->contents.result);
1600         uint64_t res_ref = 0;
1601         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1602         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1603         res_ref = (uint64_t)res_var.inner & ~1;
1604         return res_ref;
1605 }
1606 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_get_err(uint32_t arg) {
1607         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
1608         CHECK(!val->result_ok);
1609         LDKDecodeError err_var = (*val->contents.err);
1610         uint64_t err_ref = 0;
1611         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1612         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1613         err_ref = (uint64_t)err_var.inner & ~1;
1614         return err_ref;
1615 }
1616 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_result_ok(uint32_t arg) {
1617         return ((LDKCResult_ScorerDecodeErrorZ*)arg)->result_ok;
1618 }
1619 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_get_ok(uint32_t arg) {
1620         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
1621         CHECK(val->result_ok);
1622         LDKScorer res_var = (*val->contents.result);
1623         uint64_t res_ref = 0;
1624         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1625         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1626         res_ref = (uint64_t)res_var.inner & ~1;
1627         return res_ref;
1628 }
1629 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_get_err(uint32_t arg) {
1630         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
1631         CHECK(!val->result_ok);
1632         LDKDecodeError err_var = (*val->contents.err);
1633         uint64_t err_ref = 0;
1634         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1635         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1636         err_ref = (uint64_t)err_var.inner & ~1;
1637         return err_ref;
1638 }
1639 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1640         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1641 }
1642 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1643         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1644         CHECK(val->result_ok);
1645         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1646         uint64_t res_ref = 0;
1647         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1648         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1649         res_ref = (uint64_t)res_var.inner & ~1;
1650         return res_ref;
1651 }
1652 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1653         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1654         CHECK(!val->result_ok);
1655         LDKDecodeError err_var = (*val->contents.err);
1656         uint64_t err_ref = 0;
1657         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1658         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1659         err_ref = (uint64_t)err_var.inner & ~1;
1660         return err_ref;
1661 }
1662 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1663         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1664 }
1665 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1666         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1667         CHECK(val->result_ok);
1668         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1669         uint64_t res_ref = 0;
1670         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1671         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1672         res_ref = (uint64_t)res_var.inner & ~1;
1673         return res_ref;
1674 }
1675 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1676         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1677         CHECK(!val->result_ok);
1678         LDKDecodeError err_var = (*val->contents.err);
1679         uint64_t err_ref = 0;
1680         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1681         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1682         err_ref = (uint64_t)err_var.inner & ~1;
1683         return err_ref;
1684 }
1685 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1686         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1687 }
1688 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1689         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1690         CHECK(val->result_ok);
1691         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1692         return res_ref;
1693 }
1694 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1695         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1696         CHECK(!val->result_ok);
1697         LDKDecodeError err_var = (*val->contents.err);
1698         uint64_t err_ref = 0;
1699         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1700         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1701         err_ref = (uint64_t)err_var.inner & ~1;
1702         return err_ref;
1703 }
1704 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_result_ok(uint32_t arg) {
1705         return ((LDKCResult_NoneNoneZ*)arg)->result_ok;
1706 }
1707 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_ok(uint32_t arg) {
1708         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
1709         CHECK(val->result_ok);
1710         return *val->contents.result;
1711 }
1712 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_err(uint32_t arg) {
1713         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
1714         CHECK(!val->result_ok);
1715         return *val->contents.err;
1716 }
1717 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
1718         return tuple->a;
1719 }
1720 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t tuple) {
1721         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
1722         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1723         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_SignatureCVec_SignatureZZ_get_a(tuple_conv).compact_form, 64);
1724         return ret_arr;
1725 }
1726
1727 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
1728         return tuple->b;
1729 }
1730 ptrArray  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t tuple) {
1731         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
1732         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
1733         ptrArray ret_arr = NULL;
1734         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1735         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
1736         for (size_t m = 0; m < ret_var.datalen; m++) {
1737                 int8_tArray ret_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1738                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compact_form, 64);
1739                 ret_arr_ptr[m] = ret_conv_12_arr;
1740         }
1741         
1742         FREE(ret_var.data);
1743         return ret_arr;
1744 }
1745
1746 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
1747         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1748 }
1749 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1750         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1751         CHECK(val->result_ok);
1752         LDKC2Tuple_SignatureCVec_SignatureZZ* res_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1753         *res_conv = (*val->contents.result);
1754         *res_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(res_conv);
1755         return ((uint64_t)res_conv);
1756 }
1757 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1758         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1759         CHECK(!val->result_ok);
1760         return *val->contents.err;
1761 }
1762 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
1763         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1764 }
1765 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1766         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1767         CHECK(val->result_ok);
1768         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1769         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1770         return res_arr;
1771 }
1772 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1773         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1774         CHECK(!val->result_ok);
1775         return *val->contents.err;
1776 }
1777 typedef struct LDKBaseSign_JCalls {
1778         atomic_size_t refcnt;
1779         uint32_t get_per_commitment_point_meth;
1780         uint32_t release_commitment_secret_meth;
1781         uint32_t validate_holder_commitment_meth;
1782         uint32_t channel_keys_id_meth;
1783         uint32_t sign_counterparty_commitment_meth;
1784         uint32_t validate_counterparty_revocation_meth;
1785         uint32_t sign_holder_commitment_and_htlcs_meth;
1786         uint32_t sign_justice_revoked_output_meth;
1787         uint32_t sign_justice_revoked_htlc_meth;
1788         uint32_t sign_counterparty_htlc_transaction_meth;
1789         uint32_t sign_closing_transaction_meth;
1790         uint32_t sign_channel_announcement_meth;
1791         uint32_t ready_channel_meth;
1792 } LDKBaseSign_JCalls;
1793 static void LDKBaseSign_JCalls_free(void* this_arg) {
1794         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1795         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1796                 js_free(j_calls->get_per_commitment_point_meth);
1797                 js_free(j_calls->release_commitment_secret_meth);
1798                 js_free(j_calls->validate_holder_commitment_meth);
1799                 js_free(j_calls->channel_keys_id_meth);
1800                 js_free(j_calls->sign_counterparty_commitment_meth);
1801                 js_free(j_calls->validate_counterparty_revocation_meth);
1802                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1803                 js_free(j_calls->sign_justice_revoked_output_meth);
1804                 js_free(j_calls->sign_justice_revoked_htlc_meth);
1805                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1806                 js_free(j_calls->sign_closing_transaction_meth);
1807                 js_free(j_calls->sign_channel_announcement_meth);
1808                 js_free(j_calls->ready_channel_meth);
1809                 FREE(j_calls);
1810         }
1811 }
1812 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1813         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1814         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1815         LDKPublicKey ret_ref;
1816         CHECK(*((uint32_t*)ret) == 33);
1817         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1818         return ret_ref;
1819 }
1820 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1821         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1822         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1823         LDKThirtyTwoBytes ret_ref;
1824         CHECK(*((uint32_t*)ret) == 32);
1825         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1826         return ret_ref;
1827 }
1828 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
1829         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1830         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
1831         uint64_t holder_tx_ref = 0;
1832         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
1833         CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1834         CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1835         holder_tx_ref = (uint64_t)holder_tx_var.inner;
1836         if (holder_tx_var.is_owned) {
1837                 holder_tx_ref |= 1;
1838         }
1839         uint32_t ret = js_invoke_function_1(j_calls->validate_holder_commitment_meth, holder_tx_ref);
1840         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1841         CHECK_ACCESS(ret_ptr);
1842         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1843         ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
1844         return ret_conv;
1845 }
1846 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1847         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1848         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1849         LDKThirtyTwoBytes ret_ref;
1850         CHECK(*((uint32_t*)ret) == 32);
1851         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1852         return ret_ref;
1853 }
1854 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1855         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1856         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1857         uint64_t commitment_tx_ref = 0;
1858         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1859         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1860         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1861         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1862         if (commitment_tx_var.is_owned) {
1863                 commitment_tx_ref |= 1;
1864         }
1865         uint32_t ret = js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1866         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1867         CHECK_ACCESS(ret_ptr);
1868         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
1869         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1870         return ret_conv;
1871 }
1872 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
1873         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1874         int8_tArray secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1875         memcpy((uint8_t*)(secret_arr + 4), *secret, 32);
1876         uint32_t ret = js_invoke_function_2(j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
1877         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1878         CHECK_ACCESS(ret_ptr);
1879         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1880         ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
1881         return ret_conv;
1882 }
1883 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1884         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1885         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1886         uint64_t commitment_tx_ref = 0;
1887         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1888         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1889         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1890         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1891         if (commitment_tx_var.is_owned) {
1892                 commitment_tx_ref |= 1;
1893         }
1894         uint32_t ret = js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1895         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1896         CHECK_ACCESS(ret_ptr);
1897         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
1898         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1899         return ret_conv;
1900 }
1901 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]) {
1902         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1903         LDKTransaction justice_tx_var = justice_tx;
1904         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1905         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1906         Transaction_free(justice_tx_var);
1907         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1908         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1909         uint32_t ret = js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
1910         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1911         CHECK_ACCESS(ret_ptr);
1912         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
1913         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1914         return ret_conv;
1915 }
1916 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) {
1917         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1918         LDKTransaction justice_tx_var = justice_tx;
1919         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1920         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1921         Transaction_free(justice_tx_var);
1922         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1923         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1924         LDKHTLCOutputInCommitment htlc_var = *htlc;
1925         uint64_t htlc_ref = 0;
1926         htlc_var = HTLCOutputInCommitment_clone(htlc);
1927         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1928         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1929         htlc_ref = (uint64_t)htlc_var.inner;
1930         if (htlc_var.is_owned) {
1931                 htlc_ref |= 1;
1932         }
1933         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);
1934         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1935         CHECK_ACCESS(ret_ptr);
1936         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
1937         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1938         return ret_conv;
1939 }
1940 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) {
1941         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1942         LDKTransaction htlc_tx_var = htlc_tx;
1943         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1944         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1945         Transaction_free(htlc_tx_var);
1946         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1947         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1948         LDKHTLCOutputInCommitment htlc_var = *htlc;
1949         uint64_t htlc_ref = 0;
1950         htlc_var = HTLCOutputInCommitment_clone(htlc);
1951         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1952         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1953         htlc_ref = (uint64_t)htlc_var.inner;
1954         if (htlc_var.is_owned) {
1955                 htlc_ref |= 1;
1956         }
1957         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);
1958         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1959         CHECK_ACCESS(ret_ptr);
1960         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
1961         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1962         return ret_conv;
1963 }
1964 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
1965         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1966         LDKClosingTransaction closing_tx_var = *closing_tx;
1967         uint64_t closing_tx_ref = 0;
1968         closing_tx_var = ClosingTransaction_clone(closing_tx);
1969         CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1970         CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1971         closing_tx_ref = (uint64_t)closing_tx_var.inner;
1972         if (closing_tx_var.is_owned) {
1973                 closing_tx_ref |= 1;
1974         }
1975         uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_ref);
1976         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1977         CHECK_ACCESS(ret_ptr);
1978         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
1979         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1980         return ret_conv;
1981 }
1982 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1983         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1984         LDKUnsignedChannelAnnouncement msg_var = *msg;
1985         uint64_t msg_ref = 0;
1986         msg_var = UnsignedChannelAnnouncement_clone(msg);
1987         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1988         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1989         msg_ref = (uint64_t)msg_var.inner;
1990         if (msg_var.is_owned) {
1991                 msg_ref |= 1;
1992         }
1993         uint32_t ret = js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1994         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1995         CHECK_ACCESS(ret_ptr);
1996         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
1997         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1998         return ret_conv;
1999 }
2000 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2001         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2002         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2003         uint64_t channel_parameters_ref = 0;
2004         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2005         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2006         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2007         channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2008         if (channel_parameters_var.is_owned) {
2009                 channel_parameters_ref |= 1;
2010         }
2011         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
2012 }
2013 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
2014         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
2015         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2016 }
2017 static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
2018         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2019         atomic_init(&calls->refcnt, 1);
2020         //TODO: Assign calls->o from o
2021
2022         LDKChannelPublicKeys pubkeys_conv;
2023         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2024         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2025         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2026
2027         LDKBaseSign ret = {
2028                 .this_arg = (void*) calls,
2029                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2030                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2031                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
2032                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2033                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2034                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
2035                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2036                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2037                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2038                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2039                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2040                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2041                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2042                 .free = LDKBaseSign_JCalls_free,
2043                 .pubkeys = pubkeys_conv,
2044                 .set_pubkeys = NULL,
2045         };
2046         return ret;
2047 }
2048 long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
2049         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2050         *res_ptr = LDKBaseSign_init(o, pubkeys);
2051         return (long)res_ptr;
2052 }
2053 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
2054         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2055         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2056         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2057         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2058         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
2059         return ret_arr;
2060 }
2061
2062 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
2063         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2064         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2065         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2066         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2067         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
2068         return ret_arr;
2069 }
2070
2071 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx) {
2072         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2073         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2074         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2075         LDKHolderCommitmentTransaction holder_tx_conv;
2076         holder_tx_conv.inner = (void*)(holder_tx & (~1));
2077         holder_tx_conv.is_owned = false;
2078         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2079         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
2080         return (uint64_t)ret_conv;
2081 }
2082
2083 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
2084         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2085         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2086         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2087         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2088         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
2089         return ret_arr;
2090 }
2091
2092 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
2093         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2094         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2095         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2096         LDKCommitmentTransaction commitment_tx_conv;
2097         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2098         commitment_tx_conv.is_owned = false;
2099         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2100         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2101         return (uint64_t)ret_conv;
2102 }
2103
2104 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_counterparty_revocation(uint32_t this_arg, int64_t idx, int8_tArray secret) {
2105         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2106         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2107         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2108         unsigned char secret_arr[32];
2109         CHECK(*((uint32_t*)secret) == 32);
2110         memcpy(secret_arr, (uint8_t*)(secret + 4), 32);
2111         unsigned char (*secret_ref)[32] = &secret_arr;
2112         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2113         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
2114         return (uint64_t)ret_conv;
2115 }
2116
2117 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
2118         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2119         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2120         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2121         LDKHolderCommitmentTransaction commitment_tx_conv;
2122         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2123         commitment_tx_conv.is_owned = false;
2124         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2125         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2126         return (uint64_t)ret_conv;
2127 }
2128
2129 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) {
2130         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2131         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2132         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2133         LDKTransaction justice_tx_ref;
2134         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
2135         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2136         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
2137         justice_tx_ref.data_is_owned = true;
2138         unsigned char per_commitment_key_arr[32];
2139         CHECK(*((uint32_t*)per_commitment_key) == 32);
2140         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
2141         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2142         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2143         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2144         return (uint64_t)ret_conv;
2145 }
2146
2147 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) {
2148         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2149         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2150         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2151         LDKTransaction justice_tx_ref;
2152         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
2153         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2154         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
2155         justice_tx_ref.data_is_owned = true;
2156         unsigned char per_commitment_key_arr[32];
2157         CHECK(*((uint32_t*)per_commitment_key) == 32);
2158         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
2159         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2160         LDKHTLCOutputInCommitment htlc_conv;
2161         htlc_conv.inner = (void*)(htlc & (~1));
2162         htlc_conv.is_owned = false;
2163         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2164         *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);
2165         return (uint64_t)ret_conv;
2166 }
2167
2168 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) {
2169         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2170         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2171         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2172         LDKTransaction htlc_tx_ref;
2173         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
2174         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2175         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
2176         htlc_tx_ref.data_is_owned = true;
2177         LDKPublicKey per_commitment_point_ref;
2178         CHECK(*((uint32_t*)per_commitment_point) == 33);
2179         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
2180         LDKHTLCOutputInCommitment htlc_conv;
2181         htlc_conv.inner = (void*)(htlc & (~1));
2182         htlc_conv.is_owned = false;
2183         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2184         *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);
2185         return (uint64_t)ret_conv;
2186 }
2187
2188 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
2189         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2190         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2191         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2192         LDKClosingTransaction closing_tx_conv;
2193         closing_tx_conv.inner = (void*)(closing_tx & (~1));
2194         closing_tx_conv.is_owned = false;
2195         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2196         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
2197         return (uint64_t)ret_conv;
2198 }
2199
2200 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
2201         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2202         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2203         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2204         LDKUnsignedChannelAnnouncement msg_conv;
2205         msg_conv.inner = (void*)(msg & (~1));
2206         msg_conv.is_owned = false;
2207         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2208         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2209         return (uint64_t)ret_conv;
2210 }
2211
2212 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
2213         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2214         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2215         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2216         LDKChannelTransactionParameters channel_parameters_conv;
2217         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2218         channel_parameters_conv.is_owned = false;
2219         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2220 }
2221
2222 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2223         if (this_arg->set_pubkeys != NULL)
2224                 this_arg->set_pubkeys(this_arg);
2225         return this_arg->pubkeys;
2226 }
2227 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
2228         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2229         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2230         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2231         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2232         uint64_t ret_ref = 0;
2233         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2234         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2235         ret_ref = (uint64_t)ret_var.inner;
2236         if (ret_var.is_owned) {
2237                 ret_ref |= 1;
2238         }
2239         return ret_ref;
2240 }
2241
2242 typedef struct LDKSign_JCalls {
2243         atomic_size_t refcnt;
2244         LDKBaseSign_JCalls* BaseSign;
2245         uint32_t write_meth;
2246 } LDKSign_JCalls;
2247 static void LDKSign_JCalls_free(void* this_arg) {
2248         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2249         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2250                 js_free(j_calls->write_meth);
2251                 FREE(j_calls);
2252         }
2253 }
2254 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2255         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2256         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
2257         LDKCVec_u8Z ret_ref;
2258         ret_ref.datalen = *((uint32_t*)ret);
2259         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2260         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2261         return ret_ref;
2262 }
2263 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2264         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2265         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2266         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2267 }
2268 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
2269         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2270         atomic_init(&calls->refcnt, 1);
2271         //TODO: Assign calls->o from o
2272
2273         LDKChannelPublicKeys pubkeys_conv;
2274         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2275         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2276         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2277
2278         LDKSign ret = {
2279                 .this_arg = (void*) calls,
2280                 .write = write_LDKSign_jcall,
2281                 .cloned = LDKSign_JCalls_cloned,
2282                 .free = LDKSign_JCalls_free,
2283                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
2284         };
2285         calls->BaseSign = ret.BaseSign.this_arg;
2286         return ret;
2287 }
2288 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
2289         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2290         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
2291         return (long)res_ptr;
2292 }
2293 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
2294         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2295         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2296         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
2297         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2298         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2299         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2300         CVec_u8Z_free(ret_var);
2301         return ret_arr;
2302 }
2303
2304 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
2305         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2306 }
2307 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
2308         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2309         CHECK(val->result_ok);
2310         LDKSign* res_ret = MALLOC(sizeof(LDKSign), "LDKSign");
2311         *res_ret = Sign_clone(&(*val->contents.result));
2312         return (uint64_t)res_ret;
2313 }
2314 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
2315         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2316         CHECK(!val->result_ok);
2317         LDKDecodeError err_var = (*val->contents.err);
2318         uint64_t err_ref = 0;
2319         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2320         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2321         err_ref = (uint64_t)err_var.inner & ~1;
2322         return err_ref;
2323 }
2324 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_result_ok(uint32_t arg) {
2325         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2326 }
2327 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_ok(uint32_t arg) {
2328         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2329         CHECK(val->result_ok);
2330         int8_tArray es_arr = init_arr(68, sizeof(uint8_t), "Native int8_tArray Bytes");
2331         memcpy((uint8_t*)(es_arr + 4), (*val->contents.result).serialized_form, 68);
2332         return es_arr;
2333 }
2334 void  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_err(uint32_t arg) {
2335         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2336         CHECK(!val->result_ok);
2337         return *val->contents.err;
2338 }
2339 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2340         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2341         for (size_t i = 0; i < ret.datalen; i++) {
2342                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2343         }
2344         return ret;
2345 }
2346 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
2347         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2348 }
2349 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
2350         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2351         CHECK(val->result_ok);
2352         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2353         ptrArray res_arr = NULL;
2354         res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
2355         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
2356         for (size_t m = 0; m < res_var.datalen; m++) {
2357                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
2358                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2359                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
2360                 res_arr_ptr[m] = res_conv_12_arr;
2361         }
2362         
2363         return res_arr;
2364 }
2365 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
2366         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2367         CHECK(!val->result_ok);
2368         return *val->contents.err;
2369 }
2370 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
2371         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2372 }
2373 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
2374         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2375         CHECK(val->result_ok);
2376         LDKInMemorySigner res_var = (*val->contents.result);
2377         uint64_t res_ref = 0;
2378         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2379         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2380         res_ref = (uint64_t)res_var.inner & ~1;
2381         return res_ref;
2382 }
2383 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
2384         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2385         CHECK(!val->result_ok);
2386         LDKDecodeError err_var = (*val->contents.err);
2387         uint64_t err_ref = 0;
2388         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2389         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2390         err_ref = (uint64_t)err_var.inner & ~1;
2391         return err_ref;
2392 }
2393 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
2394         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2395         ret->datalen = *((uint32_t*)elems);
2396         if (ret->datalen == 0) {
2397                 ret->data = NULL;
2398         } else {
2399                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2400                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2401                 for (size_t i = 0; i < ret->datalen; i++) {
2402                         uint32_t arr_elem = java_elems[i];
2403                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
2404                         CHECK_ACCESS(arr_elem_ptr);
2405                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(arr_elem_ptr);
2406                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2407                         ret->data[i] = arr_elem_conv;
2408                 }
2409         }
2410         return (uint64_t)ret;
2411 }
2412 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2413         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2414         for (size_t i = 0; i < ret.datalen; i++) {
2415                 ret.data[i] = TxOut_clone(&orig->data[i]);
2416         }
2417         return ret;
2418 }
2419 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
2420         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2421 }
2422 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
2423         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2424         CHECK(val->result_ok);
2425         LDKTransaction res_var = (*val->contents.result);
2426         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2427         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
2428         return res_arr;
2429 }
2430 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
2431         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2432         CHECK(!val->result_ok);
2433         return *val->contents.err;
2434 }
2435 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
2436         return ThirtyTwoBytes_clone(&tuple->a);
2437 }
2438 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t tuple) {
2439         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
2440         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2441         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_BlockHashChannelMonitorZ_get_a(tuple_conv).data, 32);
2442         return ret_arr;
2443 }
2444
2445 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
2446         return ChannelMonitor_clone(&tuple->b);
2447 }
2448 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t tuple) {
2449         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
2450         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
2451         uint64_t ret_ref = 0;
2452         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2453         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2454         ret_ref = (uint64_t)ret_var.inner;
2455         if (ret_var.is_owned) {
2456                 ret_ref |= 1;
2457         }
2458         return ret_ref;
2459 }
2460
2461 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_BlockHashChannelMonitorZZ_new(uint32_tArray elems) {
2462         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2463         ret->datalen = *((uint32_t*)elems);
2464         if (ret->datalen == 0) {
2465                 ret->data = NULL;
2466         } else {
2467                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2468                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2469                 for (size_t i = 0; i < ret->datalen; i++) {
2470                         uint32_t arr_elem = java_elems[i];
2471                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
2472                         CHECK_ACCESS(arr_elem_ptr);
2473                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(arr_elem_ptr);
2474                         arr_elem_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1));
2475                         ret->data[i] = arr_elem_conv;
2476                 }
2477         }
2478         return (uint64_t)ret;
2479 }
2480 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
2481         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
2482         for (size_t i = 0; i < ret.datalen; i++) {
2483                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
2484         }
2485         return ret;
2486 }
2487 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(uint32_t arg) {
2488         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2489 }
2490 uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(uint32_t arg) {
2491         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2492         CHECK(val->result_ok);
2493         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2494         uint32_tArray res_arr = NULL;
2495         res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2496         uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
2497         for (size_t j = 0; j < res_var.datalen; j++) {
2498                 LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2499                 *res_conv_35_conv = res_var.data[j];
2500                 *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
2501                 res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
2502         }
2503         
2504         return res_arr;
2505 }
2506 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
2507         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2508         CHECK(!val->result_ok);
2509         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
2510         return err_conv;
2511 }
2512 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) {
2513         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2514         switch(obj->tag) {
2515                 case LDKCOption_u16Z_Some: {
2516                         return 0 /* LDKCOption_u16Z - Some */; (void) obj->some;
2517                 }
2518                 case LDKCOption_u16Z_None: {
2519                         return 0 /* LDKCOption_u16Z - None */;
2520                 }
2521                 default: abort();
2522         }
2523 }
2524 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2525         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2526         switch(obj->tag) {
2527                 case LDKAPIError_APIMisuseError: {
2528                         LDKStr err_str = obj->api_misuse_error.err;
2529                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2530                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_conv;
2531                 }
2532                 case LDKAPIError_FeeRateTooHigh: {
2533                         LDKStr err_str = obj->fee_rate_too_high.err;
2534                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2535                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_conv; (void) obj->fee_rate_too_high.feerate;
2536                 }
2537                 case LDKAPIError_RouteError: {
2538                         LDKStr err_str = obj->route_error.err;
2539                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2540                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2541                 }
2542                 case LDKAPIError_ChannelUnavailable: {
2543                         LDKStr err_str = obj->channel_unavailable.err;
2544                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2545                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_conv;
2546                 }
2547                 case LDKAPIError_MonitorUpdateFailed: {
2548                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2549                 }
2550                 case LDKAPIError_IncompatibleShutdownScript: {
2551                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
2552                         uint64_t script_ref = 0;
2553                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2554                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2555                         script_ref = (uint64_t)script_var.inner & ~1;
2556                         return 0 /* LDKAPIError - IncompatibleShutdownScript */; (void) script_ref;
2557                 }
2558                 default: abort();
2559         }
2560 }
2561 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
2562         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2563 }
2564 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2565         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2566         CHECK(val->result_ok);
2567         return *val->contents.result;
2568 }
2569 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2570         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2571         CHECK(!val->result_ok);
2572         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2573         return err_ref;
2574 }
2575 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
2576         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2577         ret->datalen = *((uint32_t*)elems);
2578         if (ret->datalen == 0) {
2579                 ret->data = NULL;
2580         } else {
2581                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2582                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2583                 for (size_t i = 0; i < ret->datalen; i++) {
2584                         uint32_t arr_elem = java_elems[i];
2585                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
2586                         CHECK_ACCESS(arr_elem_ptr);
2587                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(arr_elem_ptr);
2588                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2589                         ret->data[i] = arr_elem_conv;
2590                 }
2591         }
2592         return (uint64_t)ret;
2593 }
2594 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2595         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2596         for (size_t i = 0; i < ret.datalen; i++) {
2597                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2598         }
2599         return ret;
2600 }
2601 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
2602         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2603         ret->datalen = *((uint32_t*)elems);
2604         if (ret->datalen == 0) {
2605                 ret->data = NULL;
2606         } else {
2607                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2608                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2609                 for (size_t i = 0; i < ret->datalen; i++) {
2610                         uint32_t arr_elem = java_elems[i];
2611                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
2612                         CHECK_ACCESS(arr_elem_ptr);
2613                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(arr_elem_ptr);
2614                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
2615                         ret->data[i] = arr_elem_conv;
2616                 }
2617         }
2618         return (uint64_t)ret;
2619 }
2620 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2621         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2622         for (size_t i = 0; i < ret.datalen; i++) {
2623                 ret.data[i] = APIError_clone(&orig->data[i]);
2624         }
2625         return ret;
2626 }
2627 jboolean  __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_result_ok(uint32_t arg) {
2628         return ((LDKCResult__u832APIErrorZ*)arg)->result_ok;
2629 }
2630 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_get_ok(uint32_t arg) {
2631         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
2632         CHECK(val->result_ok);
2633         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2634         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2635         return res_arr;
2636 }
2637 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_get_err(uint32_t arg) {
2638         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
2639         CHECK(!val->result_ok);
2640         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2641         return err_ref;
2642 }
2643 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2644         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
2645         switch(obj->tag) {
2646                 case LDKPaymentSendFailure_ParameterError: {
2647                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
2648                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
2649                 }
2650                 case LDKPaymentSendFailure_PathParameterError: {
2651                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
2652                         uint32_tArray path_parameter_error_arr = NULL;
2653                         path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2654                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
2655                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
2656                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2657                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
2658                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
2659                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
2660                         }
2661                         
2662                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
2663                 }
2664                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2665                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
2666                         uint32_tArray all_failed_retry_safe_arr = NULL;
2667                         all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2668                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
2669                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
2670                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
2671                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
2672                         }
2673                         
2674                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
2675                 }
2676                 case LDKPaymentSendFailure_PartialFailure: {
2677                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
2678                         uint32_tArray results_arr = NULL;
2679                         results_arr = init_arr(results_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2680                         uint32_t *results_arr_ptr = (uint32_t*)(results_arr + 4);
2681                         for (size_t w = 0; w < results_var.datalen; w++) {
2682                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2683                                 *results_conv_22_conv = results_var.data[w];
2684                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
2685                                 results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
2686                         }
2687                         
2688                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
2689                         uint64_t failed_paths_retry_ref = 0;
2690                         if ((uint64_t)failed_paths_retry_var.inner > 4096) {
2691                                 CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2692                                 CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2693                                 failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
2694                         }
2695                         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2696                         memcpy((uint8_t*)(payment_id_arr + 4), obj->partial_failure.payment_id.data, 32);
2697                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) results_arr; (void) failed_paths_retry_ref; (void) payment_id_arr;
2698                 }
2699                 default: abort();
2700         }
2701 }
2702 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_result_ok(uint32_t arg) {
2703         return ((LDKCResult_PaymentIdPaymentSendFailureZ*)arg)->result_ok;
2704 }
2705 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t arg) {
2706         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
2707         CHECK(val->result_ok);
2708         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2709         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2710         return res_arr;
2711 }
2712 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t arg) {
2713         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
2714         CHECK(!val->result_ok);
2715         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2716         return err_ref;
2717 }
2718 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
2719         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2720 }
2721 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2722         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2723         CHECK(val->result_ok);
2724         return *val->contents.result;
2725 }
2726 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2727         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2728         CHECK(!val->result_ok);
2729         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2730         return err_ref;
2731 }
2732 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
2733         return ThirtyTwoBytes_clone(&tuple->a);
2734 }
2735 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t tuple) {
2736         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
2737         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2738         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentIdZ_get_a(tuple_conv).data, 32);
2739         return ret_arr;
2740 }
2741
2742 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
2743         return ThirtyTwoBytes_clone(&tuple->b);
2744 }
2745 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t tuple) {
2746         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
2747         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2748         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv).data, 32);
2749         return ret_arr;
2750 }
2751
2752 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_result_ok(uint32_t arg) {
2753         return ((LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)arg)->result_ok;
2754 }
2755 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t arg) {
2756         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
2757         CHECK(val->result_ok);
2758         LDKC2Tuple_PaymentHashPaymentIdZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
2759         *res_conv = (*val->contents.result);
2760         *res_conv = C2Tuple_PaymentHashPaymentIdZ_clone(res_conv);
2761         return ((uint64_t)res_conv);
2762 }
2763 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t arg) {
2764         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
2765         CHECK(!val->result_ok);
2766         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2767         return err_ref;
2768 }
2769 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
2770         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2771         switch(obj->tag) {
2772                 case LDKNetAddress_IPv4: {
2773                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
2774                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
2775                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
2776                 }
2777                 case LDKNetAddress_IPv6: {
2778                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
2779                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
2780                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
2781                 }
2782                 case LDKNetAddress_OnionV2: {
2783                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
2784                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
2785                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
2786                 }
2787                 case LDKNetAddress_OnionV3: {
2788                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2789                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
2790                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
2791                 }
2792                 default: abort();
2793         }
2794 }
2795 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
2796         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
2797         ret->datalen = *((uint32_t*)elems);
2798         if (ret->datalen == 0) {
2799                 ret->data = NULL;
2800         } else {
2801                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
2802                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2803                 for (size_t i = 0; i < ret->datalen; i++) {
2804                         uint32_t arr_elem = java_elems[i];
2805                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
2806                         CHECK_ACCESS(arr_elem_ptr);
2807                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(arr_elem_ptr);
2808                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
2809                         ret->data[i] = arr_elem_conv;
2810                 }
2811         }
2812         return (uint64_t)ret;
2813 }
2814 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2815         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2816         for (size_t i = 0; i < ret.datalen; i++) {
2817                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2818         }
2819         return ret;
2820 }
2821 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
2822         return ThirtyTwoBytes_clone(&tuple->a);
2823 }
2824 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t tuple) {
2825         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
2826         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2827         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data, 32);
2828         return ret_arr;
2829 }
2830
2831 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
2832         return ThirtyTwoBytes_clone(&tuple->b);
2833 }
2834 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t tuple) {
2835         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
2836         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2837         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data, 32);
2838         return ret_arr;
2839 }
2840
2841 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_result_ok(uint32_t arg) {
2842         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
2843 }
2844 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_ok(uint32_t arg) {
2845         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2846         CHECK(val->result_ok);
2847         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2848         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2849         return res_arr;
2850 }
2851 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_err(uint32_t arg) {
2852         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2853         CHECK(!val->result_ok);
2854         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2855         return err_ref;
2856 }
2857 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
2858         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2859         ret->datalen = *((uint32_t*)elems);
2860         if (ret->datalen == 0) {
2861                 ret->data = NULL;
2862         } else {
2863                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2864                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2865                 for (size_t i = 0; i < ret->datalen; i++) {
2866                         uint32_t arr_elem = java_elems[i];
2867                         LDKChannelMonitor arr_elem_conv;
2868                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2869                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2870                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2871                         ret->data[i] = arr_elem_conv;
2872                 }
2873         }
2874         return (uint64_t)ret;
2875 }
2876 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2877         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2878         for (size_t i = 0; i < ret.datalen; i++) {
2879                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2880         }
2881         return ret;
2882 }
2883 typedef struct LDKWatch_JCalls {
2884         atomic_size_t refcnt;
2885         uint32_t watch_channel_meth;
2886         uint32_t update_channel_meth;
2887         uint32_t release_pending_monitor_events_meth;
2888 } LDKWatch_JCalls;
2889 static void LDKWatch_JCalls_free(void* this_arg) {
2890         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2891         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2892                 js_free(j_calls->watch_channel_meth);
2893                 js_free(j_calls->update_channel_meth);
2894                 js_free(j_calls->release_pending_monitor_events_meth);
2895                 FREE(j_calls);
2896         }
2897 }
2898 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2899         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2900         LDKOutPoint funding_txo_var = funding_txo;
2901         uint64_t funding_txo_ref = 0;
2902         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2903         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2904         funding_txo_ref = (uint64_t)funding_txo_var.inner;
2905         if (funding_txo_var.is_owned) {
2906                 funding_txo_ref |= 1;
2907         }
2908         LDKChannelMonitor monitor_var = monitor;
2909         uint64_t monitor_ref = 0;
2910         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2911         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2912         monitor_ref = (uint64_t)monitor_var.inner;
2913         if (monitor_var.is_owned) {
2914                 monitor_ref |= 1;
2915         }
2916         uint32_t ret = js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2917         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2918         CHECK_ACCESS(ret_ptr);
2919         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
2920         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2921         return ret_conv;
2922 }
2923 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2924         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2925         LDKOutPoint funding_txo_var = funding_txo;
2926         uint64_t funding_txo_ref = 0;
2927         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2928         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2929         funding_txo_ref = (uint64_t)funding_txo_var.inner;
2930         if (funding_txo_var.is_owned) {
2931                 funding_txo_ref |= 1;
2932         }
2933         LDKChannelMonitorUpdate update_var = update;
2934         uint64_t update_ref = 0;
2935         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2936         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2937         update_ref = (uint64_t)update_var.inner;
2938         if (update_var.is_owned) {
2939                 update_ref |= 1;
2940         }
2941         uint32_t ret = js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2942         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2943         CHECK_ACCESS(ret_ptr);
2944         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
2945         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2946         return ret_conv;
2947 }
2948 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
2949         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2950         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2951         LDKCVec_MonitorEventZ ret_constr;
2952         ret_constr.datalen = *((uint32_t*)ret);
2953         if (ret_constr.datalen > 0)
2954                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2955         else
2956                 ret_constr.data = NULL;
2957         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2958         for (size_t o = 0; o < ret_constr.datalen; o++) {
2959                 uint32_t ret_conv_14 = ret_vals[o];
2960                 void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
2961                 CHECK_ACCESS(ret_conv_14_ptr);
2962                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
2963                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
2964                 ret_constr.data[o] = ret_conv_14_conv;
2965         }
2966         return ret_constr;
2967 }
2968 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
2969         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
2970         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2971 }
2972 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2973         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2974         atomic_init(&calls->refcnt, 1);
2975         //TODO: Assign calls->o from o
2976
2977         LDKWatch ret = {
2978                 .this_arg = (void*) calls,
2979                 .watch_channel = watch_channel_LDKWatch_jcall,
2980                 .update_channel = update_channel_LDKWatch_jcall,
2981                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
2982                 .free = LDKWatch_JCalls_free,
2983         };
2984         return ret;
2985 }
2986 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2987         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2988         *res_ptr = LDKWatch_init(o);
2989         return (long)res_ptr;
2990 }
2991 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2992         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2993         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2994         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
2995         LDKOutPoint funding_txo_conv;
2996         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2997         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2998         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2999         LDKChannelMonitor monitor_conv;
3000         monitor_conv.inner = (void*)(monitor & (~1));
3001         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3002         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3003         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3004         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3005         return (uint64_t)ret_conv;
3006 }
3007
3008 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
3009         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3010         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3011         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
3012         LDKOutPoint funding_txo_conv;
3013         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3014         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3015         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3016         LDKChannelMonitorUpdate update_conv;
3017         update_conv.inner = (void*)(update & (~1));
3018         update_conv.is_owned = (update & 1) || (update == 0);
3019         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3020         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3021         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3022         return (uint64_t)ret_conv;
3023 }
3024
3025 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
3026         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3027         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3028         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
3029         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3030         uint32_tArray ret_arr = NULL;
3031         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3032         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3033         for (size_t o = 0; o < ret_var.datalen; o++) {
3034                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3035                 *ret_conv_14_copy = ret_var.data[o];
3036                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3037                 ret_arr_ptr[o] = ret_conv_14_ref;
3038         }
3039         
3040         FREE(ret_var.data);
3041         return ret_arr;
3042 }
3043
3044 typedef struct LDKBroadcasterInterface_JCalls {
3045         atomic_size_t refcnt;
3046         uint32_t broadcast_transaction_meth;
3047 } LDKBroadcasterInterface_JCalls;
3048 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3049         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3050         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3051                 js_free(j_calls->broadcast_transaction_meth);
3052                 FREE(j_calls);
3053         }
3054 }
3055 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3056         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3057         LDKTransaction tx_var = tx;
3058         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3059         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
3060         Transaction_free(tx_var);
3061         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
3062 }
3063 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
3064         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
3065         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3066 }
3067 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
3068         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3069         atomic_init(&calls->refcnt, 1);
3070         //TODO: Assign calls->o from o
3071
3072         LDKBroadcasterInterface ret = {
3073                 .this_arg = (void*) calls,
3074                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3075                 .free = LDKBroadcasterInterface_JCalls_free,
3076         };
3077         return ret;
3078 }
3079 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
3080         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3081         *res_ptr = LDKBroadcasterInterface_init(o);
3082         return (long)res_ptr;
3083 }
3084 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
3085         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3086         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3087         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
3088         LDKTransaction tx_ref;
3089         tx_ref.datalen = *((uint32_t*)tx);
3090         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3091         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
3092         tx_ref.data_is_owned = true;
3093         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3094 }
3095
3096 typedef struct LDKKeysInterface_JCalls {
3097         atomic_size_t refcnt;
3098         uint32_t get_node_secret_meth;
3099         uint32_t get_destination_script_meth;
3100         uint32_t get_shutdown_scriptpubkey_meth;
3101         uint32_t get_channel_signer_meth;
3102         uint32_t get_secure_random_bytes_meth;
3103         uint32_t read_chan_signer_meth;
3104         uint32_t sign_invoice_meth;
3105 } LDKKeysInterface_JCalls;
3106 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3107         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3108         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3109                 js_free(j_calls->get_node_secret_meth);
3110                 js_free(j_calls->get_destination_script_meth);
3111                 js_free(j_calls->get_shutdown_scriptpubkey_meth);
3112                 js_free(j_calls->get_channel_signer_meth);
3113                 js_free(j_calls->get_secure_random_bytes_meth);
3114                 js_free(j_calls->read_chan_signer_meth);
3115                 js_free(j_calls->sign_invoice_meth);
3116                 FREE(j_calls);
3117         }
3118 }
3119 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3120         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3121         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
3122         LDKSecretKey ret_ref;
3123         CHECK(*((uint32_t*)ret) == 32);
3124         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
3125         return ret_ref;
3126 }
3127 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3128         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3129         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
3130         LDKCVec_u8Z ret_ref;
3131         ret_ref.datalen = *((uint32_t*)ret);
3132         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3133         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
3134         return ret_ref;
3135 }
3136 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
3137         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3138         uint32_t ret = js_invoke_function_0(j_calls->get_shutdown_scriptpubkey_meth);
3139         LDKShutdownScript ret_conv;
3140         ret_conv.inner = (void*)(ret & (~1));
3141         ret_conv.is_owned = (ret & 1) || (ret == 0);
3142         ret_conv = ShutdownScript_clone(&ret_conv);
3143         return ret_conv;
3144 }
3145 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3146         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3147         uint32_t ret = js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3148         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3149         CHECK_ACCESS(ret_ptr);
3150         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
3151         ret_conv = Sign_clone(&ret_conv);
3152         return ret_conv;
3153 }
3154 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3155         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3156         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
3157         LDKThirtyTwoBytes ret_ref;
3158         CHECK(*((uint32_t*)ret) == 32);
3159         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
3160         return ret_ref;
3161 }
3162 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3163         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3164         LDKu8slice reader_var = reader;
3165         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3166         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
3167         uint32_t ret = js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
3168         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3169         CHECK_ACCESS(ret_ptr);
3170         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
3171         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3172         return ret_conv;
3173 }
3174 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3175         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3176         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3177         int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3178         memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
3179         CVec_u8Z_free(invoice_preimage_var);
3180         uint32_t ret = js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
3181         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3182         CHECK_ACCESS(ret_ptr);
3183         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
3184         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
3185         return ret_conv;
3186 }
3187 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
3188         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
3189         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3190 }
3191 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
3192         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3193         atomic_init(&calls->refcnt, 1);
3194         //TODO: Assign calls->o from o
3195
3196         LDKKeysInterface ret = {
3197                 .this_arg = (void*) calls,
3198                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3199                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3200                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
3201                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3202                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3203                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3204                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
3205                 .free = LDKKeysInterface_JCalls_free,
3206         };
3207         return ret;
3208 }
3209 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
3210         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3211         *res_ptr = LDKKeysInterface_init(o);
3212         return (long)res_ptr;
3213 }
3214 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
3215         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3216         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3217         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3218         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3219         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
3220         return ret_arr;
3221 }
3222
3223 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
3224         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3225         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3226         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3227         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3228         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3229         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3230         CVec_u8Z_free(ret_var);
3231         return ret_arr;
3232 }
3233
3234 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
3235         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3236         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3237         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3238         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
3239         uint64_t ret_ref = 0;
3240         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3241         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3242         ret_ref = (uint64_t)ret_var.inner;
3243         if (ret_var.is_owned) {
3244                 ret_ref |= 1;
3245         }
3246         return ret_ref;
3247 }
3248
3249 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
3250         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3251         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3252         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3253         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3254         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3255         return (uint64_t)ret_ret;
3256 }
3257
3258 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
3259         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3260         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3261         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3262         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3263         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
3264         return ret_arr;
3265 }
3266
3267 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
3268         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3269         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3270         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3271         LDKu8slice reader_ref;
3272         reader_ref.datalen = *((uint32_t*)reader);
3273         reader_ref.data = (int8_t*)(reader + 4);
3274         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3275         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3276         return (uint64_t)ret_conv;
3277 }
3278
3279 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
3280         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3281         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3282         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3283         LDKCVec_u8Z invoice_preimage_ref;
3284         invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
3285         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
3286         memcpy(invoice_preimage_ref.data, (uint8_t*)(invoice_preimage + 4), invoice_preimage_ref.datalen);
3287         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
3288         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
3289         return (uint64_t)ret_conv;
3290 }
3291
3292 typedef struct LDKFeeEstimator_JCalls {
3293         atomic_size_t refcnt;
3294         uint32_t get_est_sat_per_1000_weight_meth;
3295 } LDKFeeEstimator_JCalls;
3296 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3297         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3298         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3299                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
3300                 FREE(j_calls);
3301         }
3302 }
3303 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3304         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3305         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
3306         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3307 }
3308 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
3309         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
3310         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3311 }
3312 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
3313         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
3314         atomic_init(&calls->refcnt, 1);
3315         //TODO: Assign calls->o from o
3316
3317         LDKFeeEstimator ret = {
3318                 .this_arg = (void*) calls,
3319                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
3320                 .free = LDKFeeEstimator_JCalls_free,
3321         };
3322         return ret;
3323 }
3324 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
3325         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
3326         *res_ptr = LDKFeeEstimator_init(o);
3327         return (long)res_ptr;
3328 }
3329 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
3330         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3331         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3332         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
3333         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
3334         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
3335         return ret_val;
3336 }
3337
3338 typedef struct LDKLogger_JCalls {
3339         atomic_size_t refcnt;
3340         uint32_t log_meth;
3341 } LDKLogger_JCalls;
3342 static void LDKLogger_JCalls_free(void* this_arg) {
3343         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3344         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3345                 js_free(j_calls->log_meth);
3346                 FREE(j_calls);
3347         }
3348 }
3349 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
3350         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3351         const char* record_str = record;
3352         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
3353         js_invoke_function_1(j_calls->log_meth, record_conv);
3354 }
3355 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3356         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3357         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3358 }
3359 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
3360         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3361         atomic_init(&calls->refcnt, 1);
3362         //TODO: Assign calls->o from o
3363
3364         LDKLogger ret = {
3365                 .this_arg = (void*) calls,
3366                 .log = log_LDKLogger_jcall,
3367                 .free = LDKLogger_JCalls_free,
3368         };
3369         return ret;
3370 }
3371 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
3372         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3373         *res_ptr = LDKLogger_init(o);
3374         return (long)res_ptr;
3375 }
3376 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
3377         return ThirtyTwoBytes_clone(&tuple->a);
3378 }
3379 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t tuple) {
3380         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
3381         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3382         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data, 32);
3383         return ret_arr;
3384 }
3385
3386 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
3387         return &tuple->b;
3388 }
3389 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t tuple) {
3390         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
3391         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
3392         uint64_t ret_ref = 0;
3393         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3394         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3395         ret_ref = (uint64_t)ret_var.inner & ~1;
3396         return ret_ref;
3397 }
3398
3399 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
3400         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
3401 }
3402 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
3403         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3404         CHECK(val->result_ok);
3405         LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
3406         // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
3407         return ((uint64_t)res_conv) | 1;
3408 }
3409 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
3410         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3411         CHECK(!val->result_ok);
3412         LDKDecodeError err_var = (*val->contents.err);
3413         uint64_t err_ref = 0;
3414         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3415         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3416         err_ref = (uint64_t)err_var.inner & ~1;
3417         return err_ref;
3418 }
3419 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
3420         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
3421 }
3422 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
3423         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
3424         CHECK(val->result_ok);
3425         LDKChannelConfig res_var = (*val->contents.result);
3426         uint64_t res_ref = 0;
3427         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3428         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3429         res_ref = (uint64_t)res_var.inner & ~1;
3430         return res_ref;
3431 }
3432 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
3433         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
3434         CHECK(!val->result_ok);
3435         LDKDecodeError err_var = (*val->contents.err);
3436         uint64_t err_ref = 0;
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         err_ref = (uint64_t)err_var.inner & ~1;
3440         return err_ref;
3441 }
3442 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
3443         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
3444 }
3445 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
3446         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
3447         CHECK(val->result_ok);
3448         LDKOutPoint res_var = (*val->contents.result);
3449         uint64_t res_ref = 0;
3450         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3451         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3452         res_ref = (uint64_t)res_var.inner & ~1;
3453         return res_ref;
3454 }
3455 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
3456         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
3457         CHECK(!val->result_ok);
3458         LDKDecodeError err_var = (*val->contents.err);
3459         uint64_t err_ref = 0;
3460         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3461         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3462         err_ref = (uint64_t)err_var.inner & ~1;
3463         return err_ref;
3464 }
3465 typedef struct LDKType_JCalls {
3466         atomic_size_t refcnt;
3467         uint32_t type_id_meth;
3468         uint32_t debug_str_meth;
3469         uint32_t write_meth;
3470 } LDKType_JCalls;
3471 static void LDKType_JCalls_free(void* this_arg) {
3472         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3473         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3474                 js_free(j_calls->type_id_meth);
3475                 js_free(j_calls->debug_str_meth);
3476                 js_free(j_calls->write_meth);
3477                 FREE(j_calls);
3478         }
3479 }
3480 uint16_t type_id_LDKType_jcall(const void* this_arg) {
3481         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3482         return js_invoke_function_0(j_calls->type_id_meth);
3483 }
3484 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
3485         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3486         uint32_t ret = js_invoke_function_0(j_calls->debug_str_meth);
3487         LDKStr ret_conv = str_ref_to_owned_c(ret);
3488         return ret_conv;
3489 }
3490 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
3491         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3492         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
3493         LDKCVec_u8Z ret_ref;
3494         ret_ref.datalen = *((uint32_t*)ret);
3495         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3496         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
3497         return ret_ref;
3498 }
3499 static void LDKType_JCalls_cloned(LDKType* new_obj) {
3500         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
3501         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3502 }
3503 static inline LDKType LDKType_init (/*TODO: JS Object Reference */void* o) {
3504         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
3505         atomic_init(&calls->refcnt, 1);
3506         //TODO: Assign calls->o from o
3507
3508         LDKType ret = {
3509                 .this_arg = (void*) calls,
3510                 .type_id = type_id_LDKType_jcall,
3511                 .debug_str = debug_str_LDKType_jcall,
3512                 .write = write_LDKType_jcall,
3513                 .cloned = LDKType_JCalls_cloned,
3514                 .free = LDKType_JCalls_free,
3515         };
3516         return ret;
3517 }
3518 long  __attribute__((visibility("default"))) TS_LDKType_new(/*TODO: JS Object Reference */void* o) {
3519         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
3520         *res_ptr = LDKType_init(o);
3521         return (long)res_ptr;
3522 }
3523 int16_t  __attribute__((visibility("default"))) TS_Type_type_id(uint32_t this_arg) {
3524         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3525         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3526         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
3527         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
3528         return ret_val;
3529 }
3530
3531 jstring  __attribute__((visibility("default"))) TS_Type_debug_str(uint32_t this_arg) {
3532         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3533         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3534         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
3535         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
3536         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
3537         Str_free(ret_str);
3538         return ret_conv;
3539 }
3540
3541 int8_tArray  __attribute__((visibility("default"))) TS_Type_write(uint32_t this_arg) {
3542         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3543         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3544         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
3545         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3546         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3547         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3548         CVec_u8Z_free(ret_var);
3549         return ret_arr;
3550 }
3551
3552 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_TypeZ_ref_from_ptr(uint32_t ptr) {
3553         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
3554         switch(obj->tag) {
3555                 case LDKCOption_TypeZ_Some: {
3556                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
3557                         *some_ret = Type_clone(&obj->some);
3558                         return 0 /* LDKCOption_TypeZ - Some */; (void) (uint64_t)some_ret;
3559                 }
3560                 case LDKCOption_TypeZ_None: {
3561                         return 0 /* LDKCOption_TypeZ - None */;
3562                 }
3563                 default: abort();
3564         }
3565 }
3566 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_result_ok(uint32_t arg) {
3567         return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok;
3568 }
3569 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t arg) {
3570         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
3571         CHECK(val->result_ok);
3572         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3573         return res_ref;
3574 }
3575 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_err(uint32_t arg) {
3576         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
3577         CHECK(!val->result_ok);
3578         LDKDecodeError err_var = (*val->contents.err);
3579         uint64_t err_ref = 0;
3580         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3581         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3582         err_ref = (uint64_t)err_var.inner & ~1;
3583         return err_ref;
3584 }
3585 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentError_ref_from_ptr(uint32_t ptr) {
3586         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
3587         switch(obj->tag) {
3588                 case LDKPaymentError_Invoice: {
3589                         LDKStr invoice_str = obj->invoice;
3590                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
3591                         return 0 /* LDKPaymentError - Invoice */; (void) invoice_conv;
3592                 }
3593                 case LDKPaymentError_Routing: {
3594                         LDKLightningError routing_var = obj->routing;
3595                         uint64_t routing_ref = 0;
3596                         CHECK((((uint64_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3597                         CHECK((((uint64_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3598                         routing_ref = (uint64_t)routing_var.inner & ~1;
3599                         return 0 /* LDKPaymentError - Routing */; (void) routing_ref;
3600                 }
3601                 case LDKPaymentError_Sending: {
3602                         uint64_t sending_ref = ((uint64_t)&obj->sending) | 1;
3603                         return 0 /* LDKPaymentError - Sending */; (void) sending_ref;
3604                 }
3605                 default: abort();
3606         }
3607 }
3608 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_result_ok(uint32_t arg) {
3609         return ((LDKCResult_PaymentIdPaymentErrorZ*)arg)->result_ok;
3610 }
3611 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_get_ok(uint32_t arg) {
3612         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
3613         CHECK(val->result_ok);
3614         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3615         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
3616         return res_arr;
3617 }
3618 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_get_err(uint32_t arg) {
3619         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
3620         CHECK(!val->result_ok);
3621         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3622         return err_ref;
3623 }
3624 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) {
3625         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
3626 }
3627 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_ok(uint32_t arg) {
3628         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
3629         CHECK(val->result_ok);
3630         uint32_t res_conv = LDKSiPrefix_to_js((*val->contents.result));
3631         return res_conv;
3632 }
3633 void  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_err(uint32_t arg) {
3634         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
3635         CHECK(!val->result_ok);
3636         return *val->contents.err;
3637 }
3638 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_result_ok(uint32_t arg) {
3639         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
3640 }
3641 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_ok(uint32_t arg) {
3642         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
3643         CHECK(val->result_ok);
3644         LDKInvoice res_var = (*val->contents.result);
3645         uint64_t res_ref = 0;
3646         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3647         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3648         res_ref = (uint64_t)res_var.inner & ~1;
3649         return res_ref;
3650 }
3651 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
3652         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
3653         CHECK(!val->result_ok);
3654         return *val->contents.err;
3655 }
3656 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_result_ok(uint32_t arg) {
3657         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
3658 }
3659 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_ok(uint32_t arg) {
3660         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
3661         CHECK(val->result_ok);
3662         LDKSignedRawInvoice res_var = (*val->contents.result);
3663         uint64_t res_ref = 0;
3664         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3665         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3666         res_ref = (uint64_t)res_var.inner & ~1;
3667         return res_ref;
3668 }
3669 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
3670         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
3671         CHECK(!val->result_ok);
3672         return *val->contents.err;
3673 }
3674 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3675         return RawInvoice_clone(&tuple->a);
3676 }
3677 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t tuple) {
3678         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3679         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
3680         uint64_t ret_ref = 0;
3681         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3682         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3683         ret_ref = (uint64_t)ret_var.inner;
3684         if (ret_var.is_owned) {
3685                 ret_ref |= 1;
3686         }
3687         return ret_ref;
3688 }
3689
3690 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3691         return ThirtyTwoBytes_clone(&tuple->b);
3692 }
3693 int8_tArray  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t tuple) {
3694         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3695         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3696         memcpy((uint8_t*)(ret_arr + 4), C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data, 32);
3697         return ret_arr;
3698 }
3699
3700 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3701         return InvoiceSignature_clone(&tuple->c);
3702 }
3703 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t tuple) {
3704         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3705         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
3706         uint64_t ret_ref = 0;
3707         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3708         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3709         ret_ref = (uint64_t)ret_var.inner;
3710         if (ret_var.is_owned) {
3711                 ret_ref |= 1;
3712         }
3713         return ret_ref;
3714 }
3715
3716 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_result_ok(uint32_t arg) {
3717         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
3718 }
3719 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_ok(uint32_t arg) {
3720         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3721         CHECK(val->result_ok);
3722         LDKPayeePubKey res_var = (*val->contents.result);
3723         uint64_t res_ref = 0;
3724         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3725         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3726         res_ref = (uint64_t)res_var.inner & ~1;
3727         return res_ref;
3728 }
3729 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
3730         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3731         CHECK(!val->result_ok);
3732         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3733         return err_conv;
3734 }
3735 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_PrivateRouteZ_new(uint32_tArray elems) {
3736         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
3737         ret->datalen = *((uint32_t*)elems);
3738         if (ret->datalen == 0) {
3739                 ret->data = NULL;
3740         } else {
3741                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
3742                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3743                 for (size_t i = 0; i < ret->datalen; i++) {
3744                         uint32_t arr_elem = java_elems[i];
3745                         LDKPrivateRoute arr_elem_conv;
3746                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3747                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3748                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
3749                         ret->data[i] = arr_elem_conv;
3750                 }
3751         }
3752         return (uint64_t)ret;
3753 }
3754 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
3755         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
3756         for (size_t i = 0; i < ret.datalen; i++) {
3757                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
3758         }
3759         return ret;
3760 }
3761 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_result_ok(uint32_t arg) {
3762         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
3763 }
3764 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t arg) {
3765         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3766         CHECK(val->result_ok);
3767         LDKPositiveTimestamp res_var = (*val->contents.result);
3768         uint64_t res_ref = 0;
3769         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3770         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3771         res_ref = (uint64_t)res_var.inner & ~1;
3772         return res_ref;
3773 }
3774 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
3775         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3776         CHECK(!val->result_ok);
3777         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3778         return err_conv;
3779 }
3780 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_result_ok(uint32_t arg) {
3781         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
3782 }
3783 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_ok(uint32_t arg) {
3784         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3785         CHECK(val->result_ok);
3786         return *val->contents.result;
3787 }
3788 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_err(uint32_t arg) {
3789         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3790         CHECK(!val->result_ok);
3791         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3792         return err_conv;
3793 }
3794 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_result_ok(uint32_t arg) {
3795         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
3796 }
3797 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_ok(uint32_t arg) {
3798         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3799         CHECK(val->result_ok);
3800         LDKInvoice res_var = (*val->contents.result);
3801         uint64_t res_ref = 0;
3802         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3803         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3804         res_ref = (uint64_t)res_var.inner & ~1;
3805         return res_ref;
3806 }
3807 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
3808         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3809         CHECK(!val->result_ok);
3810         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3811         return err_conv;
3812 }
3813 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_result_ok(uint32_t arg) {
3814         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
3815 }
3816 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_ok(uint32_t arg) {
3817         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3818         CHECK(val->result_ok);
3819         LDKDescription res_var = (*val->contents.result);
3820         uint64_t res_ref = 0;
3821         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3822         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3823         res_ref = (uint64_t)res_var.inner & ~1;
3824         return res_ref;
3825 }
3826 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
3827         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3828         CHECK(!val->result_ok);
3829         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3830         return err_conv;
3831 }
3832 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_result_ok(uint32_t arg) {
3833         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
3834 }
3835 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_ok(uint32_t arg) {
3836         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3837         CHECK(val->result_ok);
3838         LDKExpiryTime res_var = (*val->contents.result);
3839         uint64_t res_ref = 0;
3840         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3841         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3842         res_ref = (uint64_t)res_var.inner & ~1;
3843         return res_ref;
3844 }
3845 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
3846         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3847         CHECK(!val->result_ok);
3848         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3849         return err_conv;
3850 }
3851 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_result_ok(uint32_t arg) {
3852         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
3853 }
3854 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_ok(uint32_t arg) {
3855         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3856         CHECK(val->result_ok);
3857         LDKPrivateRoute res_var = (*val->contents.result);
3858         uint64_t res_ref = 0;
3859         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3860         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3861         res_ref = (uint64_t)res_var.inner & ~1;
3862         return res_ref;
3863 }
3864 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
3865         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3866         CHECK(!val->result_ok);
3867         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3868         return err_conv;
3869 }
3870 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_result_ok(uint32_t arg) {
3871         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
3872 }
3873 jstring  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_ok(uint32_t arg) {
3874         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3875         CHECK(val->result_ok);
3876         LDKStr res_str = (*val->contents.result);
3877         jstring res_conv = str_ref_to_ts(res_str.chars, res_str.len);
3878         return res_conv;
3879 }
3880 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_err(uint32_t arg) {
3881         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3882         CHECK(!val->result_ok);
3883         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3884         return err_conv;
3885 }
3886 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3887         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
3888 }
3889 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3890         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3891         CHECK(val->result_ok);
3892         LDKChannelMonitorUpdate res_var = (*val->contents.result);
3893         uint64_t res_ref = 0;
3894         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3895         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3896         res_ref = (uint64_t)res_var.inner & ~1;
3897         return res_ref;
3898 }
3899 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
3900         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3901         CHECK(!val->result_ok);
3902         LDKDecodeError err_var = (*val->contents.err);
3903         uint64_t err_ref = 0;
3904         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3905         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3906         err_ref = (uint64_t)err_var.inner & ~1;
3907         return err_ref;
3908 }
3909 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3910         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
3911 }
3912 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3913         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3914         CHECK(val->result_ok);
3915         LDKHTLCUpdate res_var = (*val->contents.result);
3916         uint64_t res_ref = 0;
3917         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3918         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3919         res_ref = (uint64_t)res_var.inner & ~1;
3920         return res_ref;
3921 }
3922 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
3923         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3924         CHECK(!val->result_ok);
3925         LDKDecodeError err_var = (*val->contents.err);
3926         uint64_t err_ref = 0;
3927         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3928         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3929         err_ref = (uint64_t)err_var.inner & ~1;
3930         return err_ref;
3931 }
3932 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
3933         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
3934 }
3935 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
3936         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3937         CHECK(val->result_ok);
3938         return *val->contents.result;
3939 }
3940 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
3941         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3942         CHECK(!val->result_ok);
3943         LDKMonitorUpdateError err_var = (*val->contents.err);
3944         uint64_t err_ref = 0;
3945         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3946         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3947         err_ref = (uint64_t)err_var.inner & ~1;
3948         return err_ref;
3949 }
3950 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
3951         return OutPoint_clone(&tuple->a);
3952 }
3953 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t tuple) {
3954         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
3955         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
3956         uint64_t ret_ref = 0;
3957         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3958         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3959         ret_ref = (uint64_t)ret_var.inner;
3960         if (ret_var.is_owned) {
3961                 ret_ref |= 1;
3962         }
3963         return ret_ref;
3964 }
3965
3966 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
3967         return CVec_u8Z_clone(&tuple->b);
3968 }
3969 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t tuple) {
3970         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
3971         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
3972         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3973         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3974         CVec_u8Z_free(ret_var);
3975         return ret_arr;
3976 }
3977
3978 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
3979         return tuple->a;
3980 }
3981 int32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t tuple) {
3982         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
3983         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
3984         return ret_val;
3985 }
3986
3987 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
3988         return CVec_u8Z_clone(&tuple->b);
3989 }
3990 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t tuple) {
3991         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
3992         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
3993         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3994         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3995         CVec_u8Z_free(ret_var);
3996         return ret_arr;
3997 }
3998
3999 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
4000         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
4001         ret->datalen = *((uint32_t*)elems);
4002         if (ret->datalen == 0) {
4003                 ret->data = NULL;
4004         } else {
4005                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
4006                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4007                 for (size_t i = 0; i < ret->datalen; i++) {
4008                         uint32_t arr_elem = java_elems[i];
4009                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
4010                         CHECK_ACCESS(arr_elem_ptr);
4011                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(arr_elem_ptr);
4012                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
4013                         ret->data[i] = arr_elem_conv;
4014                 }
4015         }
4016         return (uint64_t)ret;
4017 }
4018 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4019         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4020         for (size_t i = 0; i < ret.datalen; i++) {
4021                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4022         }
4023         return ret;
4024 }
4025 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
4026         return ThirtyTwoBytes_clone(&tuple->a);
4027 }
4028 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t tuple) {
4029         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
4030         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4031         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data, 32);
4032         return ret_arr;
4033 }
4034
4035 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
4036         return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
4037 }
4038 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t tuple) {
4039         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
4040         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
4041         uint32_tArray ret_arr = NULL;
4042         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4043         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4044         for (size_t v = 0; v < ret_var.datalen; v++) {
4045                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4046                 *ret_conv_21_conv = ret_var.data[v];
4047                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
4048         }
4049         
4050         FREE(ret_var.data);
4051         return ret_arr;
4052 }
4053
4054 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
4055         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
4056         ret->datalen = *((uint32_t*)elems);
4057         if (ret->datalen == 0) {
4058                 ret->data = NULL;
4059         } else {
4060                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
4061                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4062                 for (size_t i = 0; i < ret->datalen; i++) {
4063                         uint32_t arr_elem = java_elems[i];
4064                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
4065                         CHECK_ACCESS(arr_elem_ptr);
4066                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arr_elem_ptr);
4067                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
4068                         ret->data[i] = arr_elem_conv;
4069                 }
4070         }
4071         return (uint64_t)ret;
4072 }
4073 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4074         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 };
4075         for (size_t i = 0; i < ret.datalen; i++) {
4076                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4077         }
4078         return ret;
4079 }
4080 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentPurpose_ref_from_ptr(uint32_t ptr) {
4081         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
4082         switch(obj->tag) {
4083                 case LDKPaymentPurpose_InvoicePayment: {
4084                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4085                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->invoice_payment.payment_preimage.data, 32);
4086                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4087                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->invoice_payment.payment_secret.data, 32);
4088                         return 0 /* LDKPaymentPurpose - InvoicePayment */; (void) payment_preimage_arr; (void) payment_secret_arr; (void) obj->invoice_payment.user_payment_id;
4089                 }
4090                 case LDKPaymentPurpose_SpontaneousPayment: {
4091                         int8_tArray spontaneous_payment_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4092                         memcpy((uint8_t*)(spontaneous_payment_arr + 4), obj->spontaneous_payment.data, 32);
4093                         return 0 /* LDKPaymentPurpose - SpontaneousPayment */; (void) spontaneous_payment_arr;
4094                 }
4095                 default: abort();
4096         }
4097 }
4098 uint32_t __attribute__((visibility("default"))) TS_LDKClosureReason_ref_from_ptr(uint32_t ptr) {
4099         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
4100         switch(obj->tag) {
4101                 case LDKClosureReason_CounterpartyForceClosed: {
4102                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
4103                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
4104                         return 0 /* LDKClosureReason - CounterpartyForceClosed */; (void) peer_msg_conv;
4105                 }
4106                 case LDKClosureReason_HolderForceClosed: {
4107                         return 0 /* LDKClosureReason - HolderForceClosed */;
4108                 }
4109                 case LDKClosureReason_CooperativeClosure: {
4110                         return 0 /* LDKClosureReason - CooperativeClosure */;
4111                 }
4112                 case LDKClosureReason_CommitmentTxConfirmed: {
4113                         return 0 /* LDKClosureReason - CommitmentTxConfirmed */;
4114                 }
4115                 case LDKClosureReason_ProcessingError: {
4116                         LDKStr err_str = obj->processing_error.err;
4117                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4118                         return 0 /* LDKClosureReason - ProcessingError */; (void) err_conv;
4119                 }
4120                 case LDKClosureReason_DisconnectedPeer: {
4121                         return 0 /* LDKClosureReason - DisconnectedPeer */;
4122                 }
4123                 case LDKClosureReason_OutdatedChannelManager: {
4124                         return 0 /* LDKClosureReason - OutdatedChannelManager */;
4125                 }
4126                 default: abort();
4127         }
4128 }
4129 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
4130         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
4131         switch(obj->tag) {
4132                 case LDKEvent_FundingGenerationReady: {
4133                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4134                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
4135                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4136                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4137                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
4138                         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;
4139                 }
4140                 case LDKEvent_PaymentReceived: {
4141                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4142                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
4143                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
4144                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) obj->payment_received.amt; (void) purpose_ref;
4145                 }
4146                 case LDKEvent_PaymentSent: {
4147                         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4148                         memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_sent.payment_id.data, 32);
4149                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4150                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
4151                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4152                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_sent.payment_hash.data, 32);
4153                         uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
4154                         return 0 /* LDKEvent - PaymentSent */; (void) payment_id_arr; (void) payment_preimage_arr; (void) payment_hash_arr; (void) fee_paid_msat_ref;
4155                 }
4156                 case LDKEvent_PaymentPathFailed: {
4157                         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4158                         memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_path_failed.payment_id.data, 32);
4159                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4160                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_path_failed.payment_hash.data, 32);
4161                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
4162                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
4163                         uint32_tArray path_arr = NULL;
4164                         path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4165                         uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
4166                         for (size_t k = 0; k < path_var.datalen; k++) {
4167                                 LDKRouteHop path_conv_10_var = path_var.data[k];
4168                                 uint64_t path_conv_10_ref = 0;
4169                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4170                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4171                                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
4172                                 path_arr_ptr[k] = path_conv_10_ref;
4173                         }
4174                         
4175                         uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
4176                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
4177                         uint64_t retry_ref = 0;
4178                         if ((uint64_t)retry_var.inner > 4096) {
4179                                 CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4180                                 CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4181                                 retry_ref = (uint64_t)retry_var.inner & ~1;
4182                         }
4183                         return 0 /* LDKEvent - PaymentPathFailed */; (void) payment_id_arr; (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; (void) short_channel_id_ref; (void) retry_ref;
4184                 }
4185                 case LDKEvent_PendingHTLCsForwardable: {
4186                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
4187                 }
4188                 case LDKEvent_SpendableOutputs: {
4189                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4190                         uint32_tArray outputs_arr = NULL;
4191                         outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4192                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
4193                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4194                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
4195                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4196                         }
4197                         
4198                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
4199                 }
4200                 case LDKEvent_PaymentForwarded: {
4201                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
4202                         return 0 /* LDKEvent - PaymentForwarded */; (void) fee_earned_msat_ref; (void) obj->payment_forwarded.claim_from_onchain_tx;
4203                 }
4204                 case LDKEvent_ChannelClosed: {
4205                         int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4206                         memcpy((uint8_t*)(channel_id_arr + 4), obj->channel_closed.channel_id.data, 32);
4207                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
4208                         return 0 /* LDKEvent - ChannelClosed */; (void) channel_id_arr; (void) obj->channel_closed.user_channel_id; (void) reason_ref;
4209                 }
4210                 case LDKEvent_DiscardFunding: {
4211                         int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4212                         memcpy((uint8_t*)(channel_id_arr + 4), obj->discard_funding.channel_id.data, 32);
4213                         LDKTransaction transaction_var = obj->discard_funding.transaction;
4214                         int8_tArray transaction_arr = init_arr(transaction_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4215                         memcpy((uint8_t*)(transaction_arr + 4), transaction_var.data, transaction_var.datalen);
4216                         return 0 /* LDKEvent - DiscardFunding */; (void) channel_id_arr; (void) transaction_arr;
4217                 }
4218                 default: abort();
4219         }
4220 }
4221 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
4222         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4223         ret->datalen = *((uint32_t*)elems);
4224         if (ret->datalen == 0) {
4225                 ret->data = NULL;
4226         } else {
4227                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
4228                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4229                 for (size_t i = 0; i < ret->datalen; i++) {
4230                         uint32_t arr_elem = java_elems[i];
4231                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
4232                         CHECK_ACCESS(arr_elem_ptr);
4233                         LDKEvent arr_elem_conv = *(LDKEvent*)(arr_elem_ptr);
4234                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
4235                         ret->data[i] = arr_elem_conv;
4236                 }
4237         }
4238         return (uint64_t)ret;
4239 }
4240 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4241         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4242         for (size_t i = 0; i < ret.datalen; i++) {
4243                 ret.data[i] = Event_clone(&orig->data[i]);
4244         }
4245         return ret;
4246 }
4247 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
4248         return tuple->a;
4249 }
4250 int32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t tuple) {
4251         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
4252         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
4253         return ret_val;
4254 }
4255
4256 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
4257         return TxOut_clone(&tuple->b);
4258 }
4259 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t tuple) {
4260         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
4261         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
4262         *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
4263         return (uint64_t)ret_ref;
4264 }
4265
4266 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
4267         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
4268         ret->datalen = *((uint32_t*)elems);
4269         if (ret->datalen == 0) {
4270                 ret->data = NULL;
4271         } else {
4272                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
4273                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4274                 for (size_t i = 0; i < ret->datalen; i++) {
4275                         uint32_t arr_elem = java_elems[i];
4276                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
4277                         CHECK_ACCESS(arr_elem_ptr);
4278                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(arr_elem_ptr);
4279                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
4280                         ret->data[i] = arr_elem_conv;
4281                 }
4282         }
4283         return (uint64_t)ret;
4284 }
4285 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4286         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4287         for (size_t i = 0; i < ret.datalen; i++) {
4288                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4289         }
4290         return ret;
4291 }
4292 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
4293         return ThirtyTwoBytes_clone(&tuple->a);
4294 }
4295 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t tuple) {
4296         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
4297         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4298         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data, 32);
4299         return ret_arr;
4300 }
4301
4302 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
4303         return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
4304 }
4305 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t tuple) {
4306         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
4307         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
4308         uint32_tArray ret_arr = NULL;
4309         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4310         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4311         for (size_t u = 0; u < ret_var.datalen; u++) {
4312                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4313                 *ret_conv_20_conv = ret_var.data[u];
4314                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
4315         }
4316         
4317         FREE(ret_var.data);
4318         return ret_arr;
4319 }
4320
4321 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
4322         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
4323         ret->datalen = *((uint32_t*)elems);
4324         if (ret->datalen == 0) {
4325                 ret->data = NULL;
4326         } else {
4327                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
4328                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4329                 for (size_t i = 0; i < ret->datalen; i++) {
4330                         uint32_t arr_elem = java_elems[i];
4331                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
4332                         CHECK_ACCESS(arr_elem_ptr);
4333                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arr_elem_ptr);
4334                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
4335                         ret->data[i] = arr_elem_conv;
4336                 }
4337         }
4338         return (uint64_t)ret;
4339 }
4340 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
4341         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 };
4342         for (size_t i = 0; i < ret.datalen; i++) {
4343                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
4344         }
4345         return ret;
4346 }
4347 uint32_t __attribute__((visibility("default"))) TS_LDKBalance_ref_from_ptr(uint32_t ptr) {
4348         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
4349         switch(obj->tag) {
4350                 case LDKBalance_ClaimableOnChannelClose: {
4351                         return 0 /* LDKBalance - ClaimableOnChannelClose */; (void) obj->claimable_on_channel_close.claimable_amount_satoshis;
4352                 }
4353                 case LDKBalance_ClaimableAwaitingConfirmations: {
4354                         return 0 /* LDKBalance - ClaimableAwaitingConfirmations */; (void) obj->claimable_awaiting_confirmations.claimable_amount_satoshis; (void) obj->claimable_awaiting_confirmations.confirmation_height;
4355                 }
4356                 case LDKBalance_ContentiousClaimable: {
4357                         return 0 /* LDKBalance - ContentiousClaimable */; (void) obj->contentious_claimable.claimable_amount_satoshis; (void) obj->contentious_claimable.timeout_height;
4358                 }
4359                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
4360                         return 0 /* LDKBalance - MaybeClaimableHTLCAwaitingTimeout */; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
4361                 }
4362                 default: abort();
4363         }
4364 }
4365 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_BalanceZ_new(uint32_tArray elems) {
4366         LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ");
4367         ret->datalen = *((uint32_t*)elems);
4368         if (ret->datalen == 0) {
4369                 ret->data = NULL;
4370         } else {
4371                 ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ Data");
4372                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4373                 for (size_t i = 0; i < ret->datalen; i++) {
4374                         uint32_t arr_elem = java_elems[i];
4375                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
4376                         CHECK_ACCESS(arr_elem_ptr);
4377                         LDKBalance arr_elem_conv = *(LDKBalance*)(arr_elem_ptr);
4378                         arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
4379                         ret->data[i] = arr_elem_conv;
4380                 }
4381         }
4382         return (uint64_t)ret;
4383 }
4384 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
4385         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
4386         for (size_t i = 0; i < ret.datalen; i++) {
4387                 ret.data[i] = Balance_clone(&orig->data[i]);
4388         }
4389         return ret;
4390 }
4391 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
4392         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
4393 }
4394 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
4395         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4396         CHECK(val->result_ok);
4397         LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4398         *res_conv = (*val->contents.result);
4399         *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
4400         return ((uint64_t)res_conv);
4401 }
4402 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
4403         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4404         CHECK(!val->result_ok);
4405         LDKDecodeError err_var = (*val->contents.err);
4406         uint64_t err_ref = 0;
4407         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4408         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4409         err_ref = (uint64_t)err_var.inner & ~1;
4410         return err_ref;
4411 }
4412 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
4413         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
4414 }
4415 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
4416         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4417         CHECK(val->result_ok);
4418         return *val->contents.result;
4419 }
4420 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
4421         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4422         CHECK(!val->result_ok);
4423         LDKLightningError err_var = (*val->contents.err);
4424         uint64_t err_ref = 0;
4425         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4426         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4427         err_ref = (uint64_t)err_var.inner & ~1;
4428         return err_ref;
4429 }
4430 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
4431         return tuple->a;
4432 }
4433 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t tuple) {
4434         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
4435         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4436         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form, 33);
4437         return ret_arr;
4438 }
4439
4440 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
4441         return Type_clone(&tuple->b);
4442 }
4443 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t tuple) {
4444         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
4445         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
4446         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
4447         return (uint64_t)ret_ret;
4448 }
4449
4450 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_PublicKeyTypeZZ_new(uint32_tArray elems) {
4451         LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ");
4452         ret->datalen = *((uint32_t*)elems);
4453         if (ret->datalen == 0) {
4454                 ret->data = NULL;
4455         } else {
4456                 ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ 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                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
4461                         CHECK_ACCESS(arr_elem_ptr);
4462                         LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(arr_elem_ptr);
4463                         arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
4464                         ret->data[i] = arr_elem_conv;
4465                 }
4466         }
4467         return (uint64_t)ret;
4468 }
4469 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
4470         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
4471         for (size_t i = 0; i < ret.datalen; i++) {
4472                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
4473         }
4474         return ret;
4475 }
4476 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
4477         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
4478 }
4479 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
4480         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4481         CHECK(val->result_ok);
4482         return *val->contents.result;
4483 }
4484 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
4485         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4486         CHECK(!val->result_ok);
4487         LDKLightningError err_var = (*val->contents.err);
4488         uint64_t err_ref = 0;
4489         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4490         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4491         err_ref = (uint64_t)err_var.inner & ~1;
4492         return err_ref;
4493 }
4494 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4495         return ChannelAnnouncement_clone(&tuple->a);
4496 }
4497 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t tuple) {
4498         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4499         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
4500         uint64_t ret_ref = 0;
4501         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4502         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4503         ret_ref = (uint64_t)ret_var.inner;
4504         if (ret_var.is_owned) {
4505                 ret_ref |= 1;
4506         }
4507         return ret_ref;
4508 }
4509
4510 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4511         return ChannelUpdate_clone(&tuple->b);
4512 }
4513 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t tuple) {
4514         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4515         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
4516         uint64_t ret_ref = 0;
4517         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4518         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4519         ret_ref = (uint64_t)ret_var.inner;
4520         if (ret_var.is_owned) {
4521                 ret_ref |= 1;
4522         }
4523         return ret_ref;
4524 }
4525
4526 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4527         return ChannelUpdate_clone(&tuple->c);
4528 }
4529 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t tuple) {
4530         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4531         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
4532         uint64_t ret_ref = 0;
4533         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4534         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4535         ret_ref = (uint64_t)ret_var.inner;
4536         if (ret_var.is_owned) {
4537                 ret_ref |= 1;
4538         }
4539         return ret_ref;
4540 }
4541
4542 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
4543         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
4544         ret->datalen = *((uint32_t*)elems);
4545         if (ret->datalen == 0) {
4546                 ret->data = NULL;
4547         } else {
4548                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
4549                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4550                 for (size_t i = 0; i < ret->datalen; i++) {
4551                         uint32_t arr_elem = java_elems[i];
4552                         void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
4553                         CHECK_ACCESS(arr_elem_ptr);
4554                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arr_elem_ptr);
4555                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
4556                         ret->data[i] = arr_elem_conv;
4557                 }
4558         }
4559         return (uint64_t)ret;
4560 }
4561 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4562         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4563         for (size_t i = 0; i < ret.datalen; i++) {
4564                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4565         }
4566         return ret;
4567 }
4568 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
4569         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
4570         ret->datalen = *((uint32_t*)elems);
4571         if (ret->datalen == 0) {
4572                 ret->data = NULL;
4573         } else {
4574                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
4575                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4576                 for (size_t i = 0; i < ret->datalen; i++) {
4577                         uint32_t arr_elem = java_elems[i];
4578                         LDKNodeAnnouncement arr_elem_conv;
4579                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4580                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4581                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
4582                         ret->data[i] = arr_elem_conv;
4583                 }
4584         }
4585         return (uint64_t)ret;
4586 }
4587 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
4588         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
4589         for (size_t i = 0; i < ret.datalen; i++) {
4590                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
4591         }
4592         return ret;
4593 }
4594 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
4595         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
4596 }
4597 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
4598         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4599         CHECK(val->result_ok);
4600         LDKCVec_u8Z res_var = (*val->contents.result);
4601         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4602         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
4603         return res_arr;
4604 }
4605 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
4606         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4607         CHECK(!val->result_ok);
4608         LDKPeerHandleError err_var = (*val->contents.err);
4609         uint64_t err_ref = 0;
4610         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4611         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4612         err_ref = (uint64_t)err_var.inner & ~1;
4613         return err_ref;
4614 }
4615 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
4616         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
4617 }
4618 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
4619         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4620         CHECK(val->result_ok);
4621         return *val->contents.result;
4622 }
4623 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
4624         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4625         CHECK(!val->result_ok);
4626         LDKPeerHandleError err_var = (*val->contents.err);
4627         uint64_t err_ref = 0;
4628         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4629         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4630         err_ref = (uint64_t)err_var.inner & ~1;
4631         return err_ref;
4632 }
4633 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
4634         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
4635 }
4636 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
4637         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4638         CHECK(val->result_ok);
4639         return *val->contents.result;
4640 }
4641 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
4642         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4643         CHECK(!val->result_ok);
4644         LDKPeerHandleError err_var = (*val->contents.err);
4645         uint64_t err_ref = 0;
4646         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4647         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4648         err_ref = (uint64_t)err_var.inner & ~1;
4649         return err_ref;
4650 }
4651 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_result_ok(uint32_t arg) {
4652         return ((LDKCResult_NodeIdDecodeErrorZ*)arg)->result_ok;
4653 }
4654 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_get_ok(uint32_t arg) {
4655         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
4656         CHECK(val->result_ok);
4657         LDKNodeId res_var = (*val->contents.result);
4658         uint64_t res_ref = 0;
4659         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4660         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4661         res_ref = (uint64_t)res_var.inner & ~1;
4662         return res_ref;
4663 }
4664 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_get_err(uint32_t arg) {
4665         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
4666         CHECK(!val->result_ok);
4667         LDKDecodeError err_var = (*val->contents.err);
4668         uint64_t err_ref = 0;
4669         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4670         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4671         err_ref = (uint64_t)err_var.inner & ~1;
4672         return err_ref;
4673 }
4674 typedef struct LDKAccess_JCalls {
4675         atomic_size_t refcnt;
4676         uint32_t get_utxo_meth;
4677 } LDKAccess_JCalls;
4678 static void LDKAccess_JCalls_free(void* this_arg) {
4679         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4680         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4681                 js_free(j_calls->get_utxo_meth);
4682                 FREE(j_calls);
4683         }
4684 }
4685 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4686         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4687         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4688         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4689         uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4690         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4691         CHECK_ACCESS(ret_ptr);
4692         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
4693         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
4694         return ret_conv;
4695 }
4696 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
4697         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
4698         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4699 }
4700 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4701         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4702         atomic_init(&calls->refcnt, 1);
4703         //TODO: Assign calls->o from o
4704
4705         LDKAccess ret = {
4706                 .this_arg = (void*) calls,
4707                 .get_utxo = get_utxo_LDKAccess_jcall,
4708                 .free = LDKAccess_JCalls_free,
4709         };
4710         return ret;
4711 }
4712 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4713         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4714         *res_ptr = LDKAccess_init(o);
4715         return (long)res_ptr;
4716 }
4717 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4718         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4719         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4720         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
4721         unsigned char genesis_hash_arr[32];
4722         CHECK(*((uint32_t*)genesis_hash) == 32);
4723         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4724         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4725         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4726         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4727         return (uint64_t)ret_conv;
4728 }
4729
4730 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_AccessZ_ref_from_ptr(uint32_t ptr) {
4731         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
4732         switch(obj->tag) {
4733                 case LDKCOption_AccessZ_Some: {
4734                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
4735                         *some_ret = obj->some;
4736                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
4737                         return 0 /* LDKCOption_AccessZ - Some */; (void) (uint64_t)some_ret;
4738                 }
4739                 case LDKCOption_AccessZ_None: {
4740                         return 0 /* LDKCOption_AccessZ - None */;
4741                 }
4742                 default: abort();
4743         }
4744 }
4745 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
4746         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
4747 }
4748 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
4749         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4750         CHECK(val->result_ok);
4751         LDKDirectionalChannelInfo res_var = (*val->contents.result);
4752         uint64_t res_ref = 0;
4753         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4754         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4755         res_ref = (uint64_t)res_var.inner & ~1;
4756         return res_ref;
4757 }
4758 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
4759         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4760         CHECK(!val->result_ok);
4761         LDKDecodeError err_var = (*val->contents.err);
4762         uint64_t err_ref = 0;
4763         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4764         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4765         err_ref = (uint64_t)err_var.inner & ~1;
4766         return err_ref;
4767 }
4768 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
4769         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
4770 }
4771 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
4772         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4773         CHECK(val->result_ok);
4774         LDKChannelInfo res_var = (*val->contents.result);
4775         uint64_t res_ref = 0;
4776         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4777         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4778         res_ref = (uint64_t)res_var.inner & ~1;
4779         return res_ref;
4780 }
4781 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
4782         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4783         CHECK(!val->result_ok);
4784         LDKDecodeError err_var = (*val->contents.err);
4785         uint64_t err_ref = 0;
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         err_ref = (uint64_t)err_var.inner & ~1;
4789         return err_ref;
4790 }
4791 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
4792         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
4793 }
4794 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
4795         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4796         CHECK(val->result_ok);
4797         LDKRoutingFees res_var = (*val->contents.result);
4798         uint64_t res_ref = 0;
4799         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4800         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4801         res_ref = (uint64_t)res_var.inner & ~1;
4802         return res_ref;
4803 }
4804 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
4805         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4806         CHECK(!val->result_ok);
4807         LDKDecodeError err_var = (*val->contents.err);
4808         uint64_t err_ref = 0;
4809         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4810         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4811         err_ref = (uint64_t)err_var.inner & ~1;
4812         return err_ref;
4813 }
4814 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
4815         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
4816 }
4817 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
4818         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4819         CHECK(val->result_ok);
4820         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
4821         uint64_t res_ref = 0;
4822         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4823         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4824         res_ref = (uint64_t)res_var.inner & ~1;
4825         return res_ref;
4826 }
4827 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
4828         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4829         CHECK(!val->result_ok);
4830         LDKDecodeError err_var = (*val->contents.err);
4831         uint64_t err_ref = 0;
4832         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4833         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4834         err_ref = (uint64_t)err_var.inner & ~1;
4835         return err_ref;
4836 }
4837 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
4838         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
4839         ret->datalen = *((uint32_t*)elems);
4840         if (ret->datalen == 0) {
4841                 ret->data = NULL;
4842         } else {
4843                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
4844                 int64_t *java_elems = (int64_t*)(elems + 4);
4845                 for (size_t i = 0; i < ret->datalen; i++) {
4846                         ret->data[i] = java_elems[i];
4847                 }
4848         }
4849         return (uint64_t)ret;
4850 }
4851 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
4852         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
4853         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
4854         return ret;
4855 }
4856 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
4857         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
4858 }
4859 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
4860         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
4861         CHECK(val->result_ok);
4862         LDKNodeInfo res_var = (*val->contents.result);
4863         uint64_t res_ref = 0;
4864         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4865         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4866         res_ref = (uint64_t)res_var.inner & ~1;
4867         return res_ref;
4868 }
4869 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
4870         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
4871         CHECK(!val->result_ok);
4872         LDKDecodeError err_var = (*val->contents.err);
4873         uint64_t err_ref = 0;
4874         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4875         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4876         err_ref = (uint64_t)err_var.inner & ~1;
4877         return err_ref;
4878 }
4879 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
4880         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
4881 }
4882 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
4883         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
4884         CHECK(val->result_ok);
4885         LDKNetworkGraph res_var = (*val->contents.result);
4886         uint64_t res_ref = 0;
4887         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4888         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4889         res_ref = (uint64_t)res_var.inner & ~1;
4890         return res_ref;
4891 }
4892 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
4893         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
4894         CHECK(!val->result_ok);
4895         LDKDecodeError err_var = (*val->contents.err);
4896         uint64_t err_ref = 0;
4897         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4898         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4899         err_ref = (uint64_t)err_var.inner & ~1;
4900         return err_ref;
4901 }
4902 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_CVec_NetAddressZZ_ref_from_ptr(uint32_t ptr) {
4903         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
4904         switch(obj->tag) {
4905                 case LDKCOption_CVec_NetAddressZZ_Some: {
4906                         LDKCVec_NetAddressZ some_var = obj->some;
4907                         uint32_tArray some_arr = NULL;
4908                         some_arr = init_arr(some_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4909                         uint32_t *some_arr_ptr = (uint32_t*)(some_arr + 4);
4910                         for (size_t m = 0; m < some_var.datalen; m++) {
4911                                 uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
4912                                 some_arr_ptr[m] = some_conv_12_ref;
4913                         }
4914                         
4915                         return 0 /* LDKCOption_CVec_NetAddressZZ - Some */; (void) some_arr;
4916                 }
4917                 case LDKCOption_CVec_NetAddressZZ_None: {
4918                         return 0 /* LDKCOption_CVec_NetAddressZZ - None */;
4919                 }
4920                 default: abort();
4921         }
4922 }
4923 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_result_ok(uint32_t arg) {
4924         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
4925 }
4926 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_ok(uint32_t arg) {
4927         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
4928         CHECK(val->result_ok);
4929         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4930         return res_ref;
4931 }
4932 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_err(uint32_t arg) {
4933         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
4934         CHECK(!val->result_ok);
4935         LDKDecodeError err_var = (*val->contents.err);
4936         uint64_t err_ref = 0;
4937         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4938         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4939         err_ref = (uint64_t)err_var.inner & ~1;
4940         return err_ref;
4941 }
4942 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
4943         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
4944         ret->datalen = *((uint32_t*)elems);
4945         if (ret->datalen == 0) {
4946                 ret->data = NULL;
4947         } else {
4948                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
4949                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4950                 for (size_t i = 0; i < ret->datalen; i++) {
4951                         uint32_t arr_elem = java_elems[i];
4952                         LDKUpdateAddHTLC arr_elem_conv;
4953                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4954                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4955                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
4956                         ret->data[i] = arr_elem_conv;
4957                 }
4958         }
4959         return (uint64_t)ret;
4960 }
4961 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
4962         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
4963         for (size_t i = 0; i < ret.datalen; i++) {
4964                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
4965         }
4966         return ret;
4967 }
4968 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
4969         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
4970         ret->datalen = *((uint32_t*)elems);
4971         if (ret->datalen == 0) {
4972                 ret->data = NULL;
4973         } else {
4974                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
4975                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4976                 for (size_t i = 0; i < ret->datalen; i++) {
4977                         uint32_t arr_elem = java_elems[i];
4978                         LDKUpdateFulfillHTLC arr_elem_conv;
4979                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4980                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4981                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
4982                         ret->data[i] = arr_elem_conv;
4983                 }
4984         }
4985         return (uint64_t)ret;
4986 }
4987 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
4988         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
4989         for (size_t i = 0; i < ret.datalen; i++) {
4990                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
4991         }
4992         return ret;
4993 }
4994 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
4995         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
4996         ret->datalen = *((uint32_t*)elems);
4997         if (ret->datalen == 0) {
4998                 ret->data = NULL;
4999         } else {
5000                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
5001                 uint32_t *java_elems = (uint32_t*)(elems + 4);
5002                 for (size_t i = 0; i < ret->datalen; i++) {
5003                         uint32_t arr_elem = java_elems[i];
5004                         LDKUpdateFailHTLC arr_elem_conv;
5005                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5006                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5007                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
5008                         ret->data[i] = arr_elem_conv;
5009                 }
5010         }
5011         return (uint64_t)ret;
5012 }
5013 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
5014         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
5015         for (size_t i = 0; i < ret.datalen; i++) {
5016                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
5017         }
5018         return ret;
5019 }
5020 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
5021         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
5022         ret->datalen = *((uint32_t*)elems);
5023         if (ret->datalen == 0) {
5024                 ret->data = NULL;
5025         } else {
5026                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
5027                 uint32_t *java_elems = (uint32_t*)(elems + 4);
5028                 for (size_t i = 0; i < ret->datalen; i++) {
5029                         uint32_t arr_elem = java_elems[i];
5030                         LDKUpdateFailMalformedHTLC arr_elem_conv;
5031                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5032                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5033                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
5034                         ret->data[i] = arr_elem_conv;
5035                 }
5036         }
5037         return (uint64_t)ret;
5038 }
5039 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
5040         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
5041         for (size_t i = 0; i < ret.datalen; i++) {
5042                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
5043         }
5044         return ret;
5045 }
5046 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
5047         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
5048 }
5049 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
5050         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5051         CHECK(val->result_ok);
5052         LDKAcceptChannel res_var = (*val->contents.result);
5053         uint64_t res_ref = 0;
5054         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5055         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5056         res_ref = (uint64_t)res_var.inner & ~1;
5057         return res_ref;
5058 }
5059 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
5060         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5061         CHECK(!val->result_ok);
5062         LDKDecodeError err_var = (*val->contents.err);
5063         uint64_t err_ref = 0;
5064         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5065         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5066         err_ref = (uint64_t)err_var.inner & ~1;
5067         return err_ref;
5068 }
5069 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
5070         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
5071 }
5072 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
5073         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5074         CHECK(val->result_ok);
5075         LDKAnnouncementSignatures res_var = (*val->contents.result);
5076         uint64_t res_ref = 0;
5077         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5078         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5079         res_ref = (uint64_t)res_var.inner & ~1;
5080         return res_ref;
5081 }
5082 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
5083         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5084         CHECK(!val->result_ok);
5085         LDKDecodeError err_var = (*val->contents.err);
5086         uint64_t err_ref = 0;
5087         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5088         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5089         err_ref = (uint64_t)err_var.inner & ~1;
5090         return err_ref;
5091 }
5092 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
5093         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
5094 }
5095 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
5096         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5097         CHECK(val->result_ok);
5098         LDKChannelReestablish res_var = (*val->contents.result);
5099         uint64_t res_ref = 0;
5100         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5101         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5102         res_ref = (uint64_t)res_var.inner & ~1;
5103         return res_ref;
5104 }
5105 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
5106         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5107         CHECK(!val->result_ok);
5108         LDKDecodeError err_var = (*val->contents.err);
5109         uint64_t err_ref = 0;
5110         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5111         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5112         err_ref = (uint64_t)err_var.inner & ~1;
5113         return err_ref;
5114 }
5115 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
5116         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
5117 }
5118 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
5119         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5120         CHECK(val->result_ok);
5121         LDKClosingSigned res_var = (*val->contents.result);
5122         uint64_t res_ref = 0;
5123         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5124         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5125         res_ref = (uint64_t)res_var.inner & ~1;
5126         return res_ref;
5127 }
5128 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
5129         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5130         CHECK(!val->result_ok);
5131         LDKDecodeError err_var = (*val->contents.err);
5132         uint64_t err_ref = 0;
5133         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5134         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5135         err_ref = (uint64_t)err_var.inner & ~1;
5136         return err_ref;
5137 }
5138 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_result_ok(uint32_t arg) {
5139         return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok;
5140 }
5141 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t arg) {
5142         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
5143         CHECK(val->result_ok);
5144         LDKClosingSignedFeeRange res_var = (*val->contents.result);
5145         uint64_t res_ref = 0;
5146         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5147         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5148         res_ref = (uint64_t)res_var.inner & ~1;
5149         return res_ref;
5150 }
5151 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t arg) {
5152         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
5153         CHECK(!val->result_ok);
5154         LDKDecodeError err_var = (*val->contents.err);
5155         uint64_t err_ref = 0;
5156         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5157         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5158         err_ref = (uint64_t)err_var.inner & ~1;
5159         return err_ref;
5160 }
5161 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
5162         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
5163 }
5164 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
5165         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5166         CHECK(val->result_ok);
5167         LDKCommitmentSigned res_var = (*val->contents.result);
5168         uint64_t res_ref = 0;
5169         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5170         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5171         res_ref = (uint64_t)res_var.inner & ~1;
5172         return res_ref;
5173 }
5174 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
5175         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5176         CHECK(!val->result_ok);
5177         LDKDecodeError err_var = (*val->contents.err);
5178         uint64_t err_ref = 0;
5179         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5180         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5181         err_ref = (uint64_t)err_var.inner & ~1;
5182         return err_ref;
5183 }
5184 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
5185         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
5186 }
5187 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
5188         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5189         CHECK(val->result_ok);
5190         LDKFundingCreated res_var = (*val->contents.result);
5191         uint64_t res_ref = 0;
5192         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5193         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5194         res_ref = (uint64_t)res_var.inner & ~1;
5195         return res_ref;
5196 }
5197 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
5198         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5199         CHECK(!val->result_ok);
5200         LDKDecodeError err_var = (*val->contents.err);
5201         uint64_t err_ref = 0;
5202         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5203         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5204         err_ref = (uint64_t)err_var.inner & ~1;
5205         return err_ref;
5206 }
5207 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
5208         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
5209 }
5210 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
5211         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5212         CHECK(val->result_ok);
5213         LDKFundingSigned res_var = (*val->contents.result);
5214         uint64_t res_ref = 0;
5215         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5216         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5217         res_ref = (uint64_t)res_var.inner & ~1;
5218         return res_ref;
5219 }
5220 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
5221         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5222         CHECK(!val->result_ok);
5223         LDKDecodeError err_var = (*val->contents.err);
5224         uint64_t err_ref = 0;
5225         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5226         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5227         err_ref = (uint64_t)err_var.inner & ~1;
5228         return err_ref;
5229 }
5230 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
5231         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
5232 }
5233 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
5234         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5235         CHECK(val->result_ok);
5236         LDKFundingLocked res_var = (*val->contents.result);
5237         uint64_t res_ref = 0;
5238         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5239         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5240         res_ref = (uint64_t)res_var.inner & ~1;
5241         return res_ref;
5242 }
5243 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
5244         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5245         CHECK(!val->result_ok);
5246         LDKDecodeError err_var = (*val->contents.err);
5247         uint64_t err_ref = 0;
5248         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5249         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5250         err_ref = (uint64_t)err_var.inner & ~1;
5251         return err_ref;
5252 }
5253 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
5254         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
5255 }
5256 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
5257         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5258         CHECK(val->result_ok);
5259         LDKInit res_var = (*val->contents.result);
5260         uint64_t res_ref = 0;
5261         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5262         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5263         res_ref = (uint64_t)res_var.inner & ~1;
5264         return res_ref;
5265 }
5266 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
5267         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5268         CHECK(!val->result_ok);
5269         LDKDecodeError err_var = (*val->contents.err);
5270         uint64_t err_ref = 0;
5271         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5272         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5273         err_ref = (uint64_t)err_var.inner & ~1;
5274         return err_ref;
5275 }
5276 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
5277         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
5278 }
5279 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
5280         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5281         CHECK(val->result_ok);
5282         LDKOpenChannel res_var = (*val->contents.result);
5283         uint64_t res_ref = 0;
5284         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5285         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5286         res_ref = (uint64_t)res_var.inner & ~1;
5287         return res_ref;
5288 }
5289 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
5290         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5291         CHECK(!val->result_ok);
5292         LDKDecodeError err_var = (*val->contents.err);
5293         uint64_t err_ref = 0;
5294         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5295         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5296         err_ref = (uint64_t)err_var.inner & ~1;
5297         return err_ref;
5298 }
5299 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
5300         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5301 }
5302 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
5303         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5304         CHECK(val->result_ok);
5305         LDKRevokeAndACK res_var = (*val->contents.result);
5306         uint64_t res_ref = 0;
5307         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5308         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5309         res_ref = (uint64_t)res_var.inner & ~1;
5310         return res_ref;
5311 }
5312 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
5313         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5314         CHECK(!val->result_ok);
5315         LDKDecodeError err_var = (*val->contents.err);
5316         uint64_t err_ref = 0;
5317         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5318         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5319         err_ref = (uint64_t)err_var.inner & ~1;
5320         return err_ref;
5321 }
5322 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
5323         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5324 }
5325 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
5326         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5327         CHECK(val->result_ok);
5328         LDKShutdown res_var = (*val->contents.result);
5329         uint64_t res_ref = 0;
5330         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5331         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5332         res_ref = (uint64_t)res_var.inner & ~1;
5333         return res_ref;
5334 }
5335 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
5336         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5337         CHECK(!val->result_ok);
5338         LDKDecodeError err_var = (*val->contents.err);
5339         uint64_t err_ref = 0;
5340         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5341         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5342         err_ref = (uint64_t)err_var.inner & ~1;
5343         return err_ref;
5344 }
5345 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
5346         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5347 }
5348 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
5349         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5350         CHECK(val->result_ok);
5351         LDKUpdateFailHTLC res_var = (*val->contents.result);
5352         uint64_t res_ref = 0;
5353         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5354         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5355         res_ref = (uint64_t)res_var.inner & ~1;
5356         return res_ref;
5357 }
5358 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
5359         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5360         CHECK(!val->result_ok);
5361         LDKDecodeError err_var = (*val->contents.err);
5362         uint64_t err_ref = 0;
5363         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5364         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5365         err_ref = (uint64_t)err_var.inner & ~1;
5366         return err_ref;
5367 }
5368 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
5369         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5370 }
5371 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
5372         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5373         CHECK(val->result_ok);
5374         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5375         uint64_t res_ref = 0;
5376         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5377         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5378         res_ref = (uint64_t)res_var.inner & ~1;
5379         return res_ref;
5380 }
5381 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
5382         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5383         CHECK(!val->result_ok);
5384         LDKDecodeError err_var = (*val->contents.err);
5385         uint64_t err_ref = 0;
5386         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5387         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5388         err_ref = (uint64_t)err_var.inner & ~1;
5389         return err_ref;
5390 }
5391 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
5392         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5393 }
5394 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
5395         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5396         CHECK(val->result_ok);
5397         LDKUpdateFee res_var = (*val->contents.result);
5398         uint64_t res_ref = 0;
5399         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5400         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5401         res_ref = (uint64_t)res_var.inner & ~1;
5402         return res_ref;
5403 }
5404 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
5405         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5406         CHECK(!val->result_ok);
5407         LDKDecodeError err_var = (*val->contents.err);
5408         uint64_t err_ref = 0;
5409         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5410         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5411         err_ref = (uint64_t)err_var.inner & ~1;
5412         return err_ref;
5413 }
5414 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
5415         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5416 }
5417 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
5418         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5419         CHECK(val->result_ok);
5420         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5421         uint64_t res_ref = 0;
5422         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5423         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5424         res_ref = (uint64_t)res_var.inner & ~1;
5425         return res_ref;
5426 }
5427 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
5428         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5429         CHECK(!val->result_ok);
5430         LDKDecodeError err_var = (*val->contents.err);
5431         uint64_t err_ref = 0;
5432         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5433         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5434         err_ref = (uint64_t)err_var.inner & ~1;
5435         return err_ref;
5436 }
5437 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
5438         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5439 }
5440 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
5441         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5442         CHECK(val->result_ok);
5443         LDKUpdateAddHTLC res_var = (*val->contents.result);
5444         uint64_t res_ref = 0;
5445         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5446         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5447         res_ref = (uint64_t)res_var.inner & ~1;
5448         return res_ref;
5449 }
5450 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
5451         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5452         CHECK(!val->result_ok);
5453         LDKDecodeError err_var = (*val->contents.err);
5454         uint64_t err_ref = 0;
5455         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5456         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5457         err_ref = (uint64_t)err_var.inner & ~1;
5458         return err_ref;
5459 }
5460 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
5461         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5462 }
5463 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
5464         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5465         CHECK(val->result_ok);
5466         LDKPing res_var = (*val->contents.result);
5467         uint64_t res_ref = 0;
5468         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5469         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5470         res_ref = (uint64_t)res_var.inner & ~1;
5471         return res_ref;
5472 }
5473 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
5474         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5475         CHECK(!val->result_ok);
5476         LDKDecodeError err_var = (*val->contents.err);
5477         uint64_t err_ref = 0;
5478         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5479         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5480         err_ref = (uint64_t)err_var.inner & ~1;
5481         return err_ref;
5482 }
5483 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
5484         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5485 }
5486 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
5487         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5488         CHECK(val->result_ok);
5489         LDKPong res_var = (*val->contents.result);
5490         uint64_t res_ref = 0;
5491         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5492         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5493         res_ref = (uint64_t)res_var.inner & ~1;
5494         return res_ref;
5495 }
5496 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
5497         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5498         CHECK(!val->result_ok);
5499         LDKDecodeError err_var = (*val->contents.err);
5500         uint64_t err_ref = 0;
5501         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5502         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5503         err_ref = (uint64_t)err_var.inner & ~1;
5504         return err_ref;
5505 }
5506 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5507         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5508 }
5509 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5510         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5511         CHECK(val->result_ok);
5512         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5513         uint64_t res_ref = 0;
5514         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5515         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5516         res_ref = (uint64_t)res_var.inner & ~1;
5517         return res_ref;
5518 }
5519 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5520         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5521         CHECK(!val->result_ok);
5522         LDKDecodeError err_var = (*val->contents.err);
5523         uint64_t err_ref = 0;
5524         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5525         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5526         err_ref = (uint64_t)err_var.inner & ~1;
5527         return err_ref;
5528 }
5529 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5530         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5531 }
5532 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5533         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5534         CHECK(val->result_ok);
5535         LDKChannelAnnouncement res_var = (*val->contents.result);
5536         uint64_t res_ref = 0;
5537         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5538         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5539         res_ref = (uint64_t)res_var.inner & ~1;
5540         return res_ref;
5541 }
5542 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5543         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5544         CHECK(!val->result_ok);
5545         LDKDecodeError err_var = (*val->contents.err);
5546         uint64_t err_ref = 0;
5547         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5548         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5549         err_ref = (uint64_t)err_var.inner & ~1;
5550         return err_ref;
5551 }
5552 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
5553         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5554 }
5555 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
5556         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5557         CHECK(val->result_ok);
5558         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5559         uint64_t res_ref = 0;
5560         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5561         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5562         res_ref = (uint64_t)res_var.inner & ~1;
5563         return res_ref;
5564 }
5565 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
5566         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5567         CHECK(!val->result_ok);
5568         LDKDecodeError err_var = (*val->contents.err);
5569         uint64_t err_ref = 0;
5570         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5571         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5572         err_ref = (uint64_t)err_var.inner & ~1;
5573         return err_ref;
5574 }
5575 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
5576         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
5577 }
5578 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
5579         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5580         CHECK(val->result_ok);
5581         LDKChannelUpdate res_var = (*val->contents.result);
5582         uint64_t res_ref = 0;
5583         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5584         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5585         res_ref = (uint64_t)res_var.inner & ~1;
5586         return res_ref;
5587 }
5588 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
5589         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5590         CHECK(!val->result_ok);
5591         LDKDecodeError err_var = (*val->contents.err);
5592         uint64_t err_ref = 0;
5593         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5594         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5595         err_ref = (uint64_t)err_var.inner & ~1;
5596         return err_ref;
5597 }
5598 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
5599         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
5600 }
5601 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
5602         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5603         CHECK(val->result_ok);
5604         LDKErrorMessage res_var = (*val->contents.result);
5605         uint64_t res_ref = 0;
5606         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5607         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5608         res_ref = (uint64_t)res_var.inner & ~1;
5609         return res_ref;
5610 }
5611 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
5612         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5613         CHECK(!val->result_ok);
5614         LDKDecodeError err_var = (*val->contents.err);
5615         uint64_t err_ref = 0;
5616         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5617         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5618         err_ref = (uint64_t)err_var.inner & ~1;
5619         return err_ref;
5620 }
5621 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5622         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5623 }
5624 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5625         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5626         CHECK(val->result_ok);
5627         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5628         uint64_t res_ref = 0;
5629         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5630         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5631         res_ref = (uint64_t)res_var.inner & ~1;
5632         return res_ref;
5633 }
5634 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5635         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5636         CHECK(!val->result_ok);
5637         LDKDecodeError err_var = (*val->contents.err);
5638         uint64_t err_ref = 0;
5639         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5640         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5641         err_ref = (uint64_t)err_var.inner & ~1;
5642         return err_ref;
5643 }
5644 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5645         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5646 }
5647 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5648         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5649         CHECK(val->result_ok);
5650         LDKNodeAnnouncement res_var = (*val->contents.result);
5651         uint64_t res_ref = 0;
5652         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5653         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5654         res_ref = (uint64_t)res_var.inner & ~1;
5655         return res_ref;
5656 }
5657 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5658         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5659         CHECK(!val->result_ok);
5660         LDKDecodeError err_var = (*val->contents.err);
5661         uint64_t err_ref = 0;
5662         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5663         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5664         err_ref = (uint64_t)err_var.inner & ~1;
5665         return err_ref;
5666 }
5667 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
5668         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
5669 }
5670 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
5671         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5672         CHECK(val->result_ok);
5673         LDKQueryShortChannelIds res_var = (*val->contents.result);
5674         uint64_t res_ref = 0;
5675         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5676         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5677         res_ref = (uint64_t)res_var.inner & ~1;
5678         return res_ref;
5679 }
5680 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
5681         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5682         CHECK(!val->result_ok);
5683         LDKDecodeError err_var = (*val->contents.err);
5684         uint64_t err_ref = 0;
5685         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5686         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5687         err_ref = (uint64_t)err_var.inner & ~1;
5688         return err_ref;
5689 }
5690 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
5691         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
5692 }
5693 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
5694         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5695         CHECK(val->result_ok);
5696         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5697         uint64_t res_ref = 0;
5698         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5699         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5700         res_ref = (uint64_t)res_var.inner & ~1;
5701         return res_ref;
5702 }
5703 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
5704         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5705         CHECK(!val->result_ok);
5706         LDKDecodeError err_var = (*val->contents.err);
5707         uint64_t err_ref = 0;
5708         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5709         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5710         err_ref = (uint64_t)err_var.inner & ~1;
5711         return err_ref;
5712 }
5713 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
5714         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
5715 }
5716 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
5717         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5718         CHECK(val->result_ok);
5719         LDKQueryChannelRange res_var = (*val->contents.result);
5720         uint64_t res_ref = 0;
5721         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5722         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5723         res_ref = (uint64_t)res_var.inner & ~1;
5724         return res_ref;
5725 }
5726 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
5727         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5728         CHECK(!val->result_ok);
5729         LDKDecodeError err_var = (*val->contents.err);
5730         uint64_t err_ref = 0;
5731         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5732         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5733         err_ref = (uint64_t)err_var.inner & ~1;
5734         return err_ref;
5735 }
5736 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
5737         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
5738 }
5739 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
5740         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5741         CHECK(val->result_ok);
5742         LDKReplyChannelRange res_var = (*val->contents.result);
5743         uint64_t res_ref = 0;
5744         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5745         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5746         res_ref = (uint64_t)res_var.inner & ~1;
5747         return res_ref;
5748 }
5749 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
5750         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5751         CHECK(!val->result_ok);
5752         LDKDecodeError err_var = (*val->contents.err);
5753         uint64_t err_ref = 0;
5754         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5755         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5756         err_ref = (uint64_t)err_var.inner & ~1;
5757         return err_ref;
5758 }
5759 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
5760         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
5761 }
5762 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
5763         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5764         CHECK(val->result_ok);
5765         LDKGossipTimestampFilter res_var = (*val->contents.result);
5766         uint64_t res_ref = 0;
5767         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5768         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5769         res_ref = (uint64_t)res_var.inner & ~1;
5770         return res_ref;
5771 }
5772 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
5773         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5774         CHECK(!val->result_ok);
5775         LDKDecodeError err_var = (*val->contents.err);
5776         uint64_t err_ref = 0;
5777         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5778         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5779         err_ref = (uint64_t)err_var.inner & ~1;
5780         return err_ref;
5781 }
5782 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
5783         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
5784         switch(obj->tag) {
5785                 case LDKSignOrCreationError_SignError: {
5786                         return 0 /* LDKSignOrCreationError - SignError */;
5787                 }
5788                 case LDKSignOrCreationError_CreationError: {
5789                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
5790                         return 0 /* LDKSignOrCreationError - CreationError */; (void) creation_error_conv;
5791                 }
5792                 default: abort();
5793         }
5794 }
5795 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_result_ok(uint32_t arg) {
5796         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
5797 }
5798 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t arg) {
5799         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5800         CHECK(val->result_ok);
5801         LDKInvoice res_var = (*val->contents.result);
5802         uint64_t res_ref = 0;
5803         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5804         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5805         res_ref = (uint64_t)res_var.inner & ~1;
5806         return res_ref;
5807 }
5808 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
5809         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5810         CHECK(!val->result_ok);
5811         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5812         return err_ref;
5813 }
5814 typedef struct LDKFilter_JCalls {
5815         atomic_size_t refcnt;
5816         uint32_t register_tx_meth;
5817         uint32_t register_output_meth;
5818 } LDKFilter_JCalls;
5819 static void LDKFilter_JCalls_free(void* this_arg) {
5820         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5821         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5822                 js_free(j_calls->register_tx_meth);
5823                 js_free(j_calls->register_output_meth);
5824                 FREE(j_calls);
5825         }
5826 }
5827 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5828         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5829         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5830         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5831         LDKu8slice script_pubkey_var = script_pubkey;
5832         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5833         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
5834         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5835 }
5836 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5837         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5838         LDKWatchedOutput output_var = output;
5839         uint64_t output_ref = 0;
5840         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5841         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5842         output_ref = (uint64_t)output_var.inner;
5843         if (output_var.is_owned) {
5844                 output_ref |= 1;
5845         }
5846         uint32_t ret = js_invoke_function_1(j_calls->register_output_meth, output_ref);
5847         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
5848         CHECK_ACCESS(ret_ptr);
5849         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
5850         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
5851         return ret_conv;
5852 }
5853 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
5854         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
5855         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5856 }
5857 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
5858         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5859         atomic_init(&calls->refcnt, 1);
5860         //TODO: Assign calls->o from o
5861
5862         LDKFilter ret = {
5863                 .this_arg = (void*) calls,
5864                 .register_tx = register_tx_LDKFilter_jcall,
5865                 .register_output = register_output_LDKFilter_jcall,
5866                 .free = LDKFilter_JCalls_free,
5867         };
5868         return ret;
5869 }
5870 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
5871         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5872         *res_ptr = LDKFilter_init(o);
5873         return (long)res_ptr;
5874 }
5875 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5876         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5877         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5878         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
5879         unsigned char txid_arr[32];
5880         CHECK(*((uint32_t*)txid) == 32);
5881         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5882         unsigned char (*txid_ref)[32] = &txid_arr;
5883         LDKu8slice script_pubkey_ref;
5884         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
5885         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
5886         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5887 }
5888
5889 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5890         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5891         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5892         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
5893         LDKWatchedOutput output_conv;
5894         output_conv.inner = (void*)(output & (~1));
5895         output_conv.is_owned = (output & 1) || (output == 0);
5896         output_conv = WatchedOutput_clone(&output_conv);
5897         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5898         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5899         uint64_t ret_ref = (uint64_t)ret_copy;
5900         return ret_ref;
5901 }
5902
5903 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_FilterZ_ref_from_ptr(uint32_t ptr) {
5904         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
5905         switch(obj->tag) {
5906                 case LDKCOption_FilterZ_Some: {
5907                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
5908                         *some_ret = obj->some;
5909                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
5910                         return 0 /* LDKCOption_FilterZ - Some */; (void) (uint64_t)some_ret;
5911                 }
5912                 case LDKCOption_FilterZ_None: {
5913                         return 0 /* LDKCOption_FilterZ - None */;
5914                 }
5915                 default: abort();
5916         }
5917 }
5918 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_result_ok(uint32_t arg) {
5919         return ((LDKCResult_LockedChannelMonitorNoneZ*)arg)->result_ok;
5920 }
5921 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_ok(uint32_t arg) {
5922         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
5923         CHECK(val->result_ok);
5924         LDKLockedChannelMonitor res_var = (*val->contents.result);
5925         uint64_t res_ref = 0;
5926         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5927         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5928         res_ref = (uint64_t)res_var.inner & ~1;
5929         return res_ref;
5930 }
5931 void  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_err(uint32_t arg) {
5932         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
5933         CHECK(!val->result_ok);
5934         return *val->contents.err;
5935 }
5936 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_OutPointZ_new(uint32_tArray elems) {
5937         LDKCVec_OutPointZ *ret = MALLOC(sizeof(LDKCVec_OutPointZ), "LDKCVec_OutPointZ");
5938         ret->datalen = *((uint32_t*)elems);
5939         if (ret->datalen == 0) {
5940                 ret->data = NULL;
5941         } else {
5942                 ret->data = MALLOC(sizeof(LDKOutPoint) * ret->datalen, "LDKCVec_OutPointZ Data");
5943                 uint32_t *java_elems = (uint32_t*)(elems + 4);
5944                 for (size_t i = 0; i < ret->datalen; i++) {
5945                         uint32_t arr_elem = java_elems[i];
5946                         LDKOutPoint arr_elem_conv;
5947                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5948                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5949                         arr_elem_conv = OutPoint_clone(&arr_elem_conv);
5950                         ret->data[i] = arr_elem_conv;
5951                 }
5952         }
5953         return (uint64_t)ret;
5954 }
5955 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
5956         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
5957         for (size_t i = 0; i < ret.datalen; i++) {
5958                 ret.data[i] = OutPoint_clone(&orig->data[i]);
5959         }
5960         return ret;
5961 }
5962 typedef struct LDKMessageSendEventsProvider_JCalls {
5963         atomic_size_t refcnt;
5964         uint32_t get_and_clear_pending_msg_events_meth;
5965 } LDKMessageSendEventsProvider_JCalls;
5966 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
5967         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5968         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5969                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
5970                 FREE(j_calls);
5971         }
5972 }
5973 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
5974         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5975         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
5976         LDKCVec_MessageSendEventZ ret_constr;
5977         ret_constr.datalen = *((uint32_t*)ret);
5978         if (ret_constr.datalen > 0)
5979                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
5980         else
5981                 ret_constr.data = NULL;
5982         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5983         for (size_t s = 0; s < ret_constr.datalen; s++) {
5984                 uint32_t ret_conv_18 = ret_vals[s];
5985                 void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
5986                 CHECK_ACCESS(ret_conv_18_ptr);
5987                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
5988                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
5989                 ret_constr.data[s] = ret_conv_18_conv;
5990         }
5991         return ret_constr;
5992 }
5993 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
5994         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
5995         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5996 }
5997 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
5998         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
5999         atomic_init(&calls->refcnt, 1);
6000         //TODO: Assign calls->o from o
6001
6002         LDKMessageSendEventsProvider ret = {
6003                 .this_arg = (void*) calls,
6004                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6005                 .free = LDKMessageSendEventsProvider_JCalls_free,
6006         };
6007         return ret;
6008 }
6009 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
6010         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6011         *res_ptr = LDKMessageSendEventsProvider_init(o);
6012         return (long)res_ptr;
6013 }
6014 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
6015         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6016         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6017         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
6018         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6019         uint32_tArray ret_arr = NULL;
6020         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6021         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6022         for (size_t s = 0; s < ret_var.datalen; s++) {
6023                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6024                 *ret_conv_18_copy = ret_var.data[s];
6025                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6026                 ret_arr_ptr[s] = ret_conv_18_ref;
6027         }
6028         
6029         FREE(ret_var.data);
6030         return ret_arr;
6031 }
6032
6033 typedef struct LDKEventHandler_JCalls {
6034         atomic_size_t refcnt;
6035         uint32_t handle_event_meth;
6036 } LDKEventHandler_JCalls;
6037 static void LDKEventHandler_JCalls_free(void* this_arg) {
6038         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6039         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6040                 js_free(j_calls->handle_event_meth);
6041                 FREE(j_calls);
6042         }
6043 }
6044 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
6045         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6046         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
6047         *ret_event = Event_clone(event);
6048         js_invoke_function_1(j_calls->handle_event_meth, (uint64_t)ret_event);
6049 }
6050 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
6051         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
6052         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6053 }
6054 static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) {
6055         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6056         atomic_init(&calls->refcnt, 1);
6057         //TODO: Assign calls->o from o
6058
6059         LDKEventHandler ret = {
6060                 .this_arg = (void*) calls,
6061                 .handle_event = handle_event_LDKEventHandler_jcall,
6062                 .free = LDKEventHandler_JCalls_free,
6063         };
6064         return ret;
6065 }
6066 long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS Object Reference */void* o) {
6067         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6068         *res_ptr = LDKEventHandler_init(o);
6069         return (long)res_ptr;
6070 }
6071 void  __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
6072         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6073         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6074         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
6075         LDKEvent* event_conv = (LDKEvent*)event;
6076         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6077 }
6078
6079 typedef struct LDKEventsProvider_JCalls {
6080         atomic_size_t refcnt;
6081         uint32_t process_pending_events_meth;
6082 } LDKEventsProvider_JCalls;
6083 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6084         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6085         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6086                 js_free(j_calls->process_pending_events_meth);
6087                 FREE(j_calls);
6088         }
6089 }
6090 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6091         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6092         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6093         *handler_ret = handler;
6094         js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)handler_ret);
6095 }
6096 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
6097         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
6098         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6099 }
6100 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
6101         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6102         atomic_init(&calls->refcnt, 1);
6103         //TODO: Assign calls->o from o
6104
6105         LDKEventsProvider ret = {
6106                 .this_arg = (void*) calls,
6107                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6108                 .free = LDKEventsProvider_JCalls_free,
6109         };
6110         return ret;
6111 }
6112 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
6113         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6114         *res_ptr = LDKEventsProvider_init(o);
6115         return (long)res_ptr;
6116 }
6117 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
6118         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6119         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6120         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
6121         void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
6122         CHECK_ACCESS(handler_ptr);
6123         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
6124         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6125 }
6126
6127 typedef struct LDKListen_JCalls {
6128         atomic_size_t refcnt;
6129         uint32_t block_connected_meth;
6130         uint32_t block_disconnected_meth;
6131 } LDKListen_JCalls;
6132 static void LDKListen_JCalls_free(void* this_arg) {
6133         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6134         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6135                 js_free(j_calls->block_connected_meth);
6136                 js_free(j_calls->block_disconnected_meth);
6137                 FREE(j_calls);
6138         }
6139 }
6140 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6141         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6142         LDKu8slice block_var = block;
6143         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6144         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
6145         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
6146 }
6147 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6148         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6149         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
6150         memcpy((uint8_t*)(header_arr + 4), *header, 80);
6151         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
6152 }
6153 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
6154         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
6155         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6156 }
6157 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
6158         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6159         atomic_init(&calls->refcnt, 1);
6160         //TODO: Assign calls->o from o
6161
6162         LDKListen ret = {
6163                 .this_arg = (void*) calls,
6164                 .block_connected = block_connected_LDKListen_jcall,
6165                 .block_disconnected = block_disconnected_LDKListen_jcall,
6166                 .free = LDKListen_JCalls_free,
6167         };
6168         return ret;
6169 }
6170 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
6171         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
6172         *res_ptr = LDKListen_init(o);
6173         return (long)res_ptr;
6174 }
6175 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
6176         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6177         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6178         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
6179         LDKu8slice block_ref;
6180         block_ref.datalen = *((uint32_t*)block);
6181         block_ref.data = (int8_t*)(block + 4);
6182         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
6183 }
6184
6185 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
6186         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6187         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6188         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
6189         unsigned char header_arr[80];
6190         CHECK(*((uint32_t*)header) == 80);
6191         memcpy(header_arr, (uint8_t*)(header + 4), 80);
6192         unsigned char (*header_ref)[80] = &header_arr;
6193         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
6194 }
6195
6196 typedef struct LDKConfirm_JCalls {
6197         atomic_size_t refcnt;
6198         uint32_t transactions_confirmed_meth;
6199         uint32_t transaction_unconfirmed_meth;
6200         uint32_t best_block_updated_meth;
6201         uint32_t get_relevant_txids_meth;
6202 } LDKConfirm_JCalls;
6203 static void LDKConfirm_JCalls_free(void* this_arg) {
6204         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6205         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6206                 js_free(j_calls->transactions_confirmed_meth);
6207                 js_free(j_calls->transaction_unconfirmed_meth);
6208                 js_free(j_calls->best_block_updated_meth);
6209                 js_free(j_calls->get_relevant_txids_meth);
6210                 FREE(j_calls);
6211         }
6212 }
6213 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
6214         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6215         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
6216         memcpy((uint8_t*)(header_arr + 4), *header, 80);
6217         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
6218         uint32_tArray txdata_arr = NULL;
6219         txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6220         uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
6221         for (size_t c = 0; c < txdata_var.datalen; c++) {
6222                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6223                 *txdata_conv_28_conv = txdata_var.data[c];
6224                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
6225         }
6226         
6227         FREE(txdata_var.data);
6228         js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
6229 }
6230 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
6231         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6232         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
6233         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
6234         js_invoke_function_1(j_calls->transaction_unconfirmed_meth, txid_arr);
6235 }
6236 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6237         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6238         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
6239         memcpy((uint8_t*)(header_arr + 4), *header, 80);
6240         js_invoke_function_2(j_calls->best_block_updated_meth, header_arr, height);
6241 }
6242 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
6243         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6244         ptrArray ret = js_invoke_function_0(j_calls->get_relevant_txids_meth);
6245         LDKCVec_TxidZ ret_constr;
6246         ret_constr.datalen = *((uint32_t*)ret);
6247         if (ret_constr.datalen > 0)
6248                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6249         else
6250                 ret_constr.data = NULL;
6251         int8_tArray* ret_vals = (int8_tArray*)(ret + 4);
6252         for (size_t m = 0; m < ret_constr.datalen; m++) {
6253                 int8_tArray ret_conv_12 = ret_vals[m];
6254                 LDKThirtyTwoBytes ret_conv_12_ref;
6255                 CHECK(*((uint32_t*)ret_conv_12) == 32);
6256                 memcpy(ret_conv_12_ref.data, (uint8_t*)(ret_conv_12 + 4), 32);
6257                 ret_constr.data[m] = ret_conv_12_ref;
6258         }
6259         return ret_constr;
6260 }
6261 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
6262         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
6263         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6264 }
6265 static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) {
6266         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
6267         atomic_init(&calls->refcnt, 1);
6268         //TODO: Assign calls->o from o
6269
6270         LDKConfirm ret = {
6271                 .this_arg = (void*) calls,
6272                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
6273                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
6274                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
6275                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
6276                 .free = LDKConfirm_JCalls_free,
6277         };
6278         return ret;
6279 }
6280 long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object Reference */void* o) {
6281         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
6282         *res_ptr = LDKConfirm_init(o);
6283         return (long)res_ptr;
6284 }
6285 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
6286         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6287         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6288         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
6289         unsigned char header_arr[80];
6290         CHECK(*((uint32_t*)header) == 80);
6291         memcpy(header_arr, (uint8_t*)(header + 4), 80);
6292         unsigned char (*header_ref)[80] = &header_arr;
6293         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6294         txdata_constr.datalen = *((uint32_t*)txdata);
6295         if (txdata_constr.datalen > 0)
6296                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6297         else
6298                 txdata_constr.data = NULL;
6299         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
6300         for (size_t c = 0; c < txdata_constr.datalen; c++) {
6301                 uint32_t txdata_conv_28 = txdata_vals[c];
6302                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
6303                 CHECK_ACCESS(txdata_conv_28_ptr);
6304                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
6305                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
6306                 txdata_constr.data[c] = txdata_conv_28_conv;
6307         }
6308         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
6309 }
6310
6311 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
6312         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6313         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6314         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
6315         unsigned char txid_arr[32];
6316         CHECK(*((uint32_t*)txid) == 32);
6317         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
6318         unsigned char (*txid_ref)[32] = &txid_arr;
6319         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
6320 }
6321
6322 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
6323         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6324         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6325         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
6326         unsigned char header_arr[80];
6327         CHECK(*((uint32_t*)header) == 80);
6328         memcpy(header_arr, (uint8_t*)(header + 4), 80);
6329         unsigned char (*header_ref)[80] = &header_arr;
6330         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
6331 }
6332
6333 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
6334         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6335         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6336         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
6337         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
6338         ptrArray ret_arr = NULL;
6339         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
6340         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
6341         for (size_t m = 0; m < ret_var.datalen; m++) {
6342                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
6343                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
6344                 ret_arr_ptr[m] = ret_conv_12_arr;
6345         }
6346         
6347         FREE(ret_var.data);
6348         return ret_arr;
6349 }
6350
6351 typedef struct LDKPersist_JCalls {
6352         atomic_size_t refcnt;
6353         uint32_t persist_new_channel_meth;
6354         uint32_t update_persisted_channel_meth;
6355 } LDKPersist_JCalls;
6356 static void LDKPersist_JCalls_free(void* this_arg) {
6357         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6358         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6359                 js_free(j_calls->persist_new_channel_meth);
6360                 js_free(j_calls->update_persisted_channel_meth);
6361                 FREE(j_calls);
6362         }
6363 }
6364 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
6365         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6366         LDKOutPoint channel_id_var = channel_id;
6367         uint64_t channel_id_ref = 0;
6368         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6369         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6370         channel_id_ref = (uint64_t)channel_id_var.inner;
6371         if (channel_id_var.is_owned) {
6372                 channel_id_ref |= 1;
6373         }
6374         LDKChannelMonitor data_var = *data;
6375         uint64_t data_ref = 0;
6376         data_var = ChannelMonitor_clone(data);
6377         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6378         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6379         data_ref = (uint64_t)data_var.inner;
6380         if (data_var.is_owned) {
6381                 data_ref |= 1;
6382         }
6383         LDKMonitorUpdateId update_id_var = update_id;
6384         uint64_t update_id_ref = 0;
6385         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6386         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6387         update_id_ref = (uint64_t)update_id_var.inner;
6388         if (update_id_var.is_owned) {
6389                 update_id_ref |= 1;
6390         }
6391         uint32_t ret = js_invoke_function_3(j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
6392         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6393         CHECK_ACCESS(ret_ptr);
6394         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6395         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6396         return ret_conv;
6397 }
6398 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
6399         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6400         LDKOutPoint channel_id_var = channel_id;
6401         uint64_t channel_id_ref = 0;
6402         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6403         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6404         channel_id_ref = (uint64_t)channel_id_var.inner;
6405         if (channel_id_var.is_owned) {
6406                 channel_id_ref |= 1;
6407         }
6408         LDKChannelMonitorUpdate update_var = *update;
6409         uint64_t update_ref = 0;
6410         if ((uint64_t)update_var.inner > 4096) {
6411                 update_var = ChannelMonitorUpdate_clone(update);
6412                 CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6413                 CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6414                 update_ref = (uint64_t)update_var.inner;
6415                 if (update_var.is_owned) {
6416                         update_ref |= 1;
6417                 }
6418         }
6419         LDKChannelMonitor data_var = *data;
6420         uint64_t data_ref = 0;
6421         data_var = ChannelMonitor_clone(data);
6422         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6423         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6424         data_ref = (uint64_t)data_var.inner;
6425         if (data_var.is_owned) {
6426                 data_ref |= 1;
6427         }
6428         LDKMonitorUpdateId update_id_var = update_id;
6429         uint64_t update_id_ref = 0;
6430         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6431         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6432         update_id_ref = (uint64_t)update_id_var.inner;
6433         if (update_id_var.is_owned) {
6434                 update_id_ref |= 1;
6435         }
6436         uint32_t ret = js_invoke_function_4(j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
6437         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6438         CHECK_ACCESS(ret_ptr);
6439         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6440         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6441         return ret_conv;
6442 }
6443 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
6444         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
6445         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6446 }
6447 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
6448         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
6449         atomic_init(&calls->refcnt, 1);
6450         //TODO: Assign calls->o from o
6451
6452         LDKPersist ret = {
6453                 .this_arg = (void*) calls,
6454                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
6455                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
6456                 .free = LDKPersist_JCalls_free,
6457         };
6458         return ret;
6459 }
6460 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
6461         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
6462         *res_ptr = LDKPersist_init(o);
6463         return (long)res_ptr;
6464 }
6465 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t channel_id, uint32_t data, uint32_t update_id) {
6466         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6467         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6468         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
6469         LDKOutPoint channel_id_conv;
6470         channel_id_conv.inner = (void*)(channel_id & (~1));
6471         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
6472         channel_id_conv = OutPoint_clone(&channel_id_conv);
6473         LDKChannelMonitor data_conv;
6474         data_conv.inner = (void*)(data & (~1));
6475         data_conv.is_owned = false;
6476         LDKMonitorUpdateId update_id_conv;
6477         update_id_conv.inner = (void*)(update_id & (~1));
6478         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
6479         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
6480         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6481         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
6482         return (uint64_t)ret_conv;
6483 }
6484
6485 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t channel_id, uint32_t update, uint32_t data, uint32_t update_id) {
6486         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6487         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6488         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
6489         LDKOutPoint channel_id_conv;
6490         channel_id_conv.inner = (void*)(channel_id & (~1));
6491         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
6492         channel_id_conv = OutPoint_clone(&channel_id_conv);
6493         LDKChannelMonitorUpdate update_conv;
6494         update_conv.inner = (void*)(update & (~1));
6495         update_conv.is_owned = false;
6496         LDKChannelMonitor data_conv;
6497         data_conv.inner = (void*)(data & (~1));
6498         data_conv.is_owned = false;
6499         LDKMonitorUpdateId update_id_conv;
6500         update_id_conv.inner = (void*)(update_id & (~1));
6501         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
6502         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
6503         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6504         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
6505         return (uint64_t)ret_conv;
6506 }
6507
6508 typedef struct LDKChannelMessageHandler_JCalls {
6509         atomic_size_t refcnt;
6510         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6511         uint32_t handle_open_channel_meth;
6512         uint32_t handle_accept_channel_meth;
6513         uint32_t handle_funding_created_meth;
6514         uint32_t handle_funding_signed_meth;
6515         uint32_t handle_funding_locked_meth;
6516         uint32_t handle_shutdown_meth;
6517         uint32_t handle_closing_signed_meth;
6518         uint32_t handle_update_add_htlc_meth;
6519         uint32_t handle_update_fulfill_htlc_meth;
6520         uint32_t handle_update_fail_htlc_meth;
6521         uint32_t handle_update_fail_malformed_htlc_meth;
6522         uint32_t handle_commitment_signed_meth;
6523         uint32_t handle_revoke_and_ack_meth;
6524         uint32_t handle_update_fee_meth;
6525         uint32_t handle_announcement_signatures_meth;
6526         uint32_t peer_disconnected_meth;
6527         uint32_t peer_connected_meth;
6528         uint32_t handle_channel_reestablish_meth;
6529         uint32_t handle_channel_update_meth;
6530         uint32_t handle_error_meth;
6531 } LDKChannelMessageHandler_JCalls;
6532 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
6533         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6534         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6535                 js_free(j_calls->handle_open_channel_meth);
6536                 js_free(j_calls->handle_accept_channel_meth);
6537                 js_free(j_calls->handle_funding_created_meth);
6538                 js_free(j_calls->handle_funding_signed_meth);
6539                 js_free(j_calls->handle_funding_locked_meth);
6540                 js_free(j_calls->handle_shutdown_meth);
6541                 js_free(j_calls->handle_closing_signed_meth);
6542                 js_free(j_calls->handle_update_add_htlc_meth);
6543                 js_free(j_calls->handle_update_fulfill_htlc_meth);
6544                 js_free(j_calls->handle_update_fail_htlc_meth);
6545                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
6546                 js_free(j_calls->handle_commitment_signed_meth);
6547                 js_free(j_calls->handle_revoke_and_ack_meth);
6548                 js_free(j_calls->handle_update_fee_meth);
6549                 js_free(j_calls->handle_announcement_signatures_meth);
6550                 js_free(j_calls->peer_disconnected_meth);
6551                 js_free(j_calls->peer_connected_meth);
6552                 js_free(j_calls->handle_channel_reestablish_meth);
6553                 js_free(j_calls->handle_channel_update_meth);
6554                 js_free(j_calls->handle_error_meth);
6555                 FREE(j_calls);
6556         }
6557 }
6558 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
6559         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6560         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6561         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6562         LDKInitFeatures their_features_var = their_features;
6563         uint64_t their_features_ref = 0;
6564         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6565         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6566         their_features_ref = (uint64_t)their_features_var.inner;
6567         if (their_features_var.is_owned) {
6568                 their_features_ref |= 1;
6569         }
6570         LDKOpenChannel msg_var = *msg;
6571         uint64_t msg_ref = 0;
6572         msg_var = OpenChannel_clone(msg);
6573         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6574         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6575         msg_ref = (uint64_t)msg_var.inner;
6576         if (msg_var.is_owned) {
6577                 msg_ref |= 1;
6578         }
6579         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6580 }
6581 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
6582         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6583         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6584         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6585         LDKInitFeatures their_features_var = their_features;
6586         uint64_t their_features_ref = 0;
6587         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6588         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6589         their_features_ref = (uint64_t)their_features_var.inner;
6590         if (their_features_var.is_owned) {
6591                 their_features_ref |= 1;
6592         }
6593         LDKAcceptChannel msg_var = *msg;
6594         uint64_t msg_ref = 0;
6595         msg_var = AcceptChannel_clone(msg);
6596         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6597         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6598         msg_ref = (uint64_t)msg_var.inner;
6599         if (msg_var.is_owned) {
6600                 msg_ref |= 1;
6601         }
6602         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6603 }
6604 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
6605         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6606         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6607         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6608         LDKFundingCreated msg_var = *msg;
6609         uint64_t msg_ref = 0;
6610         msg_var = FundingCreated_clone(msg);
6611         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6612         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6613         msg_ref = (uint64_t)msg_var.inner;
6614         if (msg_var.is_owned) {
6615                 msg_ref |= 1;
6616         }
6617         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
6618 }
6619 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
6620         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6621         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6622         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6623         LDKFundingSigned msg_var = *msg;
6624         uint64_t msg_ref = 0;
6625         msg_var = FundingSigned_clone(msg);
6626         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6627         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6628         msg_ref = (uint64_t)msg_var.inner;
6629         if (msg_var.is_owned) {
6630                 msg_ref |= 1;
6631         }
6632         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
6633 }
6634 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
6635         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6636         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6637         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6638         LDKFundingLocked msg_var = *msg;
6639         uint64_t msg_ref = 0;
6640         msg_var = FundingLocked_clone(msg);
6641         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6642         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6643         msg_ref = (uint64_t)msg_var.inner;
6644         if (msg_var.is_owned) {
6645                 msg_ref |= 1;
6646         }
6647         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
6648 }
6649 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
6650         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6651         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6652         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6653         LDKInitFeatures their_features_var = *their_features;
6654         uint64_t their_features_ref = 0;
6655         their_features_var = InitFeatures_clone(their_features);
6656         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6657         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6658         their_features_ref = (uint64_t)their_features_var.inner;
6659         if (their_features_var.is_owned) {
6660                 their_features_ref |= 1;
6661         }
6662         LDKShutdown msg_var = *msg;
6663         uint64_t msg_ref = 0;
6664         msg_var = Shutdown_clone(msg);
6665         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6666         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6667         msg_ref = (uint64_t)msg_var.inner;
6668         if (msg_var.is_owned) {
6669                 msg_ref |= 1;
6670         }
6671         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
6672 }
6673 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
6674         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6675         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6676         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6677         LDKClosingSigned msg_var = *msg;
6678         uint64_t msg_ref = 0;
6679         msg_var = ClosingSigned_clone(msg);
6680         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6681         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6682         msg_ref = (uint64_t)msg_var.inner;
6683         if (msg_var.is_owned) {
6684                 msg_ref |= 1;
6685         }
6686         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
6687 }
6688 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
6689         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6690         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6691         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6692         LDKUpdateAddHTLC msg_var = *msg;
6693         uint64_t msg_ref = 0;
6694         msg_var = UpdateAddHTLC_clone(msg);
6695         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6696         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6697         msg_ref = (uint64_t)msg_var.inner;
6698         if (msg_var.is_owned) {
6699                 msg_ref |= 1;
6700         }
6701         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
6702 }
6703 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
6704         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6705         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6706         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6707         LDKUpdateFulfillHTLC msg_var = *msg;
6708         uint64_t msg_ref = 0;
6709         msg_var = UpdateFulfillHTLC_clone(msg);
6710         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6711         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6712         msg_ref = (uint64_t)msg_var.inner;
6713         if (msg_var.is_owned) {
6714                 msg_ref |= 1;
6715         }
6716         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
6717 }
6718 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
6719         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6720         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6721         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6722         LDKUpdateFailHTLC msg_var = *msg;
6723         uint64_t msg_ref = 0;
6724         msg_var = UpdateFailHTLC_clone(msg);
6725         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6726         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6727         msg_ref = (uint64_t)msg_var.inner;
6728         if (msg_var.is_owned) {
6729                 msg_ref |= 1;
6730         }
6731         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
6732 }
6733 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
6734         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6735         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6736         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6737         LDKUpdateFailMalformedHTLC msg_var = *msg;
6738         uint64_t msg_ref = 0;
6739         msg_var = UpdateFailMalformedHTLC_clone(msg);
6740         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6741         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6742         msg_ref = (uint64_t)msg_var.inner;
6743         if (msg_var.is_owned) {
6744                 msg_ref |= 1;
6745         }
6746         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
6747 }
6748 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
6749         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6750         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6751         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6752         LDKCommitmentSigned msg_var = *msg;
6753         uint64_t msg_ref = 0;
6754         msg_var = CommitmentSigned_clone(msg);
6755         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6756         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6757         msg_ref = (uint64_t)msg_var.inner;
6758         if (msg_var.is_owned) {
6759                 msg_ref |= 1;
6760         }
6761         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
6762 }
6763 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
6764         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6765         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6766         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6767         LDKRevokeAndACK msg_var = *msg;
6768         uint64_t msg_ref = 0;
6769         msg_var = RevokeAndACK_clone(msg);
6770         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6771         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6772         msg_ref = (uint64_t)msg_var.inner;
6773         if (msg_var.is_owned) {
6774                 msg_ref |= 1;
6775         }
6776         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
6777 }
6778 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
6779         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6780         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6781         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6782         LDKUpdateFee msg_var = *msg;
6783         uint64_t msg_ref = 0;
6784         msg_var = UpdateFee_clone(msg);
6785         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6786         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6787         msg_ref = (uint64_t)msg_var.inner;
6788         if (msg_var.is_owned) {
6789                 msg_ref |= 1;
6790         }
6791         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
6792 }
6793 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
6794         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6795         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6796         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6797         LDKAnnouncementSignatures msg_var = *msg;
6798         uint64_t msg_ref = 0;
6799         msg_var = AnnouncementSignatures_clone(msg);
6800         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6801         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6802         msg_ref = (uint64_t)msg_var.inner;
6803         if (msg_var.is_owned) {
6804                 msg_ref |= 1;
6805         }
6806         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
6807 }
6808 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
6809         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6810         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6811         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6812         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
6813 }
6814 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
6815         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6816         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6817         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6818         LDKInit msg_var = *msg;
6819         uint64_t msg_ref = 0;
6820         msg_var = Init_clone(msg);
6821         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6822         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6823         msg_ref = (uint64_t)msg_var.inner;
6824         if (msg_var.is_owned) {
6825                 msg_ref |= 1;
6826         }
6827         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
6828 }
6829 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
6830         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6831         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6832         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6833         LDKChannelReestablish msg_var = *msg;
6834         uint64_t msg_ref = 0;
6835         msg_var = ChannelReestablish_clone(msg);
6836         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6837         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6838         msg_ref = (uint64_t)msg_var.inner;
6839         if (msg_var.is_owned) {
6840                 msg_ref |= 1;
6841         }
6842         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
6843 }
6844 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
6845         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6846         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6847         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6848         LDKChannelUpdate msg_var = *msg;
6849         uint64_t msg_ref = 0;
6850         msg_var = ChannelUpdate_clone(msg);
6851         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6852         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6853         msg_ref = (uint64_t)msg_var.inner;
6854         if (msg_var.is_owned) {
6855                 msg_ref |= 1;
6856         }
6857         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
6858 }
6859 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
6860         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6861         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6862         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6863         LDKErrorMessage msg_var = *msg;
6864         uint64_t msg_ref = 0;
6865         msg_var = ErrorMessage_clone(msg);
6866         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6867         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6868         msg_ref = (uint64_t)msg_var.inner;
6869         if (msg_var.is_owned) {
6870                 msg_ref |= 1;
6871         }
6872         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
6873 }
6874 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
6875         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
6876         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6877         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6878 }
6879 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6880         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
6881         atomic_init(&calls->refcnt, 1);
6882         //TODO: Assign calls->o from o
6883
6884         LDKChannelMessageHandler ret = {
6885                 .this_arg = (void*) calls,
6886                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
6887                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
6888                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
6889                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
6890                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
6891                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
6892                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
6893                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
6894                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
6895                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
6896                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
6897                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
6898                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
6899                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
6900                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
6901                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
6902                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
6903                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
6904                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
6905                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
6906                 .free = LDKChannelMessageHandler_JCalls_free,
6907                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6908         };
6909         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6910         return ret;
6911 }
6912 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6913         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
6914         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
6915         return (long)res_ptr;
6916 }
6917 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) {
6918         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6919         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6920         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6921         LDKPublicKey their_node_id_ref;
6922         CHECK(*((uint32_t*)their_node_id) == 33);
6923         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6924         LDKInitFeatures their_features_conv;
6925         their_features_conv.inner = (void*)(their_features & (~1));
6926         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6927         their_features_conv = InitFeatures_clone(&their_features_conv);
6928         LDKOpenChannel msg_conv;
6929         msg_conv.inner = (void*)(msg & (~1));
6930         msg_conv.is_owned = false;
6931         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6932 }
6933
6934 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) {
6935         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6936         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6937         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6938         LDKPublicKey their_node_id_ref;
6939         CHECK(*((uint32_t*)their_node_id) == 33);
6940         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6941         LDKInitFeatures their_features_conv;
6942         their_features_conv.inner = (void*)(their_features & (~1));
6943         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6944         their_features_conv = InitFeatures_clone(&their_features_conv);
6945         LDKAcceptChannel msg_conv;
6946         msg_conv.inner = (void*)(msg & (~1));
6947         msg_conv.is_owned = false;
6948         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6949 }
6950
6951 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6952         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6953         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6954         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6955         LDKPublicKey their_node_id_ref;
6956         CHECK(*((uint32_t*)their_node_id) == 33);
6957         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6958         LDKFundingCreated msg_conv;
6959         msg_conv.inner = (void*)(msg & (~1));
6960         msg_conv.is_owned = false;
6961         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6962 }
6963
6964 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6965         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6966         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6967         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6968         LDKPublicKey their_node_id_ref;
6969         CHECK(*((uint32_t*)their_node_id) == 33);
6970         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6971         LDKFundingSigned msg_conv;
6972         msg_conv.inner = (void*)(msg & (~1));
6973         msg_conv.is_owned = false;
6974         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6975 }
6976
6977 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6978         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6979         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6980         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6981         LDKPublicKey their_node_id_ref;
6982         CHECK(*((uint32_t*)their_node_id) == 33);
6983         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6984         LDKFundingLocked msg_conv;
6985         msg_conv.inner = (void*)(msg & (~1));
6986         msg_conv.is_owned = false;
6987         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6988 }
6989
6990 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
6991         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6992         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6993         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6994         LDKPublicKey their_node_id_ref;
6995         CHECK(*((uint32_t*)their_node_id) == 33);
6996         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6997         LDKInitFeatures their_features_conv;
6998         their_features_conv.inner = (void*)(their_features & (~1));
6999         their_features_conv.is_owned = false;
7000         LDKShutdown msg_conv;
7001         msg_conv.inner = (void*)(msg & (~1));
7002         msg_conv.is_owned = false;
7003         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
7004 }
7005
7006 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7007         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7008         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7009         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7010         LDKPublicKey their_node_id_ref;
7011         CHECK(*((uint32_t*)their_node_id) == 33);
7012         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7013         LDKClosingSigned msg_conv;
7014         msg_conv.inner = (void*)(msg & (~1));
7015         msg_conv.is_owned = false;
7016         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7017 }
7018
7019 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7020         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7021         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7022         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7023         LDKPublicKey their_node_id_ref;
7024         CHECK(*((uint32_t*)their_node_id) == 33);
7025         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7026         LDKUpdateAddHTLC msg_conv;
7027         msg_conv.inner = (void*)(msg & (~1));
7028         msg_conv.is_owned = false;
7029         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7030 }
7031
7032 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7033         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7034         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7035         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7036         LDKPublicKey their_node_id_ref;
7037         CHECK(*((uint32_t*)their_node_id) == 33);
7038         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7039         LDKUpdateFulfillHTLC msg_conv;
7040         msg_conv.inner = (void*)(msg & (~1));
7041         msg_conv.is_owned = false;
7042         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7043 }
7044
7045 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7046         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7047         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7048         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7049         LDKPublicKey their_node_id_ref;
7050         CHECK(*((uint32_t*)their_node_id) == 33);
7051         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7052         LDKUpdateFailHTLC msg_conv;
7053         msg_conv.inner = (void*)(msg & (~1));
7054         msg_conv.is_owned = false;
7055         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7056 }
7057
7058 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7059         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7060         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7061         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7062         LDKPublicKey their_node_id_ref;
7063         CHECK(*((uint32_t*)their_node_id) == 33);
7064         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7065         LDKUpdateFailMalformedHTLC msg_conv;
7066         msg_conv.inner = (void*)(msg & (~1));
7067         msg_conv.is_owned = false;
7068         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7069 }
7070
7071 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7072         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7073         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7074         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7075         LDKPublicKey their_node_id_ref;
7076         CHECK(*((uint32_t*)their_node_id) == 33);
7077         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7078         LDKCommitmentSigned msg_conv;
7079         msg_conv.inner = (void*)(msg & (~1));
7080         msg_conv.is_owned = false;
7081         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7082 }
7083
7084 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7085         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7086         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7087         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7088         LDKPublicKey their_node_id_ref;
7089         CHECK(*((uint32_t*)their_node_id) == 33);
7090         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7091         LDKRevokeAndACK msg_conv;
7092         msg_conv.inner = (void*)(msg & (~1));
7093         msg_conv.is_owned = false;
7094         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7095 }
7096
7097 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7098         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7099         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7100         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7101         LDKPublicKey their_node_id_ref;
7102         CHECK(*((uint32_t*)their_node_id) == 33);
7103         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7104         LDKUpdateFee msg_conv;
7105         msg_conv.inner = (void*)(msg & (~1));
7106         msg_conv.is_owned = false;
7107         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7108 }
7109
7110 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7111         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7112         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7113         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7114         LDKPublicKey their_node_id_ref;
7115         CHECK(*((uint32_t*)their_node_id) == 33);
7116         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7117         LDKAnnouncementSignatures msg_conv;
7118         msg_conv.inner = (void*)(msg & (~1));
7119         msg_conv.is_owned = false;
7120         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7121 }
7122
7123 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
7124         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7125         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7126         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7127         LDKPublicKey their_node_id_ref;
7128         CHECK(*((uint32_t*)their_node_id) == 33);
7129         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7130         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
7131 }
7132
7133 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7134         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7135         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7136         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7137         LDKPublicKey their_node_id_ref;
7138         CHECK(*((uint32_t*)their_node_id) == 33);
7139         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7140         LDKInit msg_conv;
7141         msg_conv.inner = (void*)(msg & (~1));
7142         msg_conv.is_owned = false;
7143         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7144 }
7145
7146 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7147         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7148         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7149         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7150         LDKPublicKey their_node_id_ref;
7151         CHECK(*((uint32_t*)their_node_id) == 33);
7152         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7153         LDKChannelReestablish msg_conv;
7154         msg_conv.inner = (void*)(msg & (~1));
7155         msg_conv.is_owned = false;
7156         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7157 }
7158
7159 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7160         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7161         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7162         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7163         LDKPublicKey their_node_id_ref;
7164         CHECK(*((uint32_t*)their_node_id) == 33);
7165         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7166         LDKChannelUpdate msg_conv;
7167         msg_conv.inner = (void*)(msg & (~1));
7168         msg_conv.is_owned = false;
7169         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7170 }
7171
7172 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7173         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7174         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7175         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7176         LDKPublicKey their_node_id_ref;
7177         CHECK(*((uint32_t*)their_node_id) == 33);
7178         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7179         LDKErrorMessage msg_conv;
7180         msg_conv.inner = (void*)(msg & (~1));
7181         msg_conv.is_owned = false;
7182         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7183 }
7184
7185 typedef struct LDKRoutingMessageHandler_JCalls {
7186         atomic_size_t refcnt;
7187         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7188         uint32_t handle_node_announcement_meth;
7189         uint32_t handle_channel_announcement_meth;
7190         uint32_t handle_channel_update_meth;
7191         uint32_t get_next_channel_announcements_meth;
7192         uint32_t get_next_node_announcements_meth;
7193         uint32_t sync_routing_table_meth;
7194         uint32_t handle_reply_channel_range_meth;
7195         uint32_t handle_reply_short_channel_ids_end_meth;
7196         uint32_t handle_query_channel_range_meth;
7197         uint32_t handle_query_short_channel_ids_meth;
7198 } LDKRoutingMessageHandler_JCalls;
7199 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
7200         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7201         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7202                 js_free(j_calls->handle_node_announcement_meth);
7203                 js_free(j_calls->handle_channel_announcement_meth);
7204                 js_free(j_calls->handle_channel_update_meth);
7205                 js_free(j_calls->get_next_channel_announcements_meth);
7206                 js_free(j_calls->get_next_node_announcements_meth);
7207                 js_free(j_calls->sync_routing_table_meth);
7208                 js_free(j_calls->handle_reply_channel_range_meth);
7209                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
7210                 js_free(j_calls->handle_query_channel_range_meth);
7211                 js_free(j_calls->handle_query_short_channel_ids_meth);
7212                 FREE(j_calls);
7213         }
7214 }
7215 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
7216         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7217         LDKNodeAnnouncement msg_var = *msg;
7218         uint64_t msg_ref = 0;
7219         msg_var = NodeAnnouncement_clone(msg);
7220         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7221         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7222         msg_ref = (uint64_t)msg_var.inner;
7223         if (msg_var.is_owned) {
7224                 msg_ref |= 1;
7225         }
7226         uint32_t ret = js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
7227         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7228         CHECK_ACCESS(ret_ptr);
7229         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
7230         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
7231         return ret_conv;
7232 }
7233 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
7234         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7235         LDKChannelAnnouncement msg_var = *msg;
7236         uint64_t msg_ref = 0;
7237         msg_var = ChannelAnnouncement_clone(msg);
7238         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7239         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7240         msg_ref = (uint64_t)msg_var.inner;
7241         if (msg_var.is_owned) {
7242                 msg_ref |= 1;
7243         }
7244         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
7245         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7246         CHECK_ACCESS(ret_ptr);
7247         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
7248         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
7249         return ret_conv;
7250 }
7251 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
7252         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7253         LDKChannelUpdate msg_var = *msg;
7254         uint64_t msg_ref = 0;
7255         msg_var = ChannelUpdate_clone(msg);
7256         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7257         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7258         msg_ref = (uint64_t)msg_var.inner;
7259         if (msg_var.is_owned) {
7260                 msg_ref |= 1;
7261         }
7262         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
7263         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7264         CHECK_ACCESS(ret_ptr);
7265         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
7266         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
7267         return ret_conv;
7268 }
7269 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
7270         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7271         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
7272         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
7273         ret_constr.datalen = *((uint32_t*)ret);
7274         if (ret_constr.datalen > 0)
7275                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
7276         else
7277                 ret_constr.data = NULL;
7278         uint32_t* ret_vals = (uint32_t*)(ret + 4);
7279         for (size_t h = 0; h < ret_constr.datalen; h++) {
7280                 uint32_t ret_conv_59 = ret_vals[h];
7281                 void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
7282                 CHECK_ACCESS(ret_conv_59_ptr);
7283                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
7284                 ret_conv_59_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1));
7285                 ret_constr.data[h] = ret_conv_59_conv;
7286         }
7287         return ret_constr;
7288 }
7289 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
7290         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7291         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7292         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
7293         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
7294         LDKCVec_NodeAnnouncementZ ret_constr;
7295         ret_constr.datalen = *((uint32_t*)ret);
7296         if (ret_constr.datalen > 0)
7297                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
7298         else
7299                 ret_constr.data = NULL;
7300         uint32_t* ret_vals = (uint32_t*)(ret + 4);
7301         for (size_t s = 0; s < ret_constr.datalen; s++) {
7302                 uint32_t ret_conv_18 = ret_vals[s];
7303                 LDKNodeAnnouncement ret_conv_18_conv;
7304                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
7305                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
7306                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
7307                 ret_constr.data[s] = ret_conv_18_conv;
7308         }
7309         return ret_constr;
7310 }
7311 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
7312         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7313         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7314         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
7315         LDKInit init_var = *init;
7316         uint64_t init_ref = 0;
7317         init_var = Init_clone(init);
7318         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7319         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7320         init_ref = (uint64_t)init_var.inner;
7321         if (init_var.is_owned) {
7322                 init_ref |= 1;
7323         }
7324         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
7325 }
7326 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
7327         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7328         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7329         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
7330         LDKReplyChannelRange msg_var = msg;
7331         uint64_t msg_ref = 0;
7332         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7333         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7334         msg_ref = (uint64_t)msg_var.inner;
7335         if (msg_var.is_owned) {
7336                 msg_ref |= 1;
7337         }
7338         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
7339         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7340         CHECK_ACCESS(ret_ptr);
7341         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
7342         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
7343         return ret_conv;
7344 }
7345 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
7346         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7347         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7348         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
7349         LDKReplyShortChannelIdsEnd msg_var = msg;
7350         uint64_t msg_ref = 0;
7351         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7352         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7353         msg_ref = (uint64_t)msg_var.inner;
7354         if (msg_var.is_owned) {
7355                 msg_ref |= 1;
7356         }
7357         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
7358         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7359         CHECK_ACCESS(ret_ptr);
7360         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
7361         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
7362         return ret_conv;
7363 }
7364 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
7365         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7366         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7367         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
7368         LDKQueryChannelRange msg_var = msg;
7369         uint64_t msg_ref = 0;
7370         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7371         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7372         msg_ref = (uint64_t)msg_var.inner;
7373         if (msg_var.is_owned) {
7374                 msg_ref |= 1;
7375         }
7376         uint32_t ret = js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
7377         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7378         CHECK_ACCESS(ret_ptr);
7379         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
7380         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
7381         return ret_conv;
7382 }
7383 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
7384         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
7385         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7386         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
7387         LDKQueryShortChannelIds msg_var = msg;
7388         uint64_t msg_ref = 0;
7389         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7390         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7391         msg_ref = (uint64_t)msg_var.inner;
7392         if (msg_var.is_owned) {
7393                 msg_ref |= 1;
7394         }
7395         uint32_t ret = js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
7396         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7397         CHECK_ACCESS(ret_ptr);
7398         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
7399         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
7400         return ret_conv;
7401 }
7402 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
7403         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
7404         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7405         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7406 }
7407 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
7408         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
7409         atomic_init(&calls->refcnt, 1);
7410         //TODO: Assign calls->o from o
7411
7412         LDKRoutingMessageHandler ret = {
7413                 .this_arg = (void*) calls,
7414                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
7415                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
7416                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
7417                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
7418                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
7419                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
7420                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
7421                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
7422                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
7423                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
7424                 .free = LDKRoutingMessageHandler_JCalls_free,
7425                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
7426         };
7427         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7428         return ret;
7429 }
7430 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
7431         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
7432         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
7433         return (long)res_ptr;
7434 }
7435 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
7436         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7437         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7438         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7439         LDKNodeAnnouncement msg_conv;
7440         msg_conv.inner = (void*)(msg & (~1));
7441         msg_conv.is_owned = false;
7442         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7443         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
7444         return (uint64_t)ret_conv;
7445 }
7446
7447 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
7448         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7449         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7450         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7451         LDKChannelAnnouncement msg_conv;
7452         msg_conv.inner = (void*)(msg & (~1));
7453         msg_conv.is_owned = false;
7454         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7455         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
7456         return (uint64_t)ret_conv;
7457 }
7458
7459 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
7460         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7461         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7462         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7463         LDKChannelUpdate msg_conv;
7464         msg_conv.inner = (void*)(msg & (~1));
7465         msg_conv.is_owned = false;
7466         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7467         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
7468         return (uint64_t)ret_conv;
7469 }
7470
7471 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
7472         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7473         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7474         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7475         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
7476         uint32_tArray ret_arr = NULL;
7477         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7478         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7479         for (size_t h = 0; h < ret_var.datalen; h++) {
7480                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
7481                 *ret_conv_59_conv = ret_var.data[h];
7482                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
7483         }
7484         
7485         FREE(ret_var.data);
7486         return ret_arr;
7487 }
7488
7489 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
7490         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7491         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7492         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7493         LDKPublicKey starting_point_ref;
7494         CHECK(*((uint32_t*)starting_point) == 33);
7495         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
7496         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
7497         uint32_tArray ret_arr = NULL;
7498         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7499         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7500         for (size_t s = 0; s < ret_var.datalen; s++) {
7501                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
7502                 uint64_t ret_conv_18_ref = 0;
7503                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7504                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7505                 ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
7506                 if (ret_conv_18_var.is_owned) {
7507                         ret_conv_18_ref |= 1;
7508                 }
7509                 ret_arr_ptr[s] = ret_conv_18_ref;
7510         }
7511         
7512         FREE(ret_var.data);
7513         return ret_arr;
7514 }
7515
7516 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
7517         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7518         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7519         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7520         LDKPublicKey their_node_id_ref;
7521         CHECK(*((uint32_t*)their_node_id) == 33);
7522         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7523         LDKInit init_conv;
7524         init_conv.inner = (void*)(init & (~1));
7525         init_conv.is_owned = false;
7526         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
7527 }
7528
7529 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7530         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7531         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7532         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7533         LDKPublicKey their_node_id_ref;
7534         CHECK(*((uint32_t*)their_node_id) == 33);
7535         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7536         LDKReplyChannelRange msg_conv;
7537         msg_conv.inner = (void*)(msg & (~1));
7538         msg_conv.is_owned = (msg & 1) || (msg == 0);
7539         msg_conv = ReplyChannelRange_clone(&msg_conv);
7540         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7541         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7542         return (uint64_t)ret_conv;
7543 }
7544
7545 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) {
7546         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7547         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7548         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7549         LDKPublicKey their_node_id_ref;
7550         CHECK(*((uint32_t*)their_node_id) == 33);
7551         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7552         LDKReplyShortChannelIdsEnd msg_conv;
7553         msg_conv.inner = (void*)(msg & (~1));
7554         msg_conv.is_owned = (msg & 1) || (msg == 0);
7555         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
7556         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7557         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7558         return (uint64_t)ret_conv;
7559 }
7560
7561 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7562         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7563         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7564         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7565         LDKPublicKey their_node_id_ref;
7566         CHECK(*((uint32_t*)their_node_id) == 33);
7567         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7568         LDKQueryChannelRange msg_conv;
7569         msg_conv.inner = (void*)(msg & (~1));
7570         msg_conv.is_owned = (msg & 1) || (msg == 0);
7571         msg_conv = QueryChannelRange_clone(&msg_conv);
7572         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7573         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7574         return (uint64_t)ret_conv;
7575 }
7576
7577 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7578         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7579         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7580         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7581         LDKPublicKey their_node_id_ref;
7582         CHECK(*((uint32_t*)their_node_id) == 33);
7583         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7584         LDKQueryShortChannelIds msg_conv;
7585         msg_conv.inner = (void*)(msg & (~1));
7586         msg_conv.is_owned = (msg & 1) || (msg == 0);
7587         msg_conv = QueryShortChannelIds_clone(&msg_conv);
7588         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7589         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7590         return (uint64_t)ret_conv;
7591 }
7592
7593 typedef struct LDKCustomMessageReader_JCalls {
7594         atomic_size_t refcnt;
7595         uint32_t read_meth;
7596 } LDKCustomMessageReader_JCalls;
7597 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
7598         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
7599         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7600                 js_free(j_calls->read_meth);
7601                 FREE(j_calls);
7602         }
7603 }
7604 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
7605         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
7606         LDKu8slice buffer_var = buffer;
7607         int8_tArray buffer_arr = init_arr(buffer_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7608         memcpy((uint8_t*)(buffer_arr + 4), buffer_var.data, buffer_var.datalen);
7609         uint32_t ret = js_invoke_function_2(j_calls->read_meth, message_type, buffer_arr);
7610         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7611         CHECK_ACCESS(ret_ptr);
7612         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
7613         ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1));
7614         return ret_conv;
7615 }
7616 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
7617         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
7618         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7619 }
7620 static inline LDKCustomMessageReader LDKCustomMessageReader_init (/*TODO: JS Object Reference */void* o) {
7621         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
7622         atomic_init(&calls->refcnt, 1);
7623         //TODO: Assign calls->o from o
7624
7625         LDKCustomMessageReader ret = {
7626                 .this_arg = (void*) calls,
7627                 .read = read_LDKCustomMessageReader_jcall,
7628                 .free = LDKCustomMessageReader_JCalls_free,
7629         };
7630         return ret;
7631 }
7632 long  __attribute__((visibility("default"))) TS_LDKCustomMessageReader_new(/*TODO: JS Object Reference */void* o) {
7633         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
7634         *res_ptr = LDKCustomMessageReader_init(o);
7635         return (long)res_ptr;
7636 }
7637 uint32_t  __attribute__((visibility("default"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
7638         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7639         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7640         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
7641         LDKu8slice buffer_ref;
7642         buffer_ref.datalen = *((uint32_t*)buffer);
7643         buffer_ref.data = (int8_t*)(buffer + 4);
7644         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
7645         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
7646         return (uint64_t)ret_conv;
7647 }
7648
7649 typedef struct LDKCustomMessageHandler_JCalls {
7650         atomic_size_t refcnt;
7651         LDKCustomMessageReader_JCalls* CustomMessageReader;
7652         uint32_t handle_custom_message_meth;
7653         uint32_t get_and_clear_pending_msg_meth;
7654 } LDKCustomMessageHandler_JCalls;
7655 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
7656         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
7657         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7658                 js_free(j_calls->handle_custom_message_meth);
7659                 js_free(j_calls->get_and_clear_pending_msg_meth);
7660                 FREE(j_calls);
7661         }
7662 }
7663 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
7664         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
7665         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
7666         *msg_ret = msg;
7667         int8_tArray sender_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7668         memcpy((uint8_t*)(sender_node_id_arr + 4), sender_node_id.compressed_form, 33);
7669         uint32_t ret = js_invoke_function_2(j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
7670         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7671         CHECK_ACCESS(ret_ptr);
7672         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
7673         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
7674         return ret_conv;
7675 }
7676 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
7677         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
7678         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_meth);
7679         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
7680         ret_constr.datalen = *((uint32_t*)ret);
7681         if (ret_constr.datalen > 0)
7682                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
7683         else
7684                 ret_constr.data = NULL;
7685         uint32_t* ret_vals = (uint32_t*)(ret + 4);
7686         for (size_t z = 0; z < ret_constr.datalen; z++) {
7687                 uint32_t ret_conv_25 = ret_vals[z];
7688                 void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
7689                 CHECK_ACCESS(ret_conv_25_ptr);
7690                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
7691                 ret_conv_25_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1));
7692                 ret_constr.data[z] = ret_conv_25_conv;
7693         }
7694         return ret_constr;
7695 }
7696 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
7697         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
7698         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7699         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
7700 }
7701 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* CustomMessageReader) {
7702         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
7703         atomic_init(&calls->refcnt, 1);
7704         //TODO: Assign calls->o from o
7705
7706         LDKCustomMessageHandler ret = {
7707                 .this_arg = (void*) calls,
7708                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
7709                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
7710                 .free = LDKCustomMessageHandler_JCalls_free,
7711                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
7712         };
7713         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
7714         return ret;
7715 }
7716 long  __attribute__((visibility("default"))) TS_LDKCustomMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* CustomMessageReader) {
7717         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
7718         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
7719         return (long)res_ptr;
7720 }
7721 uint32_t  __attribute__((visibility("default"))) TS_CustomMessageHandler_handle_custom_message(uint32_t this_arg, uint32_t msg, int8_tArray sender_node_id) {
7722         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7723         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7724         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
7725         void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
7726         CHECK_ACCESS(msg_ptr);
7727         LDKType msg_conv = *(LDKType*)(msg_ptr);
7728         LDKPublicKey sender_node_id_ref;
7729         CHECK(*((uint32_t*)sender_node_id) == 33);
7730         memcpy(sender_node_id_ref.compressed_form, (uint8_t*)(sender_node_id + 4), 33);
7731         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7732         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
7733         return (uint64_t)ret_conv;
7734 }
7735
7736 uint32_tArray  __attribute__((visibility("default"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
7737         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7738         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7739         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
7740         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
7741         uint32_tArray ret_arr = NULL;
7742         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7743         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7744         for (size_t z = 0; z < ret_var.datalen; z++) {
7745                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
7746                 *ret_conv_25_conv = ret_var.data[z];
7747                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
7748         }
7749         
7750         FREE(ret_var.data);
7751         return ret_arr;
7752 }
7753
7754 typedef struct LDKSocketDescriptor_JCalls {
7755         atomic_size_t refcnt;
7756         uint32_t send_data_meth;
7757         uint32_t disconnect_socket_meth;
7758         uint32_t eq_meth;
7759         uint32_t hash_meth;
7760 } LDKSocketDescriptor_JCalls;
7761 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
7762         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7763         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7764                 js_free(j_calls->send_data_meth);
7765                 js_free(j_calls->disconnect_socket_meth);
7766                 js_free(j_calls->eq_meth);
7767                 js_free(j_calls->hash_meth);
7768                 FREE(j_calls);
7769         }
7770 }
7771 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
7772         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7773         LDKu8slice data_var = data;
7774         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7775         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
7776         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
7777 }
7778 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
7779         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7780         js_invoke_function_0(j_calls->disconnect_socket_meth);
7781 }
7782 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
7783         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7784         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
7785         *other_arg_clone = SocketDescriptor_clone(other_arg);
7786         return js_invoke_function_1(j_calls->eq_meth, (uint64_t)other_arg_clone);
7787 }
7788 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
7789         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7790         return js_invoke_function_0(j_calls->hash_meth);
7791 }
7792 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
7793         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
7794         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7795 }
7796 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
7797         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
7798         atomic_init(&calls->refcnt, 1);
7799         //TODO: Assign calls->o from o
7800
7801         LDKSocketDescriptor ret = {
7802                 .this_arg = (void*) calls,
7803                 .send_data = send_data_LDKSocketDescriptor_jcall,
7804                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
7805                 .eq = eq_LDKSocketDescriptor_jcall,
7806                 .hash = hash_LDKSocketDescriptor_jcall,
7807                 .cloned = LDKSocketDescriptor_JCalls_cloned,
7808                 .free = LDKSocketDescriptor_JCalls_free,
7809         };
7810         return ret;
7811 }
7812 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
7813         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
7814         *res_ptr = LDKSocketDescriptor_init(o);
7815         return (long)res_ptr;
7816 }
7817 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
7818         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7819         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7820         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
7821         LDKu8slice data_ref;
7822         data_ref.datalen = *((uint32_t*)data);
7823         data_ref.data = (int8_t*)(data + 4);
7824         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
7825         return ret_val;
7826 }
7827
7828 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
7829         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7830         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7831         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
7832         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
7833 }
7834
7835 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
7836         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7837         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7838         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
7839         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
7840         return ret_val;
7841 }
7842
7843 typedef struct LDKScore_JCalls {
7844         atomic_size_t refcnt;
7845         uint32_t channel_penalty_msat_meth;
7846         uint32_t payment_path_failed_meth;
7847         uint32_t write_meth;
7848 } LDKScore_JCalls;
7849 static void LDKScore_JCalls_free(void* this_arg) {
7850         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7851         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7852                 js_free(j_calls->channel_penalty_msat_meth);
7853                 js_free(j_calls->payment_path_failed_meth);
7854                 js_free(j_calls->write_meth);
7855                 FREE(j_calls);
7856         }
7857 }
7858 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target) {
7859         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7860         LDKNodeId source_var = *source;
7861         uint64_t source_ref = 0;
7862         source_var = NodeId_clone(source);
7863         CHECK((((uint64_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7864         CHECK((((uint64_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7865         source_ref = (uint64_t)source_var.inner;
7866         if (source_var.is_owned) {
7867                 source_ref |= 1;
7868         }
7869         LDKNodeId target_var = *target;
7870         uint64_t target_ref = 0;
7871         target_var = NodeId_clone(target);
7872         CHECK((((uint64_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7873         CHECK((((uint64_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7874         target_ref = (uint64_t)target_var.inner;
7875         if (target_var.is_owned) {
7876                 target_ref |= 1;
7877         }
7878         return js_invoke_function_3(j_calls->channel_penalty_msat_meth, short_channel_id, source_ref, target_ref);
7879 }
7880 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
7881         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7882         LDKCVec_RouteHopZ path_var = path;
7883         uint32_tArray path_arr = NULL;
7884         path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7885         uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
7886         for (size_t k = 0; k < path_var.datalen; k++) {
7887                 LDKRouteHop path_conv_10_var = path_var.data[k];
7888                 uint64_t path_conv_10_ref = 0;
7889                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7890                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7891                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
7892                 if (path_conv_10_var.is_owned) {
7893                         path_conv_10_ref |= 1;
7894                 }
7895                 path_arr_ptr[k] = path_conv_10_ref;
7896         }
7897         
7898         FREE(path_var.data);
7899         js_invoke_function_2(j_calls->payment_path_failed_meth, path_arr, short_channel_id);
7900 }
7901 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
7902         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7903         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
7904         LDKCVec_u8Z ret_ref;
7905         ret_ref.datalen = *((uint32_t*)ret);
7906         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7907         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
7908         return ret_ref;
7909 }
7910 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
7911         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
7912         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7913 }
7914 static inline LDKScore LDKScore_init (/*TODO: JS Object Reference */void* o) {
7915         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
7916         atomic_init(&calls->refcnt, 1);
7917         //TODO: Assign calls->o from o
7918
7919         LDKScore ret = {
7920                 .this_arg = (void*) calls,
7921                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
7922                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
7923                 .write = write_LDKScore_jcall,
7924                 .free = LDKScore_JCalls_free,
7925         };
7926         return ret;
7927 }
7928 long  __attribute__((visibility("default"))) TS_LDKScore_new(/*TODO: JS Object Reference */void* o) {
7929         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
7930         *res_ptr = LDKScore_init(o);
7931         return (long)res_ptr;
7932 }
7933 int64_t  __attribute__((visibility("default"))) TS_Score_channel_penalty_msat(uint32_t this_arg, int64_t short_channel_id, uint32_t source, uint32_t target) {
7934         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7935         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7936         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
7937         LDKNodeId source_conv;
7938         source_conv.inner = (void*)(source & (~1));
7939         source_conv.is_owned = false;
7940         LDKNodeId target_conv;
7941         target_conv.inner = (void*)(target & (~1));
7942         target_conv.is_owned = false;
7943         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv);
7944         return ret_val;
7945 }
7946
7947 void  __attribute__((visibility("default"))) TS_Score_payment_path_failed(uint32_t this_arg, uint32_tArray path, int64_t short_channel_id) {
7948         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7949         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7950         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
7951         LDKCVec_RouteHopZ path_constr;
7952         path_constr.datalen = *((uint32_t*)path);
7953         if (path_constr.datalen > 0)
7954                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7955         else
7956                 path_constr.data = NULL;
7957         uint32_t* path_vals = (uint32_t*)(path + 4);
7958         for (size_t k = 0; k < path_constr.datalen; k++) {
7959                 uint32_t path_conv_10 = path_vals[k];
7960                 LDKRouteHop path_conv_10_conv;
7961                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
7962                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
7963                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
7964                 path_constr.data[k] = path_conv_10_conv;
7965         }
7966         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
7967 }
7968
7969 int8_tArray  __attribute__((visibility("default"))) TS_Score_write(uint32_t this_arg) {
7970         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7971         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7972         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
7973         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7974         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7975         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
7976         CVec_u8Z_free(ret_var);
7977         return ret_arr;
7978 }
7979
7980 typedef struct LDKChannelManagerPersister_JCalls {
7981         atomic_size_t refcnt;
7982         uint32_t persist_manager_meth;
7983 } LDKChannelManagerPersister_JCalls;
7984 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
7985         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
7986         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7987                 js_free(j_calls->persist_manager_meth);
7988                 FREE(j_calls);
7989         }
7990 }
7991 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
7992         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
7993         LDKChannelManager channel_manager_var = *channel_manager;
7994         uint64_t channel_manager_ref = 0;
7995         // Warning: we may need a move here but no clone is available for LDKChannelManager
7996         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7997         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7998         channel_manager_ref = (uint64_t)channel_manager_var.inner;
7999         if (channel_manager_var.is_owned) {
8000                 channel_manager_ref |= 1;
8001         }
8002         uint32_t ret = js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
8003         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8004         CHECK_ACCESS(ret_ptr);
8005         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8006         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
8007         return ret_conv;
8008 }
8009 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
8010         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
8011         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8012 }
8013 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (/*TODO: JS Object Reference */void* o) {
8014         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
8015         atomic_init(&calls->refcnt, 1);
8016         //TODO: Assign calls->o from o
8017
8018         LDKChannelManagerPersister ret = {
8019                 .this_arg = (void*) calls,
8020                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
8021                 .free = LDKChannelManagerPersister_JCalls_free,
8022         };
8023         return ret;
8024 }
8025 long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/*TODO: JS Object Reference */void* o) {
8026         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
8027         *res_ptr = LDKChannelManagerPersister_init(o);
8028         return (long)res_ptr;
8029 }
8030 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
8031         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8032         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8033         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
8034         LDKChannelManager channel_manager_conv;
8035         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8036         channel_manager_conv.is_owned = false;
8037         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8038         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8039         return (uint64_t)ret_conv;
8040 }
8041
8042 uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint32_t ptr) {
8043         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
8044         switch(obj->tag) {
8045                 case LDKFallback_SegWitProgram: {
8046                         uint8_t version_val = obj->seg_wit_program.version._0;
8047                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
8048                         int8_tArray program_arr = init_arr(program_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
8049                         memcpy((uint8_t*)(program_arr + 4), program_var.data, program_var.datalen);
8050                         return 0 /* LDKFallback - SegWitProgram */; (void) version_val; (void) program_arr;
8051                 }
8052                 case LDKFallback_PubKeyHash: {
8053                         int8_tArray pub_key_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
8054                         memcpy((uint8_t*)(pub_key_hash_arr + 4), obj->pub_key_hash.data, 20);
8055                         return 0 /* LDKFallback - PubKeyHash */; (void) pub_key_hash_arr;
8056                 }
8057                 case LDKFallback_ScriptHash: {
8058                         int8_tArray script_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
8059                         memcpy((uint8_t*)(script_hash_arr + 4), obj->script_hash.data, 20);
8060                         return 0 /* LDKFallback - ScriptHash */; (void) script_hash_arr;
8061                 }
8062                 default: abort();
8063         }
8064 }
8065 typedef struct LDKPayer_JCalls {
8066         atomic_size_t refcnt;
8067         uint32_t node_id_meth;
8068         uint32_t first_hops_meth;
8069         uint32_t send_payment_meth;
8070         uint32_t retry_payment_meth;
8071 } LDKPayer_JCalls;
8072 static void LDKPayer_JCalls_free(void* this_arg) {
8073         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
8074         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8075                 js_free(j_calls->node_id_meth);
8076                 js_free(j_calls->first_hops_meth);
8077                 js_free(j_calls->send_payment_meth);
8078                 js_free(j_calls->retry_payment_meth);
8079                 FREE(j_calls);
8080         }
8081 }
8082 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
8083         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
8084         int8_tArray ret = js_invoke_function_0(j_calls->node_id_meth);
8085         LDKPublicKey ret_ref;
8086         CHECK(*((uint32_t*)ret) == 33);
8087         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
8088         return ret_ref;
8089 }
8090 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
8091         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
8092         uint32_tArray ret = js_invoke_function_0(j_calls->first_hops_meth);
8093         LDKCVec_ChannelDetailsZ ret_constr;
8094         ret_constr.datalen = *((uint32_t*)ret);
8095         if (ret_constr.datalen > 0)
8096                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
8097         else
8098                 ret_constr.data = NULL;
8099         uint32_t* ret_vals = (uint32_t*)(ret + 4);
8100         for (size_t q = 0; q < ret_constr.datalen; q++) {
8101                 uint32_t ret_conv_16 = ret_vals[q];
8102                 LDKChannelDetails ret_conv_16_conv;
8103                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
8104                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
8105                 ret_conv_16_conv = ChannelDetails_clone(&ret_conv_16_conv);
8106                 ret_constr.data[q] = ret_conv_16_conv;
8107         }
8108         return ret_constr;
8109 }
8110 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
8111         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
8112         LDKRoute route_var = *route;
8113         uint64_t route_ref = 0;
8114         route_var = Route_clone(route);
8115         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8116         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8117         route_ref = (uint64_t)route_var.inner;
8118         if (route_var.is_owned) {
8119                 route_ref |= 1;
8120         }
8121         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8122         memcpy((uint8_t*)(payment_hash_arr + 4), payment_hash.data, 32);
8123         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8124         memcpy((uint8_t*)(payment_secret_arr + 4), payment_secret.data, 32);
8125         uint32_t ret = js_invoke_function_3(j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
8126         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8127         CHECK_ACCESS(ret_ptr);
8128         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
8129         ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone((LDKCResult_PaymentIdPaymentSendFailureZ*)(((uint64_t)ret) & ~1));
8130         return ret_conv;
8131 }
8132 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
8133         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
8134         LDKRoute route_var = *route;
8135         uint64_t route_ref = 0;
8136         route_var = Route_clone(route);
8137         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8138         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8139         route_ref = (uint64_t)route_var.inner;
8140         if (route_var.is_owned) {
8141                 route_ref |= 1;
8142         }
8143         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8144         memcpy((uint8_t*)(payment_id_arr + 4), payment_id.data, 32);
8145         uint32_t ret = js_invoke_function_2(j_calls->retry_payment_meth, route_ref, payment_id_arr);
8146         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8147         CHECK_ACCESS(ret_ptr);
8148         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
8149         ret_conv = CResult_NonePaymentSendFailureZ_clone((LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)ret) & ~1));
8150         return ret_conv;
8151 }
8152 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
8153         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
8154         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8155 }
8156 static inline LDKPayer LDKPayer_init (/*TODO: JS Object Reference */void* o) {
8157         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
8158         atomic_init(&calls->refcnt, 1);
8159         //TODO: Assign calls->o from o
8160
8161         LDKPayer ret = {
8162                 .this_arg = (void*) calls,
8163                 .node_id = node_id_LDKPayer_jcall,
8164                 .first_hops = first_hops_LDKPayer_jcall,
8165                 .send_payment = send_payment_LDKPayer_jcall,
8166                 .retry_payment = retry_payment_LDKPayer_jcall,
8167                 .free = LDKPayer_JCalls_free,
8168         };
8169         return ret;
8170 }
8171 long  __attribute__((visibility("default"))) TS_LDKPayer_new(/*TODO: JS Object Reference */void* o) {
8172         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
8173         *res_ptr = LDKPayer_init(o);
8174         return (long)res_ptr;
8175 }
8176 int8_tArray  __attribute__((visibility("default"))) TS_Payer_node_id(uint32_t this_arg) {
8177         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8178         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8179         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
8180         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8181         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
8182         return ret_arr;
8183 }
8184
8185 uint32_tArray  __attribute__((visibility("default"))) TS_Payer_first_hops(uint32_t this_arg) {
8186         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8187         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8188         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
8189         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
8190         uint32_tArray ret_arr = NULL;
8191         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
8192         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
8193         for (size_t q = 0; q < ret_var.datalen; q++) {
8194                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
8195                 uint64_t ret_conv_16_ref = 0;
8196                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8197                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8198                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
8199                 if (ret_conv_16_var.is_owned) {
8200                         ret_conv_16_ref |= 1;
8201                 }
8202                 ret_arr_ptr[q] = ret_conv_16_ref;
8203         }
8204         
8205         FREE(ret_var.data);
8206         return ret_arr;
8207 }
8208
8209 uint32_t  __attribute__((visibility("default"))) TS_Payer_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
8210         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8211         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8212         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
8213         LDKRoute route_conv;
8214         route_conv.inner = (void*)(route & (~1));
8215         route_conv.is_owned = false;
8216         LDKThirtyTwoBytes payment_hash_ref;
8217         CHECK(*((uint32_t*)payment_hash) == 32);
8218         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
8219         LDKThirtyTwoBytes payment_secret_ref;
8220         CHECK(*((uint32_t*)payment_secret) == 32);
8221         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
8222         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
8223         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
8224         return (uint64_t)ret_conv;
8225 }
8226
8227 uint32_t  __attribute__((visibility("default"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
8228         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8229         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8230         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
8231         LDKRoute route_conv;
8232         route_conv.inner = (void*)(route & (~1));
8233         route_conv.is_owned = false;
8234         LDKThirtyTwoBytes payment_id_ref;
8235         CHECK(*((uint32_t*)payment_id) == 32);
8236         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
8237         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8238         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
8239         return (uint64_t)ret_conv;
8240 }
8241
8242 typedef struct LDKRouter_JCalls {
8243         atomic_size_t refcnt;
8244         uint32_t find_route_meth;
8245 } LDKRouter_JCalls;
8246 static void LDKRouter_JCalls_free(void* this_arg) {
8247         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8248         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8249                 js_free(j_calls->find_route_meth);
8250                 FREE(j_calls);
8251         }
8252 }
8253 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * params, LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
8254         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8255         int8_tArray payer_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8256         memcpy((uint8_t*)(payer_arr + 4), payer.compressed_form, 33);
8257         LDKRouteParameters params_var = *params;
8258         uint64_t params_ref = 0;
8259         params_var = RouteParameters_clone(params);
8260         CHECK((((uint64_t)params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8261         CHECK((((uint64_t)&params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8262         params_ref = (uint64_t)params_var.inner;
8263         if (params_var.is_owned) {
8264                 params_ref |= 1;
8265         }
8266         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
8267         uint32_tArray first_hops_arr = NULL;
8268         if (first_hops != NULL) {
8269                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
8270                 first_hops_arr = init_arr(first_hops_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
8271                 uint32_t *first_hops_arr_ptr = (uint32_t*)(first_hops_arr + 4);
8272                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
8273                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
8274                         uint64_t first_hops_conv_16_ref = 0;
8275                         CHECK((((uint64_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8276                         CHECK((((uint64_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8277                         first_hops_conv_16_ref = (uint64_t)first_hops_conv_16_var.inner;
8278                         if (first_hops_conv_16_var.is_owned) {
8279                                 first_hops_conv_16_ref |= 1;
8280                         }
8281                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
8282                 }
8283         
8284         }
8285         // WARNING: This object doesn't live past this scope, needs clone!
8286         uint64_t ret_scorer = ((uint64_t)scorer) | 1;
8287         uint32_t ret = js_invoke_function_4(j_calls->find_route_meth, payer_arr, params_ref, first_hops_arr, ret_scorer);
8288         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8289         CHECK_ACCESS(ret_ptr);
8290         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
8291         ret_conv = CResult_RouteLightningErrorZ_clone((LDKCResult_RouteLightningErrorZ*)(((uint64_t)ret) & ~1));
8292         return ret_conv;
8293 }
8294 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
8295         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
8296         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8297 }
8298 static inline LDKRouter LDKRouter_init (/*TODO: JS Object Reference */void* o) {
8299         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
8300         atomic_init(&calls->refcnt, 1);
8301         //TODO: Assign calls->o from o
8302
8303         LDKRouter ret = {
8304                 .this_arg = (void*) calls,
8305                 .find_route = find_route_LDKRouter_jcall,
8306                 .free = LDKRouter_JCalls_free,
8307         };
8308         return ret;
8309 }
8310 long  __attribute__((visibility("default"))) TS_LDKRouter_new(/*TODO: JS Object Reference */void* o) {
8311         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
8312         *res_ptr = LDKRouter_init(o);
8313         return (long)res_ptr;
8314 }
8315 uint32_t  __attribute__((visibility("default"))) TS_Router_find_route(uint32_t this_arg, int8_tArray payer, uint32_t params, uint32_tArray first_hops, uint32_t scorer) {
8316         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8317         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8318         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
8319         LDKPublicKey payer_ref;
8320         CHECK(*((uint32_t*)payer) == 33);
8321         memcpy(payer_ref.compressed_form, (uint8_t*)(payer + 4), 33);
8322         LDKRouteParameters params_conv;
8323         params_conv.inner = (void*)(params & (~1));
8324         params_conv.is_owned = false;
8325         LDKCVec_ChannelDetailsZ first_hops_constr;
8326         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
8327         if (first_hops != 0) {
8328                 first_hops_constr.datalen = *((uint32_t*)first_hops);
8329                 if (first_hops_constr.datalen > 0)
8330                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
8331                 else
8332                         first_hops_constr.data = NULL;
8333                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
8334                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
8335                         uint32_t first_hops_conv_16 = first_hops_vals[q];
8336                         LDKChannelDetails first_hops_conv_16_conv;
8337                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
8338                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
8339                         first_hops_constr.data[q] = first_hops_conv_16_conv;
8340                 }
8341                 first_hops_ptr = &first_hops_constr;
8342         }
8343         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
8344         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
8345         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
8346         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8347         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &params_conv, first_hops_ptr, scorer_conv);
8348         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
8349         return (uint64_t)ret_conv;
8350 }
8351
8352 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
8353         LDKStr ret_str = _ldk_get_compiled_version();
8354         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
8355         Str_free(ret_str);
8356         return ret_conv;
8357 }
8358
8359 jstring  __attribute__((visibility("default"))) TS__ldk_c_bindings_get_compiled_version() {
8360         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
8361         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
8362         Str_free(ret_str);
8363         return ret_conv;
8364 }
8365
8366 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
8367         LDKTransaction _res_ref;
8368         _res_ref.datalen = *((uint32_t*)_res);
8369         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
8370         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
8371         _res_ref.data_is_owned = true;
8372         Transaction_free(_res_ref);
8373 }
8374
8375 uint32_t  __attribute__((visibility("default"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
8376         LDKCVec_u8Z script_pubkey_ref;
8377         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
8378         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
8379         memcpy(script_pubkey_ref.data, (uint8_t*)(script_pubkey + 4), script_pubkey_ref.datalen);
8380         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8381         *ret_ref = TxOut_new(script_pubkey_ref, value);
8382         return (uint64_t)ret_ref;
8383 }
8384
8385 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
8386         if ((_res & 1) != 0) return;
8387         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8388         CHECK_ACCESS(_res_ptr);
8389         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
8390         FREE((void*)_res);
8391         TxOut_free(_res_conv);
8392 }
8393
8394 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
8395         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
8396         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8397         *ret_ref = TxOut_clone(orig_conv);
8398         return (uint64_t)ret_ref;
8399 }
8400
8401 void  __attribute__((visibility("default"))) TS_Str_free(jstring _res) {
8402         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
8403         Str_free(dummy);
8404 }
8405
8406 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
8407         LDKSecretKey o_ref;
8408         CHECK(*((uint32_t*)o) == 32);
8409         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
8410         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8411         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
8412         return (uint64_t)ret_conv;
8413 }
8414
8415 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
8416         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8417         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8418         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
8419         return (uint64_t)ret_conv;
8420 }
8421
8422 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
8423         if ((_res & 1) != 0) return;
8424         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8425         CHECK_ACCESS(_res_ptr);
8426         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
8427         FREE((void*)_res);
8428         CResult_SecretKeyErrorZ_free(_res_conv);
8429 }
8430
8431 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
8432         LDKPublicKey o_ref;
8433         CHECK(*((uint32_t*)o) == 33);
8434         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
8435         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8436         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
8437         return (uint64_t)ret_conv;
8438 }
8439
8440 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
8441         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8442         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8443         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
8444         return (uint64_t)ret_conv;
8445 }
8446
8447 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
8448         if ((_res & 1) != 0) return;
8449         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8450         CHECK_ACCESS(_res_ptr);
8451         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
8452         FREE((void*)_res);
8453         CResult_PublicKeyErrorZ_free(_res_conv);
8454 }
8455
8456 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
8457         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
8458         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8459         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
8460         return (uint64_t)ret_conv;
8461 }
8462
8463 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
8464         LDKTxCreationKeys o_conv;
8465         o_conv.inner = (void*)(o & (~1));
8466         o_conv.is_owned = (o & 1) || (o == 0);
8467         o_conv = TxCreationKeys_clone(&o_conv);
8468         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8469         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
8470         return (uint64_t)ret_conv;
8471 }
8472
8473 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
8474         LDKDecodeError e_conv;
8475         e_conv.inner = (void*)(e & (~1));
8476         e_conv.is_owned = (e & 1) || (e == 0);
8477         e_conv = DecodeError_clone(&e_conv);
8478         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8479         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
8480         return (uint64_t)ret_conv;
8481 }
8482
8483 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
8484         if ((_res & 1) != 0) return;
8485         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8486         CHECK_ACCESS(_res_ptr);
8487         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
8488         FREE((void*)_res);
8489         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
8490 }
8491
8492 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
8493         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
8494         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8495         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
8496         return (uint64_t)ret_conv;
8497 }
8498
8499 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
8500         LDKChannelPublicKeys o_conv;
8501         o_conv.inner = (void*)(o & (~1));
8502         o_conv.is_owned = (o & 1) || (o == 0);
8503         o_conv = ChannelPublicKeys_clone(&o_conv);
8504         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8505         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
8506         return (uint64_t)ret_conv;
8507 }
8508
8509 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
8510         LDKDecodeError e_conv;
8511         e_conv.inner = (void*)(e & (~1));
8512         e_conv.is_owned = (e & 1) || (e == 0);
8513         e_conv = DecodeError_clone(&e_conv);
8514         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8515         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
8516         return (uint64_t)ret_conv;
8517 }
8518
8519 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
8520         if ((_res & 1) != 0) return;
8521         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8522         CHECK_ACCESS(_res_ptr);
8523         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
8524         FREE((void*)_res);
8525         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
8526 }
8527
8528 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
8529         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
8530         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8531         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
8532         return (uint64_t)ret_conv;
8533 }
8534
8535 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
8536         LDKTxCreationKeys o_conv;
8537         o_conv.inner = (void*)(o & (~1));
8538         o_conv.is_owned = (o & 1) || (o == 0);
8539         o_conv = TxCreationKeys_clone(&o_conv);
8540         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8541         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
8542         return (uint64_t)ret_conv;
8543 }
8544
8545 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
8546         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8547         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8548         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
8549         return (uint64_t)ret_conv;
8550 }
8551
8552 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
8553         if ((_res & 1) != 0) return;
8554         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8555         CHECK_ACCESS(_res_ptr);
8556         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
8557         FREE((void*)_res);
8558         CResult_TxCreationKeysErrorZ_free(_res_conv);
8559 }
8560
8561 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
8562         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
8563         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8564         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
8565         return (uint64_t)ret_conv;
8566 }
8567
8568 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
8569         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8570         *ret_copy = COption_u32Z_some(o);
8571         uint64_t ret_ref = (uint64_t)ret_copy;
8572         return ret_ref;
8573 }
8574
8575 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
8576         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8577         *ret_copy = COption_u32Z_none();
8578         uint64_t ret_ref = (uint64_t)ret_copy;
8579         return ret_ref;
8580 }
8581
8582 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
8583         if ((_res & 1) != 0) return;
8584         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8585         CHECK_ACCESS(_res_ptr);
8586         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
8587         FREE((void*)_res);
8588         COption_u32Z_free(_res_conv);
8589 }
8590
8591 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
8592         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
8593         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8594         *ret_copy = COption_u32Z_clone(orig_conv);
8595         uint64_t ret_ref = (uint64_t)ret_copy;
8596         return ret_ref;
8597 }
8598
8599 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
8600         LDKHTLCOutputInCommitment o_conv;
8601         o_conv.inner = (void*)(o & (~1));
8602         o_conv.is_owned = (o & 1) || (o == 0);
8603         o_conv = HTLCOutputInCommitment_clone(&o_conv);
8604         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8605         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
8606         return (uint64_t)ret_conv;
8607 }
8608
8609 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
8610         LDKDecodeError e_conv;
8611         e_conv.inner = (void*)(e & (~1));
8612         e_conv.is_owned = (e & 1) || (e == 0);
8613         e_conv = DecodeError_clone(&e_conv);
8614         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8615         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
8616         return (uint64_t)ret_conv;
8617 }
8618
8619 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
8620         if ((_res & 1) != 0) return;
8621         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8622         CHECK_ACCESS(_res_ptr);
8623         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
8624         FREE((void*)_res);
8625         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
8626 }
8627
8628 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
8629         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
8630         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8631         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
8632         return (uint64_t)ret_conv;
8633 }
8634
8635 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
8636         LDKCounterpartyChannelTransactionParameters o_conv;
8637         o_conv.inner = (void*)(o & (~1));
8638         o_conv.is_owned = (o & 1) || (o == 0);
8639         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
8640         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8641         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
8642         return (uint64_t)ret_conv;
8643 }
8644
8645 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
8646         LDKDecodeError e_conv;
8647         e_conv.inner = (void*)(e & (~1));
8648         e_conv.is_owned = (e & 1) || (e == 0);
8649         e_conv = DecodeError_clone(&e_conv);
8650         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8651         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
8652         return (uint64_t)ret_conv;
8653 }
8654
8655 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
8656         if ((_res & 1) != 0) return;
8657         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8658         CHECK_ACCESS(_res_ptr);
8659         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
8660         FREE((void*)_res);
8661         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
8662 }
8663
8664 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
8665         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
8666         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8667         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
8668         return (uint64_t)ret_conv;
8669 }
8670
8671 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
8672         LDKChannelTransactionParameters o_conv;
8673         o_conv.inner = (void*)(o & (~1));
8674         o_conv.is_owned = (o & 1) || (o == 0);
8675         o_conv = ChannelTransactionParameters_clone(&o_conv);
8676         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8677         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
8678         return (uint64_t)ret_conv;
8679 }
8680
8681 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
8682         LDKDecodeError e_conv;
8683         e_conv.inner = (void*)(e & (~1));
8684         e_conv.is_owned = (e & 1) || (e == 0);
8685         e_conv = DecodeError_clone(&e_conv);
8686         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8687         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
8688         return (uint64_t)ret_conv;
8689 }
8690
8691 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
8692         if ((_res & 1) != 0) return;
8693         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8694         CHECK_ACCESS(_res_ptr);
8695         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
8696         FREE((void*)_res);
8697         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
8698 }
8699
8700 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
8701         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
8702         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8703         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
8704         return (uint64_t)ret_conv;
8705 }
8706
8707 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
8708         LDKCVec_SignatureZ _res_constr;
8709         _res_constr.datalen = *((uint32_t*)_res);
8710         if (_res_constr.datalen > 0)
8711                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8712         else
8713                 _res_constr.data = NULL;
8714         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8715         for (size_t m = 0; m < _res_constr.datalen; m++) {
8716                 int8_tArray _res_conv_12 = _res_vals[m];
8717                 LDKSignature _res_conv_12_ref;
8718                 CHECK(*((uint32_t*)_res_conv_12) == 64);
8719                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
8720                 _res_constr.data[m] = _res_conv_12_ref;
8721         }
8722         CVec_SignatureZ_free(_res_constr);
8723 }
8724
8725 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
8726         LDKHolderCommitmentTransaction o_conv;
8727         o_conv.inner = (void*)(o & (~1));
8728         o_conv.is_owned = (o & 1) || (o == 0);
8729         o_conv = HolderCommitmentTransaction_clone(&o_conv);
8730         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8731         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
8732         return (uint64_t)ret_conv;
8733 }
8734
8735 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
8736         LDKDecodeError e_conv;
8737         e_conv.inner = (void*)(e & (~1));
8738         e_conv.is_owned = (e & 1) || (e == 0);
8739         e_conv = DecodeError_clone(&e_conv);
8740         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8741         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
8742         return (uint64_t)ret_conv;
8743 }
8744
8745 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
8746         if ((_res & 1) != 0) return;
8747         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8748         CHECK_ACCESS(_res_ptr);
8749         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
8750         FREE((void*)_res);
8751         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
8752 }
8753
8754 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
8755         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
8756         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8757         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
8758         return (uint64_t)ret_conv;
8759 }
8760
8761 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
8762         LDKBuiltCommitmentTransaction o_conv;
8763         o_conv.inner = (void*)(o & (~1));
8764         o_conv.is_owned = (o & 1) || (o == 0);
8765         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
8766         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8767         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
8768         return (uint64_t)ret_conv;
8769 }
8770
8771 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
8772         LDKDecodeError e_conv;
8773         e_conv.inner = (void*)(e & (~1));
8774         e_conv.is_owned = (e & 1) || (e == 0);
8775         e_conv = DecodeError_clone(&e_conv);
8776         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8777         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
8778         return (uint64_t)ret_conv;
8779 }
8780
8781 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
8782         if ((_res & 1) != 0) return;
8783         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8784         CHECK_ACCESS(_res_ptr);
8785         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
8786         FREE((void*)_res);
8787         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
8788 }
8789
8790 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
8791         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
8792         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8793         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
8794         return (uint64_t)ret_conv;
8795 }
8796
8797 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
8798         LDKTrustedClosingTransaction o_conv;
8799         o_conv.inner = (void*)(o & (~1));
8800         o_conv.is_owned = (o & 1) || (o == 0);
8801         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
8802         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
8803         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
8804         return (uint64_t)ret_conv;
8805 }
8806
8807 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
8808         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
8809         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
8810         return (uint64_t)ret_conv;
8811 }
8812
8813 void  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
8814         if ((_res & 1) != 0) return;
8815         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8816         CHECK_ACCESS(_res_ptr);
8817         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
8818         FREE((void*)_res);
8819         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
8820 }
8821
8822 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
8823         LDKCommitmentTransaction o_conv;
8824         o_conv.inner = (void*)(o & (~1));
8825         o_conv.is_owned = (o & 1) || (o == 0);
8826         o_conv = CommitmentTransaction_clone(&o_conv);
8827         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
8828         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
8829         return (uint64_t)ret_conv;
8830 }
8831
8832 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
8833         LDKDecodeError e_conv;
8834         e_conv.inner = (void*)(e & (~1));
8835         e_conv.is_owned = (e & 1) || (e == 0);
8836         e_conv = DecodeError_clone(&e_conv);
8837         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
8838         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
8839         return (uint64_t)ret_conv;
8840 }
8841
8842 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
8843         if ((_res & 1) != 0) return;
8844         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8845         CHECK_ACCESS(_res_ptr);
8846         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
8847         FREE((void*)_res);
8848         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
8849 }
8850
8851 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
8852         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
8853         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
8854         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
8855         return (uint64_t)ret_conv;
8856 }
8857
8858 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
8859         LDKTrustedCommitmentTransaction o_conv;
8860         o_conv.inner = (void*)(o & (~1));
8861         o_conv.is_owned = (o & 1) || (o == 0);
8862         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
8863         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
8864         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
8865         return (uint64_t)ret_conv;
8866 }
8867
8868 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
8869         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
8870         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
8871         return (uint64_t)ret_conv;
8872 }
8873
8874 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
8875         if ((_res & 1) != 0) return;
8876         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8877         CHECK_ACCESS(_res_ptr);
8878         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
8879         FREE((void*)_res);
8880         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
8881 }
8882
8883 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
8884         LDKCVec_SignatureZ o_constr;
8885         o_constr.datalen = *((uint32_t*)o);
8886         if (o_constr.datalen > 0)
8887                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8888         else
8889                 o_constr.data = NULL;
8890         int8_tArray* o_vals = (int8_tArray*)(o + 4);
8891         for (size_t m = 0; m < o_constr.datalen; m++) {
8892                 int8_tArray o_conv_12 = o_vals[m];
8893                 LDKSignature o_conv_12_ref;
8894                 CHECK(*((uint32_t*)o_conv_12) == 64);
8895                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
8896                 o_constr.data[m] = o_conv_12_ref;
8897         }
8898         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
8899         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
8900         return (uint64_t)ret_conv;
8901 }
8902
8903 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
8904         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
8905         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
8906         return (uint64_t)ret_conv;
8907 }
8908
8909 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
8910         if ((_res & 1) != 0) return;
8911         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8912         CHECK_ACCESS(_res_ptr);
8913         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
8914         FREE((void*)_res);
8915         CResult_CVec_SignatureZNoneZ_free(_res_conv);
8916 }
8917
8918 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
8919         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
8920         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
8921         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
8922         return (uint64_t)ret_conv;
8923 }
8924
8925 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
8926         LDKShutdownScript o_conv;
8927         o_conv.inner = (void*)(o & (~1));
8928         o_conv.is_owned = (o & 1) || (o == 0);
8929         o_conv = ShutdownScript_clone(&o_conv);
8930         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
8931         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
8932         return (uint64_t)ret_conv;
8933 }
8934
8935 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
8936         LDKDecodeError e_conv;
8937         e_conv.inner = (void*)(e & (~1));
8938         e_conv.is_owned = (e & 1) || (e == 0);
8939         e_conv = DecodeError_clone(&e_conv);
8940         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
8941         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
8942         return (uint64_t)ret_conv;
8943 }
8944
8945 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
8946         if ((_res & 1) != 0) return;
8947         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8948         CHECK_ACCESS(_res_ptr);
8949         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
8950         FREE((void*)_res);
8951         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
8952 }
8953
8954 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
8955         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
8956         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
8957         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
8958         return (uint64_t)ret_conv;
8959 }
8960
8961 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
8962         LDKShutdownScript o_conv;
8963         o_conv.inner = (void*)(o & (~1));
8964         o_conv.is_owned = (o & 1) || (o == 0);
8965         o_conv = ShutdownScript_clone(&o_conv);
8966         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
8967         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
8968         return (uint64_t)ret_conv;
8969 }
8970
8971 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
8972         LDKInvalidShutdownScript e_conv;
8973         e_conv.inner = (void*)(e & (~1));
8974         e_conv.is_owned = (e & 1) || (e == 0);
8975         e_conv = InvalidShutdownScript_clone(&e_conv);
8976         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
8977         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
8978         return (uint64_t)ret_conv;
8979 }
8980
8981 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
8982         if ((_res & 1) != 0) return;
8983         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8984         CHECK_ACCESS(_res_ptr);
8985         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
8986         FREE((void*)_res);
8987         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
8988 }
8989
8990 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
8991         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
8992         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
8993         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
8994         return (uint64_t)ret_conv;
8995 }
8996
8997 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
8998         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8999         *ret_conv = CResult_NoneErrorZ_ok();
9000         return (uint64_t)ret_conv;
9001 }
9002
9003 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
9004         LDKIOError e_conv = LDKIOError_from_js(e);
9005         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9006         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9007         return (uint64_t)ret_conv;
9008 }
9009
9010 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
9011         if ((_res & 1) != 0) return;
9012         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9013         CHECK_ACCESS(_res_ptr);
9014         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
9015         FREE((void*)_res);
9016         CResult_NoneErrorZ_free(_res_conv);
9017 }
9018
9019 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
9020         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9021         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9022         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9023         return (uint64_t)ret_conv;
9024 }
9025
9026 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
9027         LDKRouteHop o_conv;
9028         o_conv.inner = (void*)(o & (~1));
9029         o_conv.is_owned = (o & 1) || (o == 0);
9030         o_conv = RouteHop_clone(&o_conv);
9031         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9032         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9033         return (uint64_t)ret_conv;
9034 }
9035
9036 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
9037         LDKDecodeError e_conv;
9038         e_conv.inner = (void*)(e & (~1));
9039         e_conv.is_owned = (e & 1) || (e == 0);
9040         e_conv = DecodeError_clone(&e_conv);
9041         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9042         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9043         return (uint64_t)ret_conv;
9044 }
9045
9046 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
9047         if ((_res & 1) != 0) return;
9048         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9049         CHECK_ACCESS(_res_ptr);
9050         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
9051         FREE((void*)_res);
9052         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9053 }
9054
9055 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
9056         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9057         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9058         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9059         return (uint64_t)ret_conv;
9060 }
9061
9062 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
9063         LDKCVec_RouteHopZ _res_constr;
9064         _res_constr.datalen = *((uint32_t*)_res);
9065         if (_res_constr.datalen > 0)
9066                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9067         else
9068                 _res_constr.data = NULL;
9069         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9070         for (size_t k = 0; k < _res_constr.datalen; k++) {
9071                 uint32_t _res_conv_10 = _res_vals[k];
9072                 LDKRouteHop _res_conv_10_conv;
9073                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9074                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9075                 _res_constr.data[k] = _res_conv_10_conv;
9076         }
9077         CVec_RouteHopZ_free(_res_constr);
9078 }
9079
9080 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
9081         LDKCVec_CVec_RouteHopZZ _res_constr;
9082         _res_constr.datalen = *((uint32_t*)_res);
9083         if (_res_constr.datalen > 0)
9084                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9085         else
9086                 _res_constr.data = NULL;
9087         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
9088         for (size_t m = 0; m < _res_constr.datalen; m++) {
9089                 uint32_tArray _res_conv_12 = _res_vals[m];
9090                 LDKCVec_RouteHopZ _res_conv_12_constr;
9091                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
9092                 if (_res_conv_12_constr.datalen > 0)
9093                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9094                 else
9095                         _res_conv_12_constr.data = NULL;
9096                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
9097                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9098                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9099                         LDKRouteHop _res_conv_12_conv_10_conv;
9100                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9101                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9102                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9103                 }
9104                 _res_constr.data[m] = _res_conv_12_constr;
9105         }
9106         CVec_CVec_RouteHopZZ_free(_res_constr);
9107 }
9108
9109 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
9110         LDKRoute o_conv;
9111         o_conv.inner = (void*)(o & (~1));
9112         o_conv.is_owned = (o & 1) || (o == 0);
9113         o_conv = Route_clone(&o_conv);
9114         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9115         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9116         return (uint64_t)ret_conv;
9117 }
9118
9119 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
9120         LDKDecodeError e_conv;
9121         e_conv.inner = (void*)(e & (~1));
9122         e_conv.is_owned = (e & 1) || (e == 0);
9123         e_conv = DecodeError_clone(&e_conv);
9124         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9125         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9126         return (uint64_t)ret_conv;
9127 }
9128
9129 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
9130         if ((_res & 1) != 0) return;
9131         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9132         CHECK_ACCESS(_res_ptr);
9133         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
9134         FREE((void*)_res);
9135         CResult_RouteDecodeErrorZ_free(_res_conv);
9136 }
9137
9138 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
9139         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9140         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9141         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9142         return (uint64_t)ret_conv;
9143 }
9144
9145 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
9146         LDKRouteParameters o_conv;
9147         o_conv.inner = (void*)(o & (~1));
9148         o_conv.is_owned = (o & 1) || (o == 0);
9149         o_conv = RouteParameters_clone(&o_conv);
9150         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
9151         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
9152         return (uint64_t)ret_conv;
9153 }
9154
9155 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
9156         LDKDecodeError e_conv;
9157         e_conv.inner = (void*)(e & (~1));
9158         e_conv.is_owned = (e & 1) || (e == 0);
9159         e_conv = DecodeError_clone(&e_conv);
9160         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
9161         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
9162         return (uint64_t)ret_conv;
9163 }
9164
9165 void  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
9166         if ((_res & 1) != 0) return;
9167         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9168         CHECK_ACCESS(_res_ptr);
9169         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
9170         FREE((void*)_res);
9171         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
9172 }
9173
9174 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
9175         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
9176         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
9177         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
9178         return (uint64_t)ret_conv;
9179 }
9180
9181 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
9182         LDKCVec_RouteHintZ _res_constr;
9183         _res_constr.datalen = *((uint32_t*)_res);
9184         if (_res_constr.datalen > 0)
9185                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9186         else
9187                 _res_constr.data = NULL;
9188         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9189         for (size_t l = 0; l < _res_constr.datalen; l++) {
9190                 uint32_t _res_conv_11 = _res_vals[l];
9191                 LDKRouteHint _res_conv_11_conv;
9192                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9193                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9194                 _res_constr.data[l] = _res_conv_11_conv;
9195         }
9196         CVec_RouteHintZ_free(_res_constr);
9197 }
9198
9199 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
9200         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9201         *ret_copy = COption_u64Z_some(o);
9202         uint64_t ret_ref = (uint64_t)ret_copy;
9203         return ret_ref;
9204 }
9205
9206 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
9207         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9208         *ret_copy = COption_u64Z_none();
9209         uint64_t ret_ref = (uint64_t)ret_copy;
9210         return ret_ref;
9211 }
9212
9213 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
9214         if ((_res & 1) != 0) return;
9215         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9216         CHECK_ACCESS(_res_ptr);
9217         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
9218         FREE((void*)_res);
9219         COption_u64Z_free(_res_conv);
9220 }
9221
9222 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
9223         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9224         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9225         *ret_copy = COption_u64Z_clone(orig_conv);
9226         uint64_t ret_ref = (uint64_t)ret_copy;
9227         return ret_ref;
9228 }
9229
9230 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_ok(uint32_t o) {
9231         LDKPayee o_conv;
9232         o_conv.inner = (void*)(o & (~1));
9233         o_conv.is_owned = (o & 1) || (o == 0);
9234         o_conv = Payee_clone(&o_conv);
9235         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
9236         *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
9237         return (uint64_t)ret_conv;
9238 }
9239
9240 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_err(uint32_t e) {
9241         LDKDecodeError e_conv;
9242         e_conv.inner = (void*)(e & (~1));
9243         e_conv.is_owned = (e & 1) || (e == 0);
9244         e_conv = DecodeError_clone(&e_conv);
9245         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
9246         *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
9247         return (uint64_t)ret_conv;
9248 }
9249
9250 void  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_free(uint32_t _res) {
9251         if ((_res & 1) != 0) return;
9252         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9253         CHECK_ACCESS(_res_ptr);
9254         LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
9255         FREE((void*)_res);
9256         CResult_PayeeDecodeErrorZ_free(_res_conv);
9257 }
9258
9259 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_clone(uint32_t orig) {
9260         LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
9261         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
9262         *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
9263         return (uint64_t)ret_conv;
9264 }
9265
9266 void  __attribute__((visibility("default"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
9267         LDKCVec_RouteHintHopZ _res_constr;
9268         _res_constr.datalen = *((uint32_t*)_res);
9269         if (_res_constr.datalen > 0)
9270                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
9271         else
9272                 _res_constr.data = NULL;
9273         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9274         for (size_t o = 0; o < _res_constr.datalen; o++) {
9275                 uint32_t _res_conv_14 = _res_vals[o];
9276                 LDKRouteHintHop _res_conv_14_conv;
9277                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
9278                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
9279                 _res_constr.data[o] = _res_conv_14_conv;
9280         }
9281         CVec_RouteHintHopZ_free(_res_constr);
9282 }
9283
9284 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
9285         LDKRouteHint o_conv;
9286         o_conv.inner = (void*)(o & (~1));
9287         o_conv.is_owned = (o & 1) || (o == 0);
9288         o_conv = RouteHint_clone(&o_conv);
9289         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
9290         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
9291         return (uint64_t)ret_conv;
9292 }
9293
9294 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
9295         LDKDecodeError e_conv;
9296         e_conv.inner = (void*)(e & (~1));
9297         e_conv.is_owned = (e & 1) || (e == 0);
9298         e_conv = DecodeError_clone(&e_conv);
9299         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
9300         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
9301         return (uint64_t)ret_conv;
9302 }
9303
9304 void  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
9305         if ((_res & 1) != 0) return;
9306         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9307         CHECK_ACCESS(_res_ptr);
9308         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
9309         FREE((void*)_res);
9310         CResult_RouteHintDecodeErrorZ_free(_res_conv);
9311 }
9312
9313 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
9314         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
9315         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
9316         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
9317         return (uint64_t)ret_conv;
9318 }
9319
9320 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
9321         LDKRouteHintHop o_conv;
9322         o_conv.inner = (void*)(o & (~1));
9323         o_conv.is_owned = (o & 1) || (o == 0);
9324         o_conv = RouteHintHop_clone(&o_conv);
9325         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
9326         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
9327         return (uint64_t)ret_conv;
9328 }
9329
9330 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
9331         LDKDecodeError e_conv;
9332         e_conv.inner = (void*)(e & (~1));
9333         e_conv.is_owned = (e & 1) || (e == 0);
9334         e_conv = DecodeError_clone(&e_conv);
9335         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
9336         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
9337         return (uint64_t)ret_conv;
9338 }
9339
9340 void  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
9341         if ((_res & 1) != 0) return;
9342         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9343         CHECK_ACCESS(_res_ptr);
9344         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
9345         FREE((void*)_res);
9346         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
9347 }
9348
9349 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
9350         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
9351         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
9352         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
9353         return (uint64_t)ret_conv;
9354 }
9355
9356 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
9357         LDKCVec_ChannelDetailsZ _res_constr;
9358         _res_constr.datalen = *((uint32_t*)_res);
9359         if (_res_constr.datalen > 0)
9360                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9361         else
9362                 _res_constr.data = NULL;
9363         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9364         for (size_t q = 0; q < _res_constr.datalen; q++) {
9365                 uint32_t _res_conv_16 = _res_vals[q];
9366                 LDKChannelDetails _res_conv_16_conv;
9367                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9368                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9369                 _res_constr.data[q] = _res_conv_16_conv;
9370         }
9371         CVec_ChannelDetailsZ_free(_res_constr);
9372 }
9373
9374 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
9375         LDKRoute o_conv;
9376         o_conv.inner = (void*)(o & (~1));
9377         o_conv.is_owned = (o & 1) || (o == 0);
9378         o_conv = Route_clone(&o_conv);
9379         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9380         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9381         return (uint64_t)ret_conv;
9382 }
9383
9384 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
9385         LDKLightningError e_conv;
9386         e_conv.inner = (void*)(e & (~1));
9387         e_conv.is_owned = (e & 1) || (e == 0);
9388         e_conv = LightningError_clone(&e_conv);
9389         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9390         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9391         return (uint64_t)ret_conv;
9392 }
9393
9394 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
9395         if ((_res & 1) != 0) return;
9396         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9397         CHECK_ACCESS(_res_ptr);
9398         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
9399         FREE((void*)_res);
9400         CResult_RouteLightningErrorZ_free(_res_conv);
9401 }
9402
9403 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
9404         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9405         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9406         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9407         return (uint64_t)ret_conv;
9408 }
9409
9410 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
9411         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9412         CHECK_ACCESS(o_ptr);
9413         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
9414         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
9415         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9416         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9417         return (uint64_t)ret_conv;
9418 }
9419
9420 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
9421         LDKAccessError e_conv = LDKAccessError_from_js(e);
9422         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9423         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9424         return (uint64_t)ret_conv;
9425 }
9426
9427 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
9428         if ((_res & 1) != 0) return;
9429         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9430         CHECK_ACCESS(_res_ptr);
9431         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
9432         FREE((void*)_res);
9433         CResult_TxOutAccessErrorZ_free(_res_conv);
9434 }
9435
9436 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
9437         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9438         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9439         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9440         return (uint64_t)ret_conv;
9441 }
9442
9443 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
9444         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9445         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9446         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
9447         return ((uint64_t)ret_conv);
9448 }
9449
9450 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
9451         LDKTransaction b_ref;
9452         b_ref.datalen = *((uint32_t*)b);
9453         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9454         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
9455         b_ref.data_is_owned = true;
9456         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9457         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
9458         return ((uint64_t)ret_conv);
9459 }
9460
9461 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
9462         if ((_res & 1) != 0) return;
9463         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9464         CHECK_ACCESS(_res_ptr);
9465         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
9466         FREE((void*)_res);
9467         C2Tuple_usizeTransactionZ_free(_res_conv);
9468 }
9469
9470 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
9471         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9472         _res_constr.datalen = *((uint32_t*)_res);
9473         if (_res_constr.datalen > 0)
9474                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9475         else
9476                 _res_constr.data = NULL;
9477         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9478         for (size_t c = 0; c < _res_constr.datalen; c++) {
9479                 uint32_t _res_conv_28 = _res_vals[c];
9480                 void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
9481                 CHECK_ACCESS(_res_conv_28_ptr);
9482                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
9483                 FREE((void*)_res_conv_28);
9484                 _res_constr.data[c] = _res_conv_28_conv;
9485         }
9486         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9487 }
9488
9489 void  __attribute__((visibility("default"))) TS_CVec_TxidZ_free(ptrArray _res) {
9490         LDKCVec_TxidZ _res_constr;
9491         _res_constr.datalen = *((uint32_t*)_res);
9492         if (_res_constr.datalen > 0)
9493                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9494         else
9495                 _res_constr.data = NULL;
9496         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
9497         for (size_t m = 0; m < _res_constr.datalen; m++) {
9498                 int8_tArray _res_conv_12 = _res_vals[m];
9499                 LDKThirtyTwoBytes _res_conv_12_ref;
9500                 CHECK(*((uint32_t*)_res_conv_12) == 32);
9501                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), 32);
9502                 _res_constr.data[m] = _res_conv_12_ref;
9503         }
9504         CVec_TxidZ_free(_res_constr);
9505 }
9506
9507 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
9508         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9509         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
9510         return (uint64_t)ret_conv;
9511 }
9512
9513 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
9514         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
9515         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9516         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
9517         return (uint64_t)ret_conv;
9518 }
9519
9520 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
9521         if ((_res & 1) != 0) return;
9522         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9523         CHECK_ACCESS(_res_ptr);
9524         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
9525         FREE((void*)_res);
9526         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
9527 }
9528
9529 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
9530         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
9531         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9532         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
9533         return (uint64_t)ret_conv;
9534 }
9535
9536 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
9537         LDKCVec_MonitorEventZ _res_constr;
9538         _res_constr.datalen = *((uint32_t*)_res);
9539         if (_res_constr.datalen > 0)
9540                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
9541         else
9542                 _res_constr.data = NULL;
9543         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9544         for (size_t o = 0; o < _res_constr.datalen; o++) {
9545                 uint32_t _res_conv_14 = _res_vals[o];
9546                 void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
9547                 CHECK_ACCESS(_res_conv_14_ptr);
9548                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
9549                 FREE((void*)_res_conv_14);
9550                 _res_constr.data[o] = _res_conv_14_conv;
9551         }
9552         CVec_MonitorEventZ_free(_res_constr);
9553 }
9554
9555 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
9556         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9557         CHECK_ACCESS(o_ptr);
9558         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
9559         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
9560         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9561         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
9562         uint64_t ret_ref = (uint64_t)ret_copy;
9563         return ret_ref;
9564 }
9565
9566 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
9567         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9568         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
9569         uint64_t ret_ref = (uint64_t)ret_copy;
9570         return ret_ref;
9571 }
9572
9573 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
9574         if ((_res & 1) != 0) return;
9575         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9576         CHECK_ACCESS(_res_ptr);
9577         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
9578         FREE((void*)_res);
9579         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
9580 }
9581
9582 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
9583         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
9584         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9585         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
9586         uint64_t ret_ref = (uint64_t)ret_copy;
9587         return ret_ref;
9588 }
9589
9590 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
9591         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9592         CHECK_ACCESS(o_ptr);
9593         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
9594         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
9595         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
9596         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
9597         uint64_t ret_ref = (uint64_t)ret_copy;
9598         return ret_ref;
9599 }
9600
9601 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_none() {
9602         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
9603         *ret_copy = COption_NetworkUpdateZ_none();
9604         uint64_t ret_ref = (uint64_t)ret_copy;
9605         return ret_ref;
9606 }
9607
9608 void  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
9609         if ((_res & 1) != 0) return;
9610         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9611         CHECK_ACCESS(_res_ptr);
9612         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
9613         FREE((void*)_res);
9614         COption_NetworkUpdateZ_free(_res_conv);
9615 }
9616
9617 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
9618         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
9619         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
9620         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
9621         uint64_t ret_ref = (uint64_t)ret_copy;
9622         return ret_ref;
9623 }
9624
9625 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
9626         LDKCVec_SpendableOutputDescriptorZ _res_constr;
9627         _res_constr.datalen = *((uint32_t*)_res);
9628         if (_res_constr.datalen > 0)
9629                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
9630         else
9631                 _res_constr.data = NULL;
9632         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9633         for (size_t b = 0; b < _res_constr.datalen; b++) {
9634                 uint32_t _res_conv_27 = _res_vals[b];
9635                 void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
9636                 CHECK_ACCESS(_res_conv_27_ptr);
9637                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
9638                 FREE((void*)_res_conv_27);
9639                 _res_constr.data[b] = _res_conv_27_conv;
9640         }
9641         CVec_SpendableOutputDescriptorZ_free(_res_constr);
9642 }
9643
9644 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
9645         LDKCVec_MessageSendEventZ _res_constr;
9646         _res_constr.datalen = *((uint32_t*)_res);
9647         if (_res_constr.datalen > 0)
9648                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9649         else
9650                 _res_constr.data = NULL;
9651         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9652         for (size_t s = 0; s < _res_constr.datalen; s++) {
9653                 uint32_t _res_conv_18 = _res_vals[s];
9654                 void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
9655                 CHECK_ACCESS(_res_conv_18_ptr);
9656                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
9657                 FREE((void*)_res_conv_18);
9658                 _res_constr.data[s] = _res_conv_18_conv;
9659         }
9660         CVec_MessageSendEventZ_free(_res_constr);
9661 }
9662
9663 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
9664         LDKInitFeatures o_conv;
9665         o_conv.inner = (void*)(o & (~1));
9666         o_conv.is_owned = (o & 1) || (o == 0);
9667         o_conv = InitFeatures_clone(&o_conv);
9668         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9669         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
9670         return (uint64_t)ret_conv;
9671 }
9672
9673 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
9674         LDKDecodeError e_conv;
9675         e_conv.inner = (void*)(e & (~1));
9676         e_conv.is_owned = (e & 1) || (e == 0);
9677         e_conv = DecodeError_clone(&e_conv);
9678         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9679         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
9680         return (uint64_t)ret_conv;
9681 }
9682
9683 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
9684         if ((_res & 1) != 0) return;
9685         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9686         CHECK_ACCESS(_res_ptr);
9687         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
9688         FREE((void*)_res);
9689         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
9690 }
9691
9692 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
9693         LDKNodeFeatures o_conv;
9694         o_conv.inner = (void*)(o & (~1));
9695         o_conv.is_owned = (o & 1) || (o == 0);
9696         o_conv = NodeFeatures_clone(&o_conv);
9697         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9698         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
9699         return (uint64_t)ret_conv;
9700 }
9701
9702 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
9703         LDKDecodeError e_conv;
9704         e_conv.inner = (void*)(e & (~1));
9705         e_conv.is_owned = (e & 1) || (e == 0);
9706         e_conv = DecodeError_clone(&e_conv);
9707         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9708         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
9709         return (uint64_t)ret_conv;
9710 }
9711
9712 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
9713         if ((_res & 1) != 0) return;
9714         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9715         CHECK_ACCESS(_res_ptr);
9716         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
9717         FREE((void*)_res);
9718         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
9719 }
9720
9721 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
9722         LDKChannelFeatures o_conv;
9723         o_conv.inner = (void*)(o & (~1));
9724         o_conv.is_owned = (o & 1) || (o == 0);
9725         o_conv = ChannelFeatures_clone(&o_conv);
9726         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9727         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
9728         return (uint64_t)ret_conv;
9729 }
9730
9731 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
9732         LDKDecodeError e_conv;
9733         e_conv.inner = (void*)(e & (~1));
9734         e_conv.is_owned = (e & 1) || (e == 0);
9735         e_conv = DecodeError_clone(&e_conv);
9736         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9737         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
9738         return (uint64_t)ret_conv;
9739 }
9740
9741 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
9742         if ((_res & 1) != 0) return;
9743         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9744         CHECK_ACCESS(_res_ptr);
9745         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
9746         FREE((void*)_res);
9747         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
9748 }
9749
9750 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
9751         LDKInvoiceFeatures o_conv;
9752         o_conv.inner = (void*)(o & (~1));
9753         o_conv.is_owned = (o & 1) || (o == 0);
9754         o_conv = InvoiceFeatures_clone(&o_conv);
9755         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9756         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
9757         return (uint64_t)ret_conv;
9758 }
9759
9760 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
9761         LDKDecodeError e_conv;
9762         e_conv.inner = (void*)(e & (~1));
9763         e_conv.is_owned = (e & 1) || (e == 0);
9764         e_conv = DecodeError_clone(&e_conv);
9765         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9766         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
9767         return (uint64_t)ret_conv;
9768 }
9769
9770 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
9771         if ((_res & 1) != 0) return;
9772         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9773         CHECK_ACCESS(_res_ptr);
9774         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
9775         FREE((void*)_res);
9776         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
9777 }
9778
9779 uint32_t  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
9780         LDKScoringParameters o_conv;
9781         o_conv.inner = (void*)(o & (~1));
9782         o_conv.is_owned = (o & 1) || (o == 0);
9783         // Warning: we need a move here but no clone is available for LDKScoringParameters
9784         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
9785         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
9786         return (uint64_t)ret_conv;
9787 }
9788
9789 uint32_t  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
9790         LDKDecodeError e_conv;
9791         e_conv.inner = (void*)(e & (~1));
9792         e_conv.is_owned = (e & 1) || (e == 0);
9793         e_conv = DecodeError_clone(&e_conv);
9794         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
9795         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
9796         return (uint64_t)ret_conv;
9797 }
9798
9799 void  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
9800         if ((_res & 1) != 0) return;
9801         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9802         CHECK_ACCESS(_res_ptr);
9803         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
9804         FREE((void*)_res);
9805         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
9806 }
9807
9808 uint32_t  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_ok(uint32_t o) {
9809         LDKScorer o_conv;
9810         o_conv.inner = (void*)(o & (~1));
9811         o_conv.is_owned = (o & 1) || (o == 0);
9812         // Warning: we need a move here but no clone is available for LDKScorer
9813         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
9814         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
9815         return (uint64_t)ret_conv;
9816 }
9817
9818 uint32_t  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_err(uint32_t e) {
9819         LDKDecodeError e_conv;
9820         e_conv.inner = (void*)(e & (~1));
9821         e_conv.is_owned = (e & 1) || (e == 0);
9822         e_conv = DecodeError_clone(&e_conv);
9823         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
9824         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
9825         return (uint64_t)ret_conv;
9826 }
9827
9828 void  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_free(uint32_t _res) {
9829         if ((_res & 1) != 0) return;
9830         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9831         CHECK_ACCESS(_res_ptr);
9832         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
9833         FREE((void*)_res);
9834         CResult_ScorerDecodeErrorZ_free(_res_conv);
9835 }
9836
9837 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
9838         LDKDelayedPaymentOutputDescriptor o_conv;
9839         o_conv.inner = (void*)(o & (~1));
9840         o_conv.is_owned = (o & 1) || (o == 0);
9841         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
9842         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
9843         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
9844         return (uint64_t)ret_conv;
9845 }
9846
9847 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
9848         LDKDecodeError e_conv;
9849         e_conv.inner = (void*)(e & (~1));
9850         e_conv.is_owned = (e & 1) || (e == 0);
9851         e_conv = DecodeError_clone(&e_conv);
9852         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
9853         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
9854         return (uint64_t)ret_conv;
9855 }
9856
9857 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
9858         if ((_res & 1) != 0) return;
9859         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9860         CHECK_ACCESS(_res_ptr);
9861         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
9862         FREE((void*)_res);
9863         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
9864 }
9865
9866 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
9867         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
9868         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
9869         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
9870         return (uint64_t)ret_conv;
9871 }
9872
9873 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
9874         LDKStaticPaymentOutputDescriptor o_conv;
9875         o_conv.inner = (void*)(o & (~1));
9876         o_conv.is_owned = (o & 1) || (o == 0);
9877         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
9878         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
9879         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
9880         return (uint64_t)ret_conv;
9881 }
9882
9883 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
9884         LDKDecodeError e_conv;
9885         e_conv.inner = (void*)(e & (~1));
9886         e_conv.is_owned = (e & 1) || (e == 0);
9887         e_conv = DecodeError_clone(&e_conv);
9888         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
9889         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
9890         return (uint64_t)ret_conv;
9891 }
9892
9893 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
9894         if ((_res & 1) != 0) return;
9895         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9896         CHECK_ACCESS(_res_ptr);
9897         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
9898         FREE((void*)_res);
9899         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
9900 }
9901
9902 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
9903         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
9904         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
9905         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
9906         return (uint64_t)ret_conv;
9907 }
9908
9909 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
9910         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9911         CHECK_ACCESS(o_ptr);
9912         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
9913         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
9914         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9915         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
9916         return (uint64_t)ret_conv;
9917 }
9918
9919 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
9920         LDKDecodeError e_conv;
9921         e_conv.inner = (void*)(e & (~1));
9922         e_conv.is_owned = (e & 1) || (e == 0);
9923         e_conv = DecodeError_clone(&e_conv);
9924         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9925         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
9926         return (uint64_t)ret_conv;
9927 }
9928
9929 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
9930         if ((_res & 1) != 0) return;
9931         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9932         CHECK_ACCESS(_res_ptr);
9933         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
9934         FREE((void*)_res);
9935         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
9936 }
9937
9938 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
9939         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
9940         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
9941         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
9942         return (uint64_t)ret_conv;
9943 }
9944
9945 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_ok() {
9946         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
9947         *ret_conv = CResult_NoneNoneZ_ok();
9948         return (uint64_t)ret_conv;
9949 }
9950
9951 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_err() {
9952         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
9953         *ret_conv = CResult_NoneNoneZ_err();
9954         return (uint64_t)ret_conv;
9955 }
9956
9957 void  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
9958         if ((_res & 1) != 0) return;
9959         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9960         CHECK_ACCESS(_res_ptr);
9961         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
9962         FREE((void*)_res);
9963         CResult_NoneNoneZ_free(_res_conv);
9964 }
9965
9966 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
9967         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
9968         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
9969         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
9970         return (uint64_t)ret_conv;
9971 }
9972
9973 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
9974         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
9975         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
9976         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
9977         return ((uint64_t)ret_conv);
9978 }
9979
9980 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
9981         LDKSignature a_ref;
9982         CHECK(*((uint32_t*)a) == 64);
9983         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
9984         LDKCVec_SignatureZ b_constr;
9985         b_constr.datalen = *((uint32_t*)b);
9986         if (b_constr.datalen > 0)
9987                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9988         else
9989                 b_constr.data = NULL;
9990         int8_tArray* b_vals = (int8_tArray*)(b + 4);
9991         for (size_t m = 0; m < b_constr.datalen; m++) {
9992                 int8_tArray b_conv_12 = b_vals[m];
9993                 LDKSignature b_conv_12_ref;
9994                 CHECK(*((uint32_t*)b_conv_12) == 64);
9995                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
9996                 b_constr.data[m] = b_conv_12_ref;
9997         }
9998         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
9999         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
10000         return ((uint64_t)ret_conv);
10001 }
10002
10003 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
10004         if ((_res & 1) != 0) return;
10005         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10006         CHECK_ACCESS(_res_ptr);
10007         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
10008         FREE((void*)_res);
10009         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
10010 }
10011
10012 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
10013         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10014         CHECK_ACCESS(o_ptr);
10015         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
10016         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
10017         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10018         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
10019         return (uint64_t)ret_conv;
10020 }
10021
10022 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
10023         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10024         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
10025         return (uint64_t)ret_conv;
10026 }
10027
10028 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
10029         if ((_res & 1) != 0) return;
10030         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10031         CHECK_ACCESS(_res_ptr);
10032         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
10033         FREE((void*)_res);
10034         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
10035 }
10036
10037 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
10038         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
10039         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10040         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
10041         return (uint64_t)ret_conv;
10042 }
10043
10044 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
10045         LDKSignature o_ref;
10046         CHECK(*((uint32_t*)o) == 64);
10047         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
10048         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10049         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
10050         return (uint64_t)ret_conv;
10051 }
10052
10053 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
10054         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10055         *ret_conv = CResult_SignatureNoneZ_err();
10056         return (uint64_t)ret_conv;
10057 }
10058
10059 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
10060         if ((_res & 1) != 0) return;
10061         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10062         CHECK_ACCESS(_res_ptr);
10063         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
10064         FREE((void*)_res);
10065         CResult_SignatureNoneZ_free(_res_conv);
10066 }
10067
10068 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
10069         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
10070         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10071         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
10072         return (uint64_t)ret_conv;
10073 }
10074
10075 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
10076         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10077         CHECK_ACCESS(o_ptr);
10078         LDKSign o_conv = *(LDKSign*)(o_ptr);
10079         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10080         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
10081         return (uint64_t)ret_conv;
10082 }
10083
10084 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
10085         LDKDecodeError e_conv;
10086         e_conv.inner = (void*)(e & (~1));
10087         e_conv.is_owned = (e & 1) || (e == 0);
10088         e_conv = DecodeError_clone(&e_conv);
10089         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10090         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
10091         return (uint64_t)ret_conv;
10092 }
10093
10094 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
10095         if ((_res & 1) != 0) return;
10096         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10097         CHECK_ACCESS(_res_ptr);
10098         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
10099         FREE((void*)_res);
10100         CResult_SignDecodeErrorZ_free(_res_conv);
10101 }
10102
10103 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
10104         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
10105         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10106         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
10107         return (uint64_t)ret_conv;
10108 }
10109
10110 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
10111         LDKCVec_u8Z _res_ref;
10112         _res_ref.datalen = *((uint32_t*)_res);
10113         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
10114         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
10115         CVec_u8Z_free(_res_ref);
10116 }
10117
10118 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray arg) {
10119         LDKRecoverableSignature arg_ref;
10120         CHECK(*((uint32_t*)arg) == 68);
10121         memcpy(arg_ref.serialized_form, (uint8_t*)(arg + 4), 68);
10122         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10123         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
10124         return (uint64_t)ret_conv;
10125 }
10126
10127 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_err() {
10128         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10129         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
10130         return (uint64_t)ret_conv;
10131 }
10132
10133 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
10134         if ((_res & 1) != 0) return;
10135         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10136         CHECK_ACCESS(_res_ptr);
10137         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
10138         FREE((void*)_res);
10139         CResult_RecoverableSignatureNoneZ_free(_res_conv);
10140 }
10141
10142 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
10143         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
10144         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10145         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
10146         return (uint64_t)ret_conv;
10147 }
10148
10149 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
10150         LDKCVec_CVec_u8ZZ _res_constr;
10151         _res_constr.datalen = *((uint32_t*)_res);
10152         if (_res_constr.datalen > 0)
10153                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10154         else
10155                 _res_constr.data = NULL;
10156         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
10157         for (size_t m = 0; m < _res_constr.datalen; m++) {
10158                 int8_tArray _res_conv_12 = _res_vals[m];
10159                 LDKCVec_u8Z _res_conv_12_ref;
10160                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
10161                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
10162                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
10163                 _res_constr.data[m] = _res_conv_12_ref;
10164         }
10165         CVec_CVec_u8ZZ_free(_res_constr);
10166 }
10167
10168 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
10169         LDKCVec_CVec_u8ZZ o_constr;
10170         o_constr.datalen = *((uint32_t*)o);
10171         if (o_constr.datalen > 0)
10172                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10173         else
10174                 o_constr.data = NULL;
10175         int8_tArray* o_vals = (int8_tArray*)(o + 4);
10176         for (size_t m = 0; m < o_constr.datalen; m++) {
10177                 int8_tArray o_conv_12 = o_vals[m];
10178                 LDKCVec_u8Z o_conv_12_ref;
10179                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
10180                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
10181                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
10182                 o_constr.data[m] = o_conv_12_ref;
10183         }
10184         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10185         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10186         return (uint64_t)ret_conv;
10187 }
10188
10189 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
10190         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10191         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10192         return (uint64_t)ret_conv;
10193 }
10194
10195 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
10196         if ((_res & 1) != 0) return;
10197         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10198         CHECK_ACCESS(_res_ptr);
10199         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
10200         FREE((void*)_res);
10201         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10202 }
10203
10204 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
10205         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
10206         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10207         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
10208         return (uint64_t)ret_conv;
10209 }
10210
10211 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
10212         LDKInMemorySigner o_conv;
10213         o_conv.inner = (void*)(o & (~1));
10214         o_conv.is_owned = (o & 1) || (o == 0);
10215         o_conv = InMemorySigner_clone(&o_conv);
10216         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10217         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
10218         return (uint64_t)ret_conv;
10219 }
10220
10221 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
10222         LDKDecodeError e_conv;
10223         e_conv.inner = (void*)(e & (~1));
10224         e_conv.is_owned = (e & 1) || (e == 0);
10225         e_conv = DecodeError_clone(&e_conv);
10226         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10227         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
10228         return (uint64_t)ret_conv;
10229 }
10230
10231 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
10232         if ((_res & 1) != 0) return;
10233         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10234         CHECK_ACCESS(_res_ptr);
10235         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
10236         FREE((void*)_res);
10237         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
10238 }
10239
10240 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
10241         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
10242         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10243         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10244         return (uint64_t)ret_conv;
10245 }
10246
10247 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
10248         LDKCVec_TxOutZ _res_constr;
10249         _res_constr.datalen = *((uint32_t*)_res);
10250         if (_res_constr.datalen > 0)
10251                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10252         else
10253                 _res_constr.data = NULL;
10254         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10255         for (size_t h = 0; h < _res_constr.datalen; h++) {
10256                 uint32_t _res_conv_7 = _res_vals[h];
10257                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
10258                 CHECK_ACCESS(_res_conv_7_ptr);
10259                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
10260                 FREE((void*)_res_conv_7);
10261                 _res_constr.data[h] = _res_conv_7_conv;
10262         }
10263         CVec_TxOutZ_free(_res_constr);
10264 }
10265
10266 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
10267         LDKTransaction o_ref;
10268         o_ref.datalen = *((uint32_t*)o);
10269         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10270         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
10271         o_ref.data_is_owned = true;
10272         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10273         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10274         return (uint64_t)ret_conv;
10275 }
10276
10277 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
10278         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10279         *ret_conv = CResult_TransactionNoneZ_err();
10280         return (uint64_t)ret_conv;
10281 }
10282
10283 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
10284         if ((_res & 1) != 0) return;
10285         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10286         CHECK_ACCESS(_res_ptr);
10287         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
10288         FREE((void*)_res);
10289         CResult_TransactionNoneZ_free(_res_conv);
10290 }
10291
10292 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
10293         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10294         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10295         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10296         return (uint64_t)ret_conv;
10297 }
10298
10299 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
10300         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
10301         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10302         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
10303         return ((uint64_t)ret_conv);
10304 }
10305
10306 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
10307         LDKThirtyTwoBytes a_ref;
10308         CHECK(*((uint32_t*)a) == 32);
10309         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
10310         LDKChannelMonitor b_conv;
10311         b_conv.inner = (void*)(b & (~1));
10312         b_conv.is_owned = (b & 1) || (b == 0);
10313         b_conv = ChannelMonitor_clone(&b_conv);
10314         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10315         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10316         return ((uint64_t)ret_conv);
10317 }
10318
10319 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
10320         if ((_res & 1) != 0) return;
10321         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10322         CHECK_ACCESS(_res_ptr);
10323         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
10324         FREE((void*)_res);
10325         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10326 }
10327
10328 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMonitorZZ_free(uint32_tArray _res) {
10329         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10330         _res_constr.datalen = *((uint32_t*)_res);
10331         if (_res_constr.datalen > 0)
10332                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10333         else
10334                 _res_constr.data = NULL;
10335         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10336         for (size_t j = 0; j < _res_constr.datalen; j++) {
10337                 uint32_t _res_conv_35 = _res_vals[j];
10338                 void* _res_conv_35_ptr = (void*)(((uint64_t)_res_conv_35) & ~1);
10339                 CHECK_ACCESS(_res_conv_35_ptr);
10340                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
10341                 FREE((void*)_res_conv_35);
10342                 _res_constr.data[j] = _res_conv_35_conv;
10343         }
10344         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10345 }
10346
10347 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(uint32_tArray o) {
10348         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10349         o_constr.datalen = *((uint32_t*)o);
10350         if (o_constr.datalen > 0)
10351                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10352         else
10353                 o_constr.data = NULL;
10354         uint32_t* o_vals = (uint32_t*)(o + 4);
10355         for (size_t j = 0; j < o_constr.datalen; j++) {
10356                 uint32_t o_conv_35 = o_vals[j];
10357                 void* o_conv_35_ptr = (void*)(((uint64_t)o_conv_35) & ~1);
10358                 CHECK_ACCESS(o_conv_35_ptr);
10359                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
10360                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
10361                 o_constr.data[j] = o_conv_35_conv;
10362         }
10363         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10364         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10365         return (uint64_t)ret_conv;
10366 }
10367
10368 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(uint32_t e) {
10369         LDKIOError e_conv = LDKIOError_from_js(e);
10370         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10371         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10372         return (uint64_t)ret_conv;
10373 }
10374
10375 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
10376         if ((_res & 1) != 0) return;
10377         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10378         CHECK_ACCESS(_res_ptr);
10379         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
10380         FREE((void*)_res);
10381         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10382 }
10383
10384 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(uint32_t orig) {
10385         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
10386         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10387         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
10388         return (uint64_t)ret_conv;
10389 }
10390
10391 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) {
10392         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10393         *ret_copy = COption_u16Z_some(o);
10394         uint64_t ret_ref = (uint64_t)ret_copy;
10395         return ret_ref;
10396 }
10397
10398 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_none() {
10399         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10400         *ret_copy = COption_u16Z_none();
10401         uint64_t ret_ref = (uint64_t)ret_copy;
10402         return ret_ref;
10403 }
10404
10405 void  __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) {
10406         if ((_res & 1) != 0) return;
10407         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10408         CHECK_ACCESS(_res_ptr);
10409         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
10410         FREE((void*)_res);
10411         COption_u16Z_free(_res_conv);
10412 }
10413
10414 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_clone(uint32_t orig) {
10415         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
10416         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10417         *ret_copy = COption_u16Z_clone(orig_conv);
10418         uint64_t ret_ref = (uint64_t)ret_copy;
10419         return ret_ref;
10420 }
10421
10422 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
10423         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10424         *ret_conv = CResult_NoneAPIErrorZ_ok();
10425         return (uint64_t)ret_conv;
10426 }
10427
10428 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
10429         void* e_ptr = (void*)(((uint64_t)e) & ~1);
10430         CHECK_ACCESS(e_ptr);
10431         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
10432         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
10433         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10434         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10435         return (uint64_t)ret_conv;
10436 }
10437
10438 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
10439         if ((_res & 1) != 0) return;
10440         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10441         CHECK_ACCESS(_res_ptr);
10442         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
10443         FREE((void*)_res);
10444         CResult_NoneAPIErrorZ_free(_res_conv);
10445 }
10446
10447 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
10448         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10449         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10450         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10451         return (uint64_t)ret_conv;
10452 }
10453
10454 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
10455         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10456         _res_constr.datalen = *((uint32_t*)_res);
10457         if (_res_constr.datalen > 0)
10458                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10459         else
10460                 _res_constr.data = NULL;
10461         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10462         for (size_t w = 0; w < _res_constr.datalen; w++) {
10463                 uint32_t _res_conv_22 = _res_vals[w];
10464                 void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
10465                 CHECK_ACCESS(_res_conv_22_ptr);
10466                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
10467                 FREE((void*)_res_conv_22);
10468                 _res_constr.data[w] = _res_conv_22_conv;
10469         }
10470         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10471 }
10472
10473 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
10474         LDKCVec_APIErrorZ _res_constr;
10475         _res_constr.datalen = *((uint32_t*)_res);
10476         if (_res_constr.datalen > 0)
10477                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10478         else
10479                 _res_constr.data = NULL;
10480         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10481         for (size_t k = 0; k < _res_constr.datalen; k++) {
10482                 uint32_t _res_conv_10 = _res_vals[k];
10483                 void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
10484                 CHECK_ACCESS(_res_conv_10_ptr);
10485                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
10486                 FREE((void*)_res_conv_10);
10487                 _res_constr.data[k] = _res_conv_10_conv;
10488         }
10489         CVec_APIErrorZ_free(_res_constr);
10490 }
10491
10492 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
10493         LDKThirtyTwoBytes o_ref;
10494         CHECK(*((uint32_t*)o) == 32);
10495         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
10496         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
10497         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
10498         return (uint64_t)ret_conv;
10499 }
10500
10501 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
10502         void* e_ptr = (void*)(((uint64_t)e) & ~1);
10503         CHECK_ACCESS(e_ptr);
10504         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
10505         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
10506         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
10507         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
10508         return (uint64_t)ret_conv;
10509 }
10510
10511 void  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
10512         if ((_res & 1) != 0) return;
10513         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10514         CHECK_ACCESS(_res_ptr);
10515         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
10516         FREE((void*)_res);
10517         CResult__u832APIErrorZ_free(_res_conv);
10518 }
10519
10520 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
10521         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
10522         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
10523         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
10524         return (uint64_t)ret_conv;
10525 }
10526
10527 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
10528         LDKThirtyTwoBytes o_ref;
10529         CHECK(*((uint32_t*)o) == 32);
10530         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
10531         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10532         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
10533         return (uint64_t)ret_conv;
10534 }
10535
10536 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
10537         void* e_ptr = (void*)(((uint64_t)e) & ~1);
10538         CHECK_ACCESS(e_ptr);
10539         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
10540         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
10541         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10542         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
10543         return (uint64_t)ret_conv;
10544 }
10545
10546 void  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
10547         if ((_res & 1) != 0) return;
10548         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10549         CHECK_ACCESS(_res_ptr);
10550         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
10551         FREE((void*)_res);
10552         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
10553 }
10554
10555 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
10556         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
10557         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10558         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
10559         return (uint64_t)ret_conv;
10560 }
10561
10562 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
10563         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10564         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10565         return (uint64_t)ret_conv;
10566 }
10567
10568 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
10569         void* e_ptr = (void*)(((uint64_t)e) & ~1);
10570         CHECK_ACCESS(e_ptr);
10571         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
10572         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
10573         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10574         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10575         return (uint64_t)ret_conv;
10576 }
10577
10578 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
10579         if ((_res & 1) != 0) return;
10580         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10581         CHECK_ACCESS(_res_ptr);
10582         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
10583         FREE((void*)_res);
10584         CResult_NonePaymentSendFailureZ_free(_res_conv);
10585 }
10586
10587 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
10588         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10589         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10590         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10591         return (uint64_t)ret_conv;
10592 }
10593
10594 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
10595         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
10596         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
10597         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
10598         return ((uint64_t)ret_conv);
10599 }
10600
10601 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
10602         LDKThirtyTwoBytes a_ref;
10603         CHECK(*((uint32_t*)a) == 32);
10604         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
10605         LDKThirtyTwoBytes b_ref;
10606         CHECK(*((uint32_t*)b) == 32);
10607         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
10608         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
10609         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
10610         return ((uint64_t)ret_conv);
10611 }
10612
10613 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
10614         if ((_res & 1) != 0) return;
10615         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10616         CHECK_ACCESS(_res_ptr);
10617         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
10618         FREE((void*)_res);
10619         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
10620 }
10621
10622 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
10623         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10624         CHECK_ACCESS(o_ptr);
10625         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
10626         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
10627         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
10628         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
10629         return (uint64_t)ret_conv;
10630 }
10631
10632 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
10633         void* e_ptr = (void*)(((uint64_t)e) & ~1);
10634         CHECK_ACCESS(e_ptr);
10635         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
10636         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
10637         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
10638         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
10639         return (uint64_t)ret_conv;
10640 }
10641
10642 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
10643         if ((_res & 1) != 0) return;
10644         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10645         CHECK_ACCESS(_res_ptr);
10646         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
10647         FREE((void*)_res);
10648         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
10649 }
10650
10651 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
10652         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
10653         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
10654         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
10655         return (uint64_t)ret_conv;
10656 }
10657
10658 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
10659         LDKCVec_NetAddressZ _res_constr;
10660         _res_constr.datalen = *((uint32_t*)_res);
10661         if (_res_constr.datalen > 0)
10662                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10663         else
10664                 _res_constr.data = NULL;
10665         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10666         for (size_t m = 0; m < _res_constr.datalen; m++) {
10667                 uint32_t _res_conv_12 = _res_vals[m];
10668                 void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
10669                 CHECK_ACCESS(_res_conv_12_ptr);
10670                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
10671                 FREE((void*)_res_conv_12);
10672                 _res_constr.data[m] = _res_conv_12_conv;
10673         }
10674         CVec_NetAddressZ_free(_res_constr);
10675 }
10676
10677 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
10678         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
10679         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10680         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
10681         return ((uint64_t)ret_conv);
10682 }
10683
10684 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
10685         LDKThirtyTwoBytes a_ref;
10686         CHECK(*((uint32_t*)a) == 32);
10687         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
10688         LDKThirtyTwoBytes b_ref;
10689         CHECK(*((uint32_t*)b) == 32);
10690         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
10691         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10692         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
10693         return ((uint64_t)ret_conv);
10694 }
10695
10696 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
10697         if ((_res & 1) != 0) return;
10698         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10699         CHECK_ACCESS(_res_ptr);
10700         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
10701         FREE((void*)_res);
10702         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
10703 }
10704
10705 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
10706         LDKThirtyTwoBytes o_ref;
10707         CHECK(*((uint32_t*)o) == 32);
10708         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
10709         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10710         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
10711         return (uint64_t)ret_conv;
10712 }
10713
10714 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
10715         void* e_ptr = (void*)(((uint64_t)e) & ~1);
10716         CHECK_ACCESS(e_ptr);
10717         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
10718         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
10719         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10720         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
10721         return (uint64_t)ret_conv;
10722 }
10723
10724 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
10725         if ((_res & 1) != 0) return;
10726         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10727         CHECK_ACCESS(_res_ptr);
10728         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
10729         FREE((void*)_res);
10730         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
10731 }
10732
10733 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
10734         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
10735         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10736         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
10737         return (uint64_t)ret_conv;
10738 }
10739
10740 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
10741         LDKCVec_ChannelMonitorZ _res_constr;
10742         _res_constr.datalen = *((uint32_t*)_res);
10743         if (_res_constr.datalen > 0)
10744                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10745         else
10746                 _res_constr.data = NULL;
10747         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10748         for (size_t q = 0; q < _res_constr.datalen; q++) {
10749                 uint32_t _res_conv_16 = _res_vals[q];
10750                 LDKChannelMonitor _res_conv_16_conv;
10751                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10752                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10753                 _res_constr.data[q] = _res_conv_16_conv;
10754         }
10755         CVec_ChannelMonitorZ_free(_res_constr);
10756 }
10757
10758 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
10759         LDKThirtyTwoBytes a_ref;
10760         CHECK(*((uint32_t*)a) == 32);
10761         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
10762         LDKChannelManager b_conv;
10763         b_conv.inner = (void*)(b & (~1));
10764         b_conv.is_owned = (b & 1) || (b == 0);
10765         // Warning: we need a move here but no clone is available for LDKChannelManager
10766         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10767         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10768         return ((uint64_t)ret_conv);
10769 }
10770
10771 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
10772         if ((_res & 1) != 0) return;
10773         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10774         CHECK_ACCESS(_res_ptr);
10775         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
10776         FREE((void*)_res);
10777         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10778 }
10779
10780 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
10781         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10782         CHECK_ACCESS(o_ptr);
10783         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
10784         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
10785         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10786         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10787         return (uint64_t)ret_conv;
10788 }
10789
10790 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
10791         LDKDecodeError e_conv;
10792         e_conv.inner = (void*)(e & (~1));
10793         e_conv.is_owned = (e & 1) || (e == 0);
10794         e_conv = DecodeError_clone(&e_conv);
10795         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10796         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10797         return (uint64_t)ret_conv;
10798 }
10799
10800 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
10801         if ((_res & 1) != 0) return;
10802         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10803         CHECK_ACCESS(_res_ptr);
10804         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
10805         FREE((void*)_res);
10806         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10807 }
10808
10809 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
10810         LDKChannelConfig o_conv;
10811         o_conv.inner = (void*)(o & (~1));
10812         o_conv.is_owned = (o & 1) || (o == 0);
10813         o_conv = ChannelConfig_clone(&o_conv);
10814         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10815         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
10816         return (uint64_t)ret_conv;
10817 }
10818
10819 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_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_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10825         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
10826         return (uint64_t)ret_conv;
10827 }
10828
10829 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
10830         if ((_res & 1) != 0) return;
10831         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10832         CHECK_ACCESS(_res_ptr);
10833         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
10834         FREE((void*)_res);
10835         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
10836 }
10837
10838 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
10839         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
10840         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10841         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
10842         return (uint64_t)ret_conv;
10843 }
10844
10845 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
10846         LDKOutPoint o_conv;
10847         o_conv.inner = (void*)(o & (~1));
10848         o_conv.is_owned = (o & 1) || (o == 0);
10849         o_conv = OutPoint_clone(&o_conv);
10850         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10851         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
10852         return (uint64_t)ret_conv;
10853 }
10854
10855 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
10856         LDKDecodeError e_conv;
10857         e_conv.inner = (void*)(e & (~1));
10858         e_conv.is_owned = (e & 1) || (e == 0);
10859         e_conv = DecodeError_clone(&e_conv);
10860         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10861         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
10862         return (uint64_t)ret_conv;
10863 }
10864
10865 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
10866         if ((_res & 1) != 0) return;
10867         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10868         CHECK_ACCESS(_res_ptr);
10869         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
10870         FREE((void*)_res);
10871         CResult_OutPointDecodeErrorZ_free(_res_conv);
10872 }
10873
10874 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
10875         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
10876         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10877         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
10878         return (uint64_t)ret_conv;
10879 }
10880
10881 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_some(uint32_t o) {
10882         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10883         CHECK_ACCESS(o_ptr);
10884         LDKType o_conv = *(LDKType*)(o_ptr);
10885         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
10886         *ret_copy = COption_TypeZ_some(o_conv);
10887         uint64_t ret_ref = (uint64_t)ret_copy;
10888         return ret_ref;
10889 }
10890
10891 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_none() {
10892         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
10893         *ret_copy = COption_TypeZ_none();
10894         uint64_t ret_ref = (uint64_t)ret_copy;
10895         return ret_ref;
10896 }
10897
10898 void  __attribute__((visibility("default"))) TS_COption_TypeZ_free(uint32_t _res) {
10899         if ((_res & 1) != 0) return;
10900         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10901         CHECK_ACCESS(_res_ptr);
10902         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
10903         FREE((void*)_res);
10904         COption_TypeZ_free(_res_conv);
10905 }
10906
10907 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_clone(uint32_t orig) {
10908         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
10909         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
10910         *ret_copy = COption_TypeZ_clone(orig_conv);
10911         uint64_t ret_ref = (uint64_t)ret_copy;
10912         return ret_ref;
10913 }
10914
10915 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
10916         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10917         CHECK_ACCESS(o_ptr);
10918         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
10919         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
10920         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10921         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
10922         return (uint64_t)ret_conv;
10923 }
10924
10925 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
10926         LDKDecodeError e_conv;
10927         e_conv.inner = (void*)(e & (~1));
10928         e_conv.is_owned = (e & 1) || (e == 0);
10929         e_conv = DecodeError_clone(&e_conv);
10930         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10931         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
10932         return (uint64_t)ret_conv;
10933 }
10934
10935 void  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
10936         if ((_res & 1) != 0) return;
10937         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10938         CHECK_ACCESS(_res_ptr);
10939         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
10940         FREE((void*)_res);
10941         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
10942 }
10943
10944 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
10945         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
10946         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10947         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
10948         return (uint64_t)ret_conv;
10949 }
10950
10951 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
10952         LDKThirtyTwoBytes o_ref;
10953         CHECK(*((uint32_t*)o) == 32);
10954         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
10955         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
10956         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
10957         return (uint64_t)ret_conv;
10958 }
10959
10960 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
10961         void* e_ptr = (void*)(((uint64_t)e) & ~1);
10962         CHECK_ACCESS(e_ptr);
10963         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
10964         e_conv = PaymentError_clone((LDKPaymentError*)(((uint64_t)e) & ~1));
10965         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
10966         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
10967         return (uint64_t)ret_conv;
10968 }
10969
10970 void  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
10971         if ((_res & 1) != 0) return;
10972         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10973         CHECK_ACCESS(_res_ptr);
10974         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
10975         FREE((void*)_res);
10976         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
10977 }
10978
10979 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
10980         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
10981         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
10982         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
10983         return (uint64_t)ret_conv;
10984 }
10985
10986 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
10987         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
10988         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10989         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
10990         return (uint64_t)ret_conv;
10991 }
10992
10993 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err() {
10994         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10995         *ret_conv = CResult_SiPrefixNoneZ_err();
10996         return (uint64_t)ret_conv;
10997 }
10998
10999 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
11000         if ((_res & 1) != 0) return;
11001         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11002         CHECK_ACCESS(_res_ptr);
11003         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
11004         FREE((void*)_res);
11005         CResult_SiPrefixNoneZ_free(_res_conv);
11006 }
11007
11008 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
11009         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
11010         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11011         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
11012         return (uint64_t)ret_conv;
11013 }
11014
11015 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
11016         LDKInvoice o_conv;
11017         o_conv.inner = (void*)(o & (~1));
11018         o_conv.is_owned = (o & 1) || (o == 0);
11019         o_conv = Invoice_clone(&o_conv);
11020         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11021         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
11022         return (uint64_t)ret_conv;
11023 }
11024
11025 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
11026         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11027         *ret_conv = CResult_InvoiceNoneZ_err();
11028         return (uint64_t)ret_conv;
11029 }
11030
11031 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
11032         if ((_res & 1) != 0) return;
11033         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11034         CHECK_ACCESS(_res_ptr);
11035         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
11036         FREE((void*)_res);
11037         CResult_InvoiceNoneZ_free(_res_conv);
11038 }
11039
11040 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
11041         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
11042         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11043         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
11044         return (uint64_t)ret_conv;
11045 }
11046
11047 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
11048         LDKSignedRawInvoice o_conv;
11049         o_conv.inner = (void*)(o & (~1));
11050         o_conv.is_owned = (o & 1) || (o == 0);
11051         o_conv = SignedRawInvoice_clone(&o_conv);
11052         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11053         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
11054         return (uint64_t)ret_conv;
11055 }
11056
11057 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
11058         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11059         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
11060         return (uint64_t)ret_conv;
11061 }
11062
11063 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
11064         if ((_res & 1) != 0) return;
11065         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11066         CHECK_ACCESS(_res_ptr);
11067         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
11068         FREE((void*)_res);
11069         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
11070 }
11071
11072 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
11073         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
11074         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11075         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
11076         return (uint64_t)ret_conv;
11077 }
11078
11079 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
11080         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
11081         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11082         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
11083         return ((uint64_t)ret_conv);
11084 }
11085
11086 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
11087         LDKRawInvoice a_conv;
11088         a_conv.inner = (void*)(a & (~1));
11089         a_conv.is_owned = (a & 1) || (a == 0);
11090         a_conv = RawInvoice_clone(&a_conv);
11091         LDKThirtyTwoBytes b_ref;
11092         CHECK(*((uint32_t*)b) == 32);
11093         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
11094         LDKInvoiceSignature c_conv;
11095         c_conv.inner = (void*)(c & (~1));
11096         c_conv.is_owned = (c & 1) || (c == 0);
11097         c_conv = InvoiceSignature_clone(&c_conv);
11098         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11099         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
11100         return ((uint64_t)ret_conv);
11101 }
11102
11103 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
11104         if ((_res & 1) != 0) return;
11105         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11106         CHECK_ACCESS(_res_ptr);
11107         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
11108         FREE((void*)_res);
11109         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
11110 }
11111
11112 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
11113         LDKPayeePubKey o_conv;
11114         o_conv.inner = (void*)(o & (~1));
11115         o_conv.is_owned = (o & 1) || (o == 0);
11116         o_conv = PayeePubKey_clone(&o_conv);
11117         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11118         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
11119         return (uint64_t)ret_conv;
11120 }
11121
11122 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
11123         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11124         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11125         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
11126         return (uint64_t)ret_conv;
11127 }
11128
11129 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
11130         if ((_res & 1) != 0) return;
11131         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11132         CHECK_ACCESS(_res_ptr);
11133         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
11134         FREE((void*)_res);
11135         CResult_PayeePubKeyErrorZ_free(_res_conv);
11136 }
11137
11138 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
11139         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
11140         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11141         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
11142         return (uint64_t)ret_conv;
11143 }
11144
11145 void  __attribute__((visibility("default"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
11146         LDKCVec_PrivateRouteZ _res_constr;
11147         _res_constr.datalen = *((uint32_t*)_res);
11148         if (_res_constr.datalen > 0)
11149                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
11150         else
11151                 _res_constr.data = NULL;
11152         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11153         for (size_t o = 0; o < _res_constr.datalen; o++) {
11154                 uint32_t _res_conv_14 = _res_vals[o];
11155                 LDKPrivateRoute _res_conv_14_conv;
11156                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11157                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11158                 _res_constr.data[o] = _res_conv_14_conv;
11159         }
11160         CVec_PrivateRouteZ_free(_res_constr);
11161 }
11162
11163 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
11164         LDKPositiveTimestamp o_conv;
11165         o_conv.inner = (void*)(o & (~1));
11166         o_conv.is_owned = (o & 1) || (o == 0);
11167         o_conv = PositiveTimestamp_clone(&o_conv);
11168         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11169         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
11170         return (uint64_t)ret_conv;
11171 }
11172
11173 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
11174         LDKCreationError e_conv = LDKCreationError_from_js(e);
11175         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11176         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
11177         return (uint64_t)ret_conv;
11178 }
11179
11180 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
11181         if ((_res & 1) != 0) return;
11182         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11183         CHECK_ACCESS(_res_ptr);
11184         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
11185         FREE((void*)_res);
11186         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
11187 }
11188
11189 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
11190         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
11191         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11192         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
11193         return (uint64_t)ret_conv;
11194 }
11195
11196 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_ok() {
11197         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11198         *ret_conv = CResult_NoneSemanticErrorZ_ok();
11199         return (uint64_t)ret_conv;
11200 }
11201
11202 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
11203         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
11204         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11205         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
11206         return (uint64_t)ret_conv;
11207 }
11208
11209 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
11210         if ((_res & 1) != 0) return;
11211         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11212         CHECK_ACCESS(_res_ptr);
11213         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
11214         FREE((void*)_res);
11215         CResult_NoneSemanticErrorZ_free(_res_conv);
11216 }
11217
11218 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
11219         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
11220         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11221         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
11222         return (uint64_t)ret_conv;
11223 }
11224
11225 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
11226         LDKInvoice o_conv;
11227         o_conv.inner = (void*)(o & (~1));
11228         o_conv.is_owned = (o & 1) || (o == 0);
11229         o_conv = Invoice_clone(&o_conv);
11230         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11231         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
11232         return (uint64_t)ret_conv;
11233 }
11234
11235 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
11236         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
11237         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11238         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
11239         return (uint64_t)ret_conv;
11240 }
11241
11242 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
11243         if ((_res & 1) != 0) return;
11244         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11245         CHECK_ACCESS(_res_ptr);
11246         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
11247         FREE((void*)_res);
11248         CResult_InvoiceSemanticErrorZ_free(_res_conv);
11249 }
11250
11251 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
11252         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
11253         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11254         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
11255         return (uint64_t)ret_conv;
11256 }
11257
11258 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
11259         LDKDescription o_conv;
11260         o_conv.inner = (void*)(o & (~1));
11261         o_conv.is_owned = (o & 1) || (o == 0);
11262         o_conv = Description_clone(&o_conv);
11263         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11264         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
11265         return (uint64_t)ret_conv;
11266 }
11267
11268 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
11269         LDKCreationError e_conv = LDKCreationError_from_js(e);
11270         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11271         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
11272         return (uint64_t)ret_conv;
11273 }
11274
11275 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
11276         if ((_res & 1) != 0) return;
11277         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11278         CHECK_ACCESS(_res_ptr);
11279         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
11280         FREE((void*)_res);
11281         CResult_DescriptionCreationErrorZ_free(_res_conv);
11282 }
11283
11284 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
11285         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
11286         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11287         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
11288         return (uint64_t)ret_conv;
11289 }
11290
11291 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_ok(uint32_t o) {
11292         LDKExpiryTime o_conv;
11293         o_conv.inner = (void*)(o & (~1));
11294         o_conv.is_owned = (o & 1) || (o == 0);
11295         o_conv = ExpiryTime_clone(&o_conv);
11296         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11297         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
11298         return (uint64_t)ret_conv;
11299 }
11300
11301 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_err(uint32_t e) {
11302         LDKCreationError e_conv = LDKCreationError_from_js(e);
11303         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11304         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
11305         return (uint64_t)ret_conv;
11306 }
11307
11308 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
11309         if ((_res & 1) != 0) return;
11310         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11311         CHECK_ACCESS(_res_ptr);
11312         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
11313         FREE((void*)_res);
11314         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
11315 }
11316
11317 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone(uint32_t orig) {
11318         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
11319         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11320         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
11321         return (uint64_t)ret_conv;
11322 }
11323
11324 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
11325         LDKPrivateRoute o_conv;
11326         o_conv.inner = (void*)(o & (~1));
11327         o_conv.is_owned = (o & 1) || (o == 0);
11328         o_conv = PrivateRoute_clone(&o_conv);
11329         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11330         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
11331         return (uint64_t)ret_conv;
11332 }
11333
11334 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
11335         LDKCreationError e_conv = LDKCreationError_from_js(e);
11336         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11337         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
11338         return (uint64_t)ret_conv;
11339 }
11340
11341 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
11342         if ((_res & 1) != 0) return;
11343         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11344         CHECK_ACCESS(_res_ptr);
11345         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
11346         FREE((void*)_res);
11347         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
11348 }
11349
11350 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
11351         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
11352         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11353         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
11354         return (uint64_t)ret_conv;
11355 }
11356
11357 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_ok(jstring o) {
11358         LDKStr o_conv = str_ref_to_owned_c(o);
11359         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11360         *ret_conv = CResult_StringErrorZ_ok(o_conv);
11361         return (uint64_t)ret_conv;
11362 }
11363
11364 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uint32_t e) {
11365         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11366         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11367         *ret_conv = CResult_StringErrorZ_err(e_conv);
11368         return (uint64_t)ret_conv;
11369 }
11370
11371 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
11372         if ((_res & 1) != 0) return;
11373         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11374         CHECK_ACCESS(_res_ptr);
11375         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
11376         FREE((void*)_res);
11377         CResult_StringErrorZ_free(_res_conv);
11378 }
11379
11380 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
11381         LDKChannelMonitorUpdate o_conv;
11382         o_conv.inner = (void*)(o & (~1));
11383         o_conv.is_owned = (o & 1) || (o == 0);
11384         o_conv = ChannelMonitorUpdate_clone(&o_conv);
11385         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11386         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
11387         return (uint64_t)ret_conv;
11388 }
11389
11390 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
11391         LDKDecodeError e_conv;
11392         e_conv.inner = (void*)(e & (~1));
11393         e_conv.is_owned = (e & 1) || (e == 0);
11394         e_conv = DecodeError_clone(&e_conv);
11395         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11396         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
11397         return (uint64_t)ret_conv;
11398 }
11399
11400 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
11401         if ((_res & 1) != 0) return;
11402         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11403         CHECK_ACCESS(_res_ptr);
11404         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
11405         FREE((void*)_res);
11406         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
11407 }
11408
11409 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
11410         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
11411         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11412         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
11413         return (uint64_t)ret_conv;
11414 }
11415
11416 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
11417         LDKHTLCUpdate o_conv;
11418         o_conv.inner = (void*)(o & (~1));
11419         o_conv.is_owned = (o & 1) || (o == 0);
11420         o_conv = HTLCUpdate_clone(&o_conv);
11421         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11422         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
11423         return (uint64_t)ret_conv;
11424 }
11425
11426 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
11427         LDKDecodeError e_conv;
11428         e_conv.inner = (void*)(e & (~1));
11429         e_conv.is_owned = (e & 1) || (e == 0);
11430         e_conv = DecodeError_clone(&e_conv);
11431         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11432         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
11433         return (uint64_t)ret_conv;
11434 }
11435
11436 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
11437         if ((_res & 1) != 0) return;
11438         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11439         CHECK_ACCESS(_res_ptr);
11440         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
11441         FREE((void*)_res);
11442         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
11443 }
11444
11445 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
11446         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
11447         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11448         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
11449         return (uint64_t)ret_conv;
11450 }
11451
11452 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
11453         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11454         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
11455         return (uint64_t)ret_conv;
11456 }
11457
11458 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
11459         LDKMonitorUpdateError e_conv;
11460         e_conv.inner = (void*)(e & (~1));
11461         e_conv.is_owned = (e & 1) || (e == 0);
11462         e_conv = MonitorUpdateError_clone(&e_conv);
11463         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11464         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
11465         return (uint64_t)ret_conv;
11466 }
11467
11468 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
11469         if ((_res & 1) != 0) return;
11470         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11471         CHECK_ACCESS(_res_ptr);
11472         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(_res_ptr);
11473         FREE((void*)_res);
11474         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
11475 }
11476
11477 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
11478         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
11479         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11480         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
11481         return (uint64_t)ret_conv;
11482 }
11483
11484 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
11485         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
11486         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11487         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
11488         return ((uint64_t)ret_conv);
11489 }
11490
11491 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
11492         LDKOutPoint a_conv;
11493         a_conv.inner = (void*)(a & (~1));
11494         a_conv.is_owned = (a & 1) || (a == 0);
11495         a_conv = OutPoint_clone(&a_conv);
11496         LDKCVec_u8Z b_ref;
11497         b_ref.datalen = *((uint32_t*)b);
11498         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11499         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
11500         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11501         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
11502         return ((uint64_t)ret_conv);
11503 }
11504
11505 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
11506         if ((_res & 1) != 0) return;
11507         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11508         CHECK_ACCESS(_res_ptr);
11509         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
11510         FREE((void*)_res);
11511         C2Tuple_OutPointScriptZ_free(_res_conv);
11512 }
11513
11514 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
11515         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
11516         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11517         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
11518         return ((uint64_t)ret_conv);
11519 }
11520
11521 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
11522         LDKCVec_u8Z b_ref;
11523         b_ref.datalen = *((uint32_t*)b);
11524         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11525         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
11526         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11527         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
11528         return ((uint64_t)ret_conv);
11529 }
11530
11531 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
11532         if ((_res & 1) != 0) return;
11533         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11534         CHECK_ACCESS(_res_ptr);
11535         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
11536         FREE((void*)_res);
11537         C2Tuple_u32ScriptZ_free(_res_conv);
11538 }
11539
11540 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
11541         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
11542         _res_constr.datalen = *((uint32_t*)_res);
11543         if (_res_constr.datalen > 0)
11544                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11545         else
11546                 _res_constr.data = NULL;
11547         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11548         for (size_t v = 0; v < _res_constr.datalen; v++) {
11549                 uint32_t _res_conv_21 = _res_vals[v];
11550                 void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
11551                 CHECK_ACCESS(_res_conv_21_ptr);
11552                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
11553                 FREE((void*)_res_conv_21);
11554                 _res_constr.data[v] = _res_conv_21_conv;
11555         }
11556         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
11557 }
11558
11559 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
11560         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
11561         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11562         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
11563         return ((uint64_t)ret_conv);
11564 }
11565
11566 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
11567         LDKThirtyTwoBytes a_ref;
11568         CHECK(*((uint32_t*)a) == 32);
11569         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
11570         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
11571         b_constr.datalen = *((uint32_t*)b);
11572         if (b_constr.datalen > 0)
11573                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11574         else
11575                 b_constr.data = NULL;
11576         uint32_t* b_vals = (uint32_t*)(b + 4);
11577         for (size_t v = 0; v < b_constr.datalen; v++) {
11578                 uint32_t b_conv_21 = b_vals[v];
11579                 void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
11580                 CHECK_ACCESS(b_conv_21_ptr);
11581                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
11582                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
11583                 b_constr.data[v] = b_conv_21_conv;
11584         }
11585         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11586         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
11587         return ((uint64_t)ret_conv);
11588 }
11589
11590 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
11591         if ((_res & 1) != 0) return;
11592         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11593         CHECK_ACCESS(_res_ptr);
11594         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
11595         FREE((void*)_res);
11596         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
11597 }
11598
11599 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
11600         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
11601         _res_constr.datalen = *((uint32_t*)_res);
11602         if (_res_constr.datalen > 0)
11603                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
11604         else
11605                 _res_constr.data = NULL;
11606         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11607         for (size_t o = 0; o < _res_constr.datalen; o++) {
11608                 uint32_t _res_conv_40 = _res_vals[o];
11609                 void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
11610                 CHECK_ACCESS(_res_conv_40_ptr);
11611                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
11612                 FREE((void*)_res_conv_40);
11613                 _res_constr.data[o] = _res_conv_40_conv;
11614         }
11615         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
11616 }
11617
11618 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
11619         LDKCVec_EventZ _res_constr;
11620         _res_constr.datalen = *((uint32_t*)_res);
11621         if (_res_constr.datalen > 0)
11622                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
11623         else
11624                 _res_constr.data = NULL;
11625         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11626         for (size_t h = 0; h < _res_constr.datalen; h++) {
11627                 uint32_t _res_conv_7 = _res_vals[h];
11628                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
11629                 CHECK_ACCESS(_res_conv_7_ptr);
11630                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
11631                 FREE((void*)_res_conv_7);
11632                 _res_constr.data[h] = _res_conv_7_conv;
11633         }
11634         CVec_EventZ_free(_res_constr);
11635 }
11636
11637 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
11638         LDKCVec_TransactionZ _res_constr;
11639         _res_constr.datalen = *((uint32_t*)_res);
11640         if (_res_constr.datalen > 0)
11641                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
11642         else
11643                 _res_constr.data = NULL;
11644         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
11645         for (size_t m = 0; m < _res_constr.datalen; m++) {
11646                 int8_tArray _res_conv_12 = _res_vals[m];
11647                 LDKTransaction _res_conv_12_ref;
11648                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
11649                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
11650                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
11651                 _res_conv_12_ref.data_is_owned = true;
11652                 _res_constr.data[m] = _res_conv_12_ref;
11653         }
11654         CVec_TransactionZ_free(_res_constr);
11655 }
11656
11657 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
11658         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
11659         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11660         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
11661         return ((uint64_t)ret_conv);
11662 }
11663
11664 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
11665         void* b_ptr = (void*)(((uint64_t)b) & ~1);
11666         CHECK_ACCESS(b_ptr);
11667         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
11668         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
11669         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11670         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
11671         return ((uint64_t)ret_conv);
11672 }
11673
11674 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
11675         if ((_res & 1) != 0) return;
11676         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11677         CHECK_ACCESS(_res_ptr);
11678         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
11679         FREE((void*)_res);
11680         C2Tuple_u32TxOutZ_free(_res_conv);
11681 }
11682
11683 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
11684         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
11685         _res_constr.datalen = *((uint32_t*)_res);
11686         if (_res_constr.datalen > 0)
11687                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11688         else
11689                 _res_constr.data = NULL;
11690         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11691         for (size_t u = 0; u < _res_constr.datalen; u++) {
11692                 uint32_t _res_conv_20 = _res_vals[u];
11693                 void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
11694                 CHECK_ACCESS(_res_conv_20_ptr);
11695                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
11696                 FREE((void*)_res_conv_20);
11697                 _res_constr.data[u] = _res_conv_20_conv;
11698         }
11699         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
11700 }
11701
11702 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
11703         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
11704         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11705         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
11706         return ((uint64_t)ret_conv);
11707 }
11708
11709 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
11710         LDKThirtyTwoBytes a_ref;
11711         CHECK(*((uint32_t*)a) == 32);
11712         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
11713         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
11714         b_constr.datalen = *((uint32_t*)b);
11715         if (b_constr.datalen > 0)
11716                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11717         else
11718                 b_constr.data = NULL;
11719         uint32_t* b_vals = (uint32_t*)(b + 4);
11720         for (size_t u = 0; u < b_constr.datalen; u++) {
11721                 uint32_t b_conv_20 = b_vals[u];
11722                 void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
11723                 CHECK_ACCESS(b_conv_20_ptr);
11724                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
11725                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
11726                 b_constr.data[u] = b_conv_20_conv;
11727         }
11728         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11729         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
11730         return ((uint64_t)ret_conv);
11731 }
11732
11733 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
11734         if ((_res & 1) != 0) return;
11735         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11736         CHECK_ACCESS(_res_ptr);
11737         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
11738         FREE((void*)_res);
11739         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
11740 }
11741
11742 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
11743         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
11744         _res_constr.datalen = *((uint32_t*)_res);
11745         if (_res_constr.datalen > 0)
11746                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
11747         else
11748                 _res_constr.data = NULL;
11749         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11750         for (size_t n = 0; n < _res_constr.datalen; n++) {
11751                 uint32_t _res_conv_39 = _res_vals[n];
11752                 void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
11753                 CHECK_ACCESS(_res_conv_39_ptr);
11754                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
11755                 FREE((void*)_res_conv_39);
11756                 _res_constr.data[n] = _res_conv_39_conv;
11757         }
11758         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
11759 }
11760
11761 void  __attribute__((visibility("default"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
11762         LDKCVec_BalanceZ _res_constr;
11763         _res_constr.datalen = *((uint32_t*)_res);
11764         if (_res_constr.datalen > 0)
11765                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
11766         else
11767                 _res_constr.data = NULL;
11768         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11769         for (size_t j = 0; j < _res_constr.datalen; j++) {
11770                 uint32_t _res_conv_9 = _res_vals[j];
11771                 void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
11772                 CHECK_ACCESS(_res_conv_9_ptr);
11773                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
11774                 FREE((void*)_res_conv_9);
11775                 _res_constr.data[j] = _res_conv_9_conv;
11776         }
11777         CVec_BalanceZ_free(_res_constr);
11778 }
11779
11780 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
11781         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11782         CHECK_ACCESS(o_ptr);
11783         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
11784         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
11785         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11786         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
11787         return (uint64_t)ret_conv;
11788 }
11789
11790 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
11791         LDKDecodeError e_conv;
11792         e_conv.inner = (void*)(e & (~1));
11793         e_conv.is_owned = (e & 1) || (e == 0);
11794         e_conv = DecodeError_clone(&e_conv);
11795         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11796         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
11797         return (uint64_t)ret_conv;
11798 }
11799
11800 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
11801         if ((_res & 1) != 0) return;
11802         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11803         CHECK_ACCESS(_res_ptr);
11804         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
11805         FREE((void*)_res);
11806         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
11807 }
11808
11809 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
11810         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
11811         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11812         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
11813         return (uint64_t)ret_conv;
11814 }
11815
11816 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
11817         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11818         *ret_conv = CResult_NoneLightningErrorZ_ok();
11819         return (uint64_t)ret_conv;
11820 }
11821
11822 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
11823         LDKLightningError e_conv;
11824         e_conv.inner = (void*)(e & (~1));
11825         e_conv.is_owned = (e & 1) || (e == 0);
11826         e_conv = LightningError_clone(&e_conv);
11827         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11828         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11829         return (uint64_t)ret_conv;
11830 }
11831
11832 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
11833         if ((_res & 1) != 0) return;
11834         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11835         CHECK_ACCESS(_res_ptr);
11836         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
11837         FREE((void*)_res);
11838         CResult_NoneLightningErrorZ_free(_res_conv);
11839 }
11840
11841 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
11842         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11843         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11844         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11845         return (uint64_t)ret_conv;
11846 }
11847
11848 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
11849         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
11850         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
11851         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
11852         return ((uint64_t)ret_conv);
11853 }
11854
11855 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
11856         LDKPublicKey a_ref;
11857         CHECK(*((uint32_t*)a) == 33);
11858         memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33);
11859         void* b_ptr = (void*)(((uint64_t)b) & ~1);
11860         CHECK_ACCESS(b_ptr);
11861         LDKType b_conv = *(LDKType*)(b_ptr);
11862         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
11863         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
11864         return ((uint64_t)ret_conv);
11865 }
11866
11867 void  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
11868         if ((_res & 1) != 0) return;
11869         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11870         CHECK_ACCESS(_res_ptr);
11871         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
11872         FREE((void*)_res);
11873         C2Tuple_PublicKeyTypeZ_free(_res_conv);
11874 }
11875
11876 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
11877         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
11878         _res_constr.datalen = *((uint32_t*)_res);
11879         if (_res_constr.datalen > 0)
11880                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
11881         else
11882                 _res_constr.data = NULL;
11883         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11884         for (size_t z = 0; z < _res_constr.datalen; z++) {
11885                 uint32_t _res_conv_25 = _res_vals[z];
11886                 void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
11887                 CHECK_ACCESS(_res_conv_25_ptr);
11888                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
11889                 FREE((void*)_res_conv_25);
11890                 _res_constr.data[z] = _res_conv_25_conv;
11891         }
11892         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
11893 }
11894
11895 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
11896         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11897         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11898         return (uint64_t)ret_conv;
11899 }
11900
11901 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
11902         LDKLightningError e_conv;
11903         e_conv.inner = (void*)(e & (~1));
11904         e_conv.is_owned = (e & 1) || (e == 0);
11905         e_conv = LightningError_clone(&e_conv);
11906         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11907         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11908         return (uint64_t)ret_conv;
11909 }
11910
11911 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
11912         if ((_res & 1) != 0) return;
11913         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11914         CHECK_ACCESS(_res_ptr);
11915         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
11916         FREE((void*)_res);
11917         CResult_boolLightningErrorZ_free(_res_conv);
11918 }
11919
11920 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
11921         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11922         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11923         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11924         return (uint64_t)ret_conv;
11925 }
11926
11927 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
11928         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11929         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11930         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11931         return ((uint64_t)ret_conv);
11932 }
11933
11934 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
11935         LDKChannelAnnouncement a_conv;
11936         a_conv.inner = (void*)(a & (~1));
11937         a_conv.is_owned = (a & 1) || (a == 0);
11938         a_conv = ChannelAnnouncement_clone(&a_conv);
11939         LDKChannelUpdate b_conv;
11940         b_conv.inner = (void*)(b & (~1));
11941         b_conv.is_owned = (b & 1) || (b == 0);
11942         b_conv = ChannelUpdate_clone(&b_conv);
11943         LDKChannelUpdate c_conv;
11944         c_conv.inner = (void*)(c & (~1));
11945         c_conv.is_owned = (c & 1) || (c == 0);
11946         c_conv = ChannelUpdate_clone(&c_conv);
11947         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11948         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11949         return ((uint64_t)ret_conv);
11950 }
11951
11952 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
11953         if ((_res & 1) != 0) return;
11954         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11955         CHECK_ACCESS(_res_ptr);
11956         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
11957         FREE((void*)_res);
11958         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11959 }
11960
11961 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
11962         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11963         _res_constr.datalen = *((uint32_t*)_res);
11964         if (_res_constr.datalen > 0)
11965                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11966         else
11967                 _res_constr.data = NULL;
11968         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11969         for (size_t h = 0; h < _res_constr.datalen; h++) {
11970                 uint32_t _res_conv_59 = _res_vals[h];
11971                 void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
11972                 CHECK_ACCESS(_res_conv_59_ptr);
11973                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
11974                 FREE((void*)_res_conv_59);
11975                 _res_constr.data[h] = _res_conv_59_conv;
11976         }
11977         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11978 }
11979
11980 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
11981         LDKCVec_NodeAnnouncementZ _res_constr;
11982         _res_constr.datalen = *((uint32_t*)_res);
11983         if (_res_constr.datalen > 0)
11984                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11985         else
11986                 _res_constr.data = NULL;
11987         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11988         for (size_t s = 0; s < _res_constr.datalen; s++) {
11989                 uint32_t _res_conv_18 = _res_vals[s];
11990                 LDKNodeAnnouncement _res_conv_18_conv;
11991                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11992                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11993                 _res_constr.data[s] = _res_conv_18_conv;
11994         }
11995         CVec_NodeAnnouncementZ_free(_res_constr);
11996 }
11997
11998 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
11999         LDKCVec_PublicKeyZ _res_constr;
12000         _res_constr.datalen = *((uint32_t*)_res);
12001         if (_res_constr.datalen > 0)
12002                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
12003         else
12004                 _res_constr.data = NULL;
12005         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
12006         for (size_t m = 0; m < _res_constr.datalen; m++) {
12007                 int8_tArray _res_conv_12 = _res_vals[m];
12008                 LDKPublicKey _res_conv_12_ref;
12009                 CHECK(*((uint32_t*)_res_conv_12) == 33);
12010                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
12011                 _res_constr.data[m] = _res_conv_12_ref;
12012         }
12013         CVec_PublicKeyZ_free(_res_constr);
12014 }
12015
12016 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
12017         LDKCVec_u8Z o_ref;
12018         o_ref.datalen = *((uint32_t*)o);
12019         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
12020         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
12021         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
12022         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
12023         return (uint64_t)ret_conv;
12024 }
12025
12026 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
12027         LDKPeerHandleError e_conv;
12028         e_conv.inner = (void*)(e & (~1));
12029         e_conv.is_owned = (e & 1) || (e == 0);
12030         e_conv = PeerHandleError_clone(&e_conv);
12031         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
12032         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
12033         return (uint64_t)ret_conv;
12034 }
12035
12036 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
12037         if ((_res & 1) != 0) return;
12038         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12039         CHECK_ACCESS(_res_ptr);
12040         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
12041         FREE((void*)_res);
12042         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
12043 }
12044
12045 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
12046         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
12047         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
12048         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
12049         return (uint64_t)ret_conv;
12050 }
12051
12052 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
12053         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12054         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
12055         return (uint64_t)ret_conv;
12056 }
12057
12058 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
12059         LDKPeerHandleError e_conv;
12060         e_conv.inner = (void*)(e & (~1));
12061         e_conv.is_owned = (e & 1) || (e == 0);
12062         e_conv = PeerHandleError_clone(&e_conv);
12063         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12064         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
12065         return (uint64_t)ret_conv;
12066 }
12067
12068 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
12069         if ((_res & 1) != 0) return;
12070         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12071         CHECK_ACCESS(_res_ptr);
12072         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
12073         FREE((void*)_res);
12074         CResult_NonePeerHandleErrorZ_free(_res_conv);
12075 }
12076
12077 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
12078         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
12079         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12080         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
12081         return (uint64_t)ret_conv;
12082 }
12083
12084 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
12085         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
12086         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
12087         return (uint64_t)ret_conv;
12088 }
12089
12090 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
12091         LDKPeerHandleError e_conv;
12092         e_conv.inner = (void*)(e & (~1));
12093         e_conv.is_owned = (e & 1) || (e == 0);
12094         e_conv = PeerHandleError_clone(&e_conv);
12095         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
12096         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
12097         return (uint64_t)ret_conv;
12098 }
12099
12100 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
12101         if ((_res & 1) != 0) return;
12102         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12103         CHECK_ACCESS(_res_ptr);
12104         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
12105         FREE((void*)_res);
12106         CResult_boolPeerHandleErrorZ_free(_res_conv);
12107 }
12108
12109 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
12110         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
12111         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
12112         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
12113         return (uint64_t)ret_conv;
12114 }
12115
12116 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
12117         LDKNodeId o_conv;
12118         o_conv.inner = (void*)(o & (~1));
12119         o_conv.is_owned = (o & 1) || (o == 0);
12120         o_conv = NodeId_clone(&o_conv);
12121         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12122         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
12123         return (uint64_t)ret_conv;
12124 }
12125
12126 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
12127         LDKDecodeError e_conv;
12128         e_conv.inner = (void*)(e & (~1));
12129         e_conv.is_owned = (e & 1) || (e == 0);
12130         e_conv = DecodeError_clone(&e_conv);
12131         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12132         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
12133         return (uint64_t)ret_conv;
12134 }
12135
12136 void  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
12137         if ((_res & 1) != 0) return;
12138         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12139         CHECK_ACCESS(_res_ptr);
12140         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
12141         FREE((void*)_res);
12142         CResult_NodeIdDecodeErrorZ_free(_res_conv);
12143 }
12144
12145 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
12146         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
12147         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12148         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
12149         return (uint64_t)ret_conv;
12150 }
12151
12152 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_some(uint32_t o) {
12153         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12154         CHECK_ACCESS(o_ptr);
12155         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
12156         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
12157         *ret_copy = COption_AccessZ_some(o_conv);
12158         uint64_t ret_ref = (uint64_t)ret_copy;
12159         return ret_ref;
12160 }
12161
12162 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_none() {
12163         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
12164         *ret_copy = COption_AccessZ_none();
12165         uint64_t ret_ref = (uint64_t)ret_copy;
12166         return ret_ref;
12167 }
12168
12169 void  __attribute__((visibility("default"))) TS_COption_AccessZ_free(uint32_t _res) {
12170         if ((_res & 1) != 0) return;
12171         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12172         CHECK_ACCESS(_res_ptr);
12173         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
12174         FREE((void*)_res);
12175         COption_AccessZ_free(_res_conv);
12176 }
12177
12178 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
12179         LDKDirectionalChannelInfo o_conv;
12180         o_conv.inner = (void*)(o & (~1));
12181         o_conv.is_owned = (o & 1) || (o == 0);
12182         o_conv = DirectionalChannelInfo_clone(&o_conv);
12183         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12184         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
12185         return (uint64_t)ret_conv;
12186 }
12187
12188 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
12189         LDKDecodeError e_conv;
12190         e_conv.inner = (void*)(e & (~1));
12191         e_conv.is_owned = (e & 1) || (e == 0);
12192         e_conv = DecodeError_clone(&e_conv);
12193         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12194         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
12195         return (uint64_t)ret_conv;
12196 }
12197
12198 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
12199         if ((_res & 1) != 0) return;
12200         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12201         CHECK_ACCESS(_res_ptr);
12202         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
12203         FREE((void*)_res);
12204         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
12205 }
12206
12207 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
12208         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
12209         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12210         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
12211         return (uint64_t)ret_conv;
12212 }
12213
12214 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
12215         LDKChannelInfo o_conv;
12216         o_conv.inner = (void*)(o & (~1));
12217         o_conv.is_owned = (o & 1) || (o == 0);
12218         o_conv = ChannelInfo_clone(&o_conv);
12219         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12220         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
12221         return (uint64_t)ret_conv;
12222 }
12223
12224 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
12225         LDKDecodeError e_conv;
12226         e_conv.inner = (void*)(e & (~1));
12227         e_conv.is_owned = (e & 1) || (e == 0);
12228         e_conv = DecodeError_clone(&e_conv);
12229         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12230         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
12231         return (uint64_t)ret_conv;
12232 }
12233
12234 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
12235         if ((_res & 1) != 0) return;
12236         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12237         CHECK_ACCESS(_res_ptr);
12238         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
12239         FREE((void*)_res);
12240         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
12241 }
12242
12243 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
12244         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
12245         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12246         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
12247         return (uint64_t)ret_conv;
12248 }
12249
12250 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
12251         LDKRoutingFees o_conv;
12252         o_conv.inner = (void*)(o & (~1));
12253         o_conv.is_owned = (o & 1) || (o == 0);
12254         o_conv = RoutingFees_clone(&o_conv);
12255         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12256         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
12257         return (uint64_t)ret_conv;
12258 }
12259
12260 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
12261         LDKDecodeError e_conv;
12262         e_conv.inner = (void*)(e & (~1));
12263         e_conv.is_owned = (e & 1) || (e == 0);
12264         e_conv = DecodeError_clone(&e_conv);
12265         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12266         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
12267         return (uint64_t)ret_conv;
12268 }
12269
12270 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
12271         if ((_res & 1) != 0) return;
12272         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12273         CHECK_ACCESS(_res_ptr);
12274         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
12275         FREE((void*)_res);
12276         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
12277 }
12278
12279 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
12280         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
12281         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12282         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
12283         return (uint64_t)ret_conv;
12284 }
12285
12286 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
12287         LDKNodeAnnouncementInfo o_conv;
12288         o_conv.inner = (void*)(o & (~1));
12289         o_conv.is_owned = (o & 1) || (o == 0);
12290         o_conv = NodeAnnouncementInfo_clone(&o_conv);
12291         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12292         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
12293         return (uint64_t)ret_conv;
12294 }
12295
12296 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
12297         LDKDecodeError e_conv;
12298         e_conv.inner = (void*)(e & (~1));
12299         e_conv.is_owned = (e & 1) || (e == 0);
12300         e_conv = DecodeError_clone(&e_conv);
12301         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12302         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
12303         return (uint64_t)ret_conv;
12304 }
12305
12306 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
12307         if ((_res & 1) != 0) return;
12308         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12309         CHECK_ACCESS(_res_ptr);
12310         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
12311         FREE((void*)_res);
12312         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
12313 }
12314
12315 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
12316         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
12317         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12318         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
12319         return (uint64_t)ret_conv;
12320 }
12321
12322 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
12323         LDKCVec_u64Z _res_constr;
12324         _res_constr.datalen = *((uint32_t*)_res);
12325         if (_res_constr.datalen > 0)
12326                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
12327         else
12328                 _res_constr.data = NULL;
12329         int64_t* _res_vals = (int64_t*)(_res + 4);
12330         for (size_t i = 0; i < _res_constr.datalen; i++) {
12331                 int64_t _res_conv_8 = _res_vals[i];
12332                 _res_constr.data[i] = _res_conv_8;
12333         }
12334         CVec_u64Z_free(_res_constr);
12335 }
12336
12337 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
12338         LDKNodeInfo o_conv;
12339         o_conv.inner = (void*)(o & (~1));
12340         o_conv.is_owned = (o & 1) || (o == 0);
12341         o_conv = NodeInfo_clone(&o_conv);
12342         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12343         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
12344         return (uint64_t)ret_conv;
12345 }
12346
12347 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
12348         LDKDecodeError e_conv;
12349         e_conv.inner = (void*)(e & (~1));
12350         e_conv.is_owned = (e & 1) || (e == 0);
12351         e_conv = DecodeError_clone(&e_conv);
12352         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12353         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
12354         return (uint64_t)ret_conv;
12355 }
12356
12357 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
12358         if ((_res & 1) != 0) return;
12359         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12360         CHECK_ACCESS(_res_ptr);
12361         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
12362         FREE((void*)_res);
12363         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
12364 }
12365
12366 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
12367         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
12368         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12369         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
12370         return (uint64_t)ret_conv;
12371 }
12372
12373 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
12374         LDKNetworkGraph o_conv;
12375         o_conv.inner = (void*)(o & (~1));
12376         o_conv.is_owned = (o & 1) || (o == 0);
12377         o_conv = NetworkGraph_clone(&o_conv);
12378         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12379         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
12380         return (uint64_t)ret_conv;
12381 }
12382
12383 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
12384         LDKDecodeError e_conv;
12385         e_conv.inner = (void*)(e & (~1));
12386         e_conv.is_owned = (e & 1) || (e == 0);
12387         e_conv = DecodeError_clone(&e_conv);
12388         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12389         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
12390         return (uint64_t)ret_conv;
12391 }
12392
12393 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
12394         if ((_res & 1) != 0) return;
12395         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12396         CHECK_ACCESS(_res_ptr);
12397         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
12398         FREE((void*)_res);
12399         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
12400 }
12401
12402 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
12403         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
12404         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12405         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
12406         return (uint64_t)ret_conv;
12407 }
12408
12409 uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
12410         LDKCVec_NetAddressZ o_constr;
12411         o_constr.datalen = *((uint32_t*)o);
12412         if (o_constr.datalen > 0)
12413                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12414         else
12415                 o_constr.data = NULL;
12416         uint32_t* o_vals = (uint32_t*)(o + 4);
12417         for (size_t m = 0; m < o_constr.datalen; m++) {
12418                 uint32_t o_conv_12 = o_vals[m];
12419                 void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
12420                 CHECK_ACCESS(o_conv_12_ptr);
12421                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
12422                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
12423                 o_constr.data[m] = o_conv_12_conv;
12424         }
12425         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12426         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
12427         uint64_t ret_ref = (uint64_t)ret_copy;
12428         return ret_ref;
12429 }
12430
12431 uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_none() {
12432         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12433         *ret_copy = COption_CVec_NetAddressZZ_none();
12434         uint64_t ret_ref = (uint64_t)ret_copy;
12435         return ret_ref;
12436 }
12437
12438 void  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
12439         if ((_res & 1) != 0) return;
12440         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12441         CHECK_ACCESS(_res_ptr);
12442         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
12443         FREE((void*)_res);
12444         COption_CVec_NetAddressZZ_free(_res_conv);
12445 }
12446
12447 uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
12448         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
12449         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12450         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
12451         uint64_t ret_ref = (uint64_t)ret_copy;
12452         return ret_ref;
12453 }
12454
12455 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
12456         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12457         CHECK_ACCESS(o_ptr);
12458         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
12459         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
12460         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12461         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
12462         return (uint64_t)ret_conv;
12463 }
12464
12465 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
12466         LDKDecodeError e_conv;
12467         e_conv.inner = (void*)(e & (~1));
12468         e_conv.is_owned = (e & 1) || (e == 0);
12469         e_conv = DecodeError_clone(&e_conv);
12470         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12471         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
12472         return (uint64_t)ret_conv;
12473 }
12474
12475 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
12476         if ((_res & 1) != 0) return;
12477         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12478         CHECK_ACCESS(_res_ptr);
12479         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
12480         FREE((void*)_res);
12481         CResult_NetAddressDecodeErrorZ_free(_res_conv);
12482 }
12483
12484 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
12485         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
12486         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12487         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
12488         return (uint64_t)ret_conv;
12489 }
12490
12491 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
12492         LDKCVec_UpdateAddHTLCZ _res_constr;
12493         _res_constr.datalen = *((uint32_t*)_res);
12494         if (_res_constr.datalen > 0)
12495                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
12496         else
12497                 _res_constr.data = NULL;
12498         uint32_t* _res_vals = (uint32_t*)(_res + 4);
12499         for (size_t p = 0; p < _res_constr.datalen; p++) {
12500                 uint32_t _res_conv_15 = _res_vals[p];
12501                 LDKUpdateAddHTLC _res_conv_15_conv;
12502                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
12503                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
12504                 _res_constr.data[p] = _res_conv_15_conv;
12505         }
12506         CVec_UpdateAddHTLCZ_free(_res_constr);
12507 }
12508
12509 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
12510         LDKCVec_UpdateFulfillHTLCZ _res_constr;
12511         _res_constr.datalen = *((uint32_t*)_res);
12512         if (_res_constr.datalen > 0)
12513                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
12514         else
12515                 _res_constr.data = NULL;
12516         uint32_t* _res_vals = (uint32_t*)(_res + 4);
12517         for (size_t t = 0; t < _res_constr.datalen; t++) {
12518                 uint32_t _res_conv_19 = _res_vals[t];
12519                 LDKUpdateFulfillHTLC _res_conv_19_conv;
12520                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
12521                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
12522                 _res_constr.data[t] = _res_conv_19_conv;
12523         }
12524         CVec_UpdateFulfillHTLCZ_free(_res_constr);
12525 }
12526
12527 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
12528         LDKCVec_UpdateFailHTLCZ _res_constr;
12529         _res_constr.datalen = *((uint32_t*)_res);
12530         if (_res_constr.datalen > 0)
12531                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
12532         else
12533                 _res_constr.data = NULL;
12534         uint32_t* _res_vals = (uint32_t*)(_res + 4);
12535         for (size_t q = 0; q < _res_constr.datalen; q++) {
12536                 uint32_t _res_conv_16 = _res_vals[q];
12537                 LDKUpdateFailHTLC _res_conv_16_conv;
12538                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12539                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12540                 _res_constr.data[q] = _res_conv_16_conv;
12541         }
12542         CVec_UpdateFailHTLCZ_free(_res_constr);
12543 }
12544
12545 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
12546         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
12547         _res_constr.datalen = *((uint32_t*)_res);
12548         if (_res_constr.datalen > 0)
12549                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
12550         else
12551                 _res_constr.data = NULL;
12552         uint32_t* _res_vals = (uint32_t*)(_res + 4);
12553         for (size_t z = 0; z < _res_constr.datalen; z++) {
12554                 uint32_t _res_conv_25 = _res_vals[z];
12555                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
12556                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
12557                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
12558                 _res_constr.data[z] = _res_conv_25_conv;
12559         }
12560         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
12561 }
12562
12563 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
12564         LDKAcceptChannel o_conv;
12565         o_conv.inner = (void*)(o & (~1));
12566         o_conv.is_owned = (o & 1) || (o == 0);
12567         o_conv = AcceptChannel_clone(&o_conv);
12568         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12569         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
12570         return (uint64_t)ret_conv;
12571 }
12572
12573 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
12574         LDKDecodeError e_conv;
12575         e_conv.inner = (void*)(e & (~1));
12576         e_conv.is_owned = (e & 1) || (e == 0);
12577         e_conv = DecodeError_clone(&e_conv);
12578         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12579         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
12580         return (uint64_t)ret_conv;
12581 }
12582
12583 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
12584         if ((_res & 1) != 0) return;
12585         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12586         CHECK_ACCESS(_res_ptr);
12587         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
12588         FREE((void*)_res);
12589         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
12590 }
12591
12592 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
12593         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
12594         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12595         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
12596         return (uint64_t)ret_conv;
12597 }
12598
12599 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
12600         LDKAnnouncementSignatures o_conv;
12601         o_conv.inner = (void*)(o & (~1));
12602         o_conv.is_owned = (o & 1) || (o == 0);
12603         o_conv = AnnouncementSignatures_clone(&o_conv);
12604         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12605         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
12606         return (uint64_t)ret_conv;
12607 }
12608
12609 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
12610         LDKDecodeError e_conv;
12611         e_conv.inner = (void*)(e & (~1));
12612         e_conv.is_owned = (e & 1) || (e == 0);
12613         e_conv = DecodeError_clone(&e_conv);
12614         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12615         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
12616         return (uint64_t)ret_conv;
12617 }
12618
12619 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
12620         if ((_res & 1) != 0) return;
12621         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12622         CHECK_ACCESS(_res_ptr);
12623         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
12624         FREE((void*)_res);
12625         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
12626 }
12627
12628 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
12629         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
12630         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12631         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
12632         return (uint64_t)ret_conv;
12633 }
12634
12635 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
12636         LDKChannelReestablish o_conv;
12637         o_conv.inner = (void*)(o & (~1));
12638         o_conv.is_owned = (o & 1) || (o == 0);
12639         o_conv = ChannelReestablish_clone(&o_conv);
12640         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12641         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
12642         return (uint64_t)ret_conv;
12643 }
12644
12645 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
12646         LDKDecodeError e_conv;
12647         e_conv.inner = (void*)(e & (~1));
12648         e_conv.is_owned = (e & 1) || (e == 0);
12649         e_conv = DecodeError_clone(&e_conv);
12650         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12651         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
12652         return (uint64_t)ret_conv;
12653 }
12654
12655 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
12656         if ((_res & 1) != 0) return;
12657         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12658         CHECK_ACCESS(_res_ptr);
12659         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
12660         FREE((void*)_res);
12661         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
12662 }
12663
12664 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
12665         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
12666         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12667         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
12668         return (uint64_t)ret_conv;
12669 }
12670
12671 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
12672         LDKClosingSigned o_conv;
12673         o_conv.inner = (void*)(o & (~1));
12674         o_conv.is_owned = (o & 1) || (o == 0);
12675         o_conv = ClosingSigned_clone(&o_conv);
12676         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12677         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
12678         return (uint64_t)ret_conv;
12679 }
12680
12681 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
12682         LDKDecodeError e_conv;
12683         e_conv.inner = (void*)(e & (~1));
12684         e_conv.is_owned = (e & 1) || (e == 0);
12685         e_conv = DecodeError_clone(&e_conv);
12686         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12687         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
12688         return (uint64_t)ret_conv;
12689 }
12690
12691 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
12692         if ((_res & 1) != 0) return;
12693         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12694         CHECK_ACCESS(_res_ptr);
12695         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
12696         FREE((void*)_res);
12697         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
12698 }
12699
12700 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
12701         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
12702         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12703         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
12704         return (uint64_t)ret_conv;
12705 }
12706
12707 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
12708         LDKClosingSignedFeeRange o_conv;
12709         o_conv.inner = (void*)(o & (~1));
12710         o_conv.is_owned = (o & 1) || (o == 0);
12711         o_conv = ClosingSignedFeeRange_clone(&o_conv);
12712         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
12713         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
12714         return (uint64_t)ret_conv;
12715 }
12716
12717 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
12718         LDKDecodeError e_conv;
12719         e_conv.inner = (void*)(e & (~1));
12720         e_conv.is_owned = (e & 1) || (e == 0);
12721         e_conv = DecodeError_clone(&e_conv);
12722         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
12723         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
12724         return (uint64_t)ret_conv;
12725 }
12726
12727 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
12728         if ((_res & 1) != 0) return;
12729         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12730         CHECK_ACCESS(_res_ptr);
12731         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
12732         FREE((void*)_res);
12733         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
12734 }
12735
12736 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
12737         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
12738         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
12739         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
12740         return (uint64_t)ret_conv;
12741 }
12742
12743 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
12744         LDKCommitmentSigned o_conv;
12745         o_conv.inner = (void*)(o & (~1));
12746         o_conv.is_owned = (o & 1) || (o == 0);
12747         o_conv = CommitmentSigned_clone(&o_conv);
12748         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12749         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
12750         return (uint64_t)ret_conv;
12751 }
12752
12753 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
12754         LDKDecodeError e_conv;
12755         e_conv.inner = (void*)(e & (~1));
12756         e_conv.is_owned = (e & 1) || (e == 0);
12757         e_conv = DecodeError_clone(&e_conv);
12758         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12759         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
12760         return (uint64_t)ret_conv;
12761 }
12762
12763 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
12764         if ((_res & 1) != 0) return;
12765         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12766         CHECK_ACCESS(_res_ptr);
12767         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
12768         FREE((void*)_res);
12769         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
12770 }
12771
12772 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
12773         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
12774         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12775         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
12776         return (uint64_t)ret_conv;
12777 }
12778
12779 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
12780         LDKFundingCreated o_conv;
12781         o_conv.inner = (void*)(o & (~1));
12782         o_conv.is_owned = (o & 1) || (o == 0);
12783         o_conv = FundingCreated_clone(&o_conv);
12784         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12785         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
12786         return (uint64_t)ret_conv;
12787 }
12788
12789 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
12790         LDKDecodeError e_conv;
12791         e_conv.inner = (void*)(e & (~1));
12792         e_conv.is_owned = (e & 1) || (e == 0);
12793         e_conv = DecodeError_clone(&e_conv);
12794         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12795         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
12796         return (uint64_t)ret_conv;
12797 }
12798
12799 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
12800         if ((_res & 1) != 0) return;
12801         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12802         CHECK_ACCESS(_res_ptr);
12803         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
12804         FREE((void*)_res);
12805         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
12806 }
12807
12808 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
12809         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
12810         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12811         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
12812         return (uint64_t)ret_conv;
12813 }
12814
12815 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
12816         LDKFundingSigned o_conv;
12817         o_conv.inner = (void*)(o & (~1));
12818         o_conv.is_owned = (o & 1) || (o == 0);
12819         o_conv = FundingSigned_clone(&o_conv);
12820         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12821         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
12822         return (uint64_t)ret_conv;
12823 }
12824
12825 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
12826         LDKDecodeError e_conv;
12827         e_conv.inner = (void*)(e & (~1));
12828         e_conv.is_owned = (e & 1) || (e == 0);
12829         e_conv = DecodeError_clone(&e_conv);
12830         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12831         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
12832         return (uint64_t)ret_conv;
12833 }
12834
12835 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
12836         if ((_res & 1) != 0) return;
12837         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12838         CHECK_ACCESS(_res_ptr);
12839         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
12840         FREE((void*)_res);
12841         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
12842 }
12843
12844 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
12845         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
12846         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12847         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
12848         return (uint64_t)ret_conv;
12849 }
12850
12851 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
12852         LDKFundingLocked o_conv;
12853         o_conv.inner = (void*)(o & (~1));
12854         o_conv.is_owned = (o & 1) || (o == 0);
12855         o_conv = FundingLocked_clone(&o_conv);
12856         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12857         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
12858         return (uint64_t)ret_conv;
12859 }
12860
12861 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
12862         LDKDecodeError e_conv;
12863         e_conv.inner = (void*)(e & (~1));
12864         e_conv.is_owned = (e & 1) || (e == 0);
12865         e_conv = DecodeError_clone(&e_conv);
12866         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12867         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
12868         return (uint64_t)ret_conv;
12869 }
12870
12871 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
12872         if ((_res & 1) != 0) return;
12873         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12874         CHECK_ACCESS(_res_ptr);
12875         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
12876         FREE((void*)_res);
12877         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
12878 }
12879
12880 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
12881         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
12882         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12883         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
12884         return (uint64_t)ret_conv;
12885 }
12886
12887 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
12888         LDKInit o_conv;
12889         o_conv.inner = (void*)(o & (~1));
12890         o_conv.is_owned = (o & 1) || (o == 0);
12891         o_conv = Init_clone(&o_conv);
12892         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12893         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
12894         return (uint64_t)ret_conv;
12895 }
12896
12897 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
12898         LDKDecodeError e_conv;
12899         e_conv.inner = (void*)(e & (~1));
12900         e_conv.is_owned = (e & 1) || (e == 0);
12901         e_conv = DecodeError_clone(&e_conv);
12902         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12903         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
12904         return (uint64_t)ret_conv;
12905 }
12906
12907 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
12908         if ((_res & 1) != 0) return;
12909         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12910         CHECK_ACCESS(_res_ptr);
12911         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
12912         FREE((void*)_res);
12913         CResult_InitDecodeErrorZ_free(_res_conv);
12914 }
12915
12916 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
12917         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
12918         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12919         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
12920         return (uint64_t)ret_conv;
12921 }
12922
12923 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
12924         LDKOpenChannel o_conv;
12925         o_conv.inner = (void*)(o & (~1));
12926         o_conv.is_owned = (o & 1) || (o == 0);
12927         o_conv = OpenChannel_clone(&o_conv);
12928         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12929         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
12930         return (uint64_t)ret_conv;
12931 }
12932
12933 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
12934         LDKDecodeError e_conv;
12935         e_conv.inner = (void*)(e & (~1));
12936         e_conv.is_owned = (e & 1) || (e == 0);
12937         e_conv = DecodeError_clone(&e_conv);
12938         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12939         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
12940         return (uint64_t)ret_conv;
12941 }
12942
12943 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
12944         if ((_res & 1) != 0) return;
12945         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12946         CHECK_ACCESS(_res_ptr);
12947         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
12948         FREE((void*)_res);
12949         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
12950 }
12951
12952 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
12953         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
12954         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12955         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
12956         return (uint64_t)ret_conv;
12957 }
12958
12959 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
12960         LDKRevokeAndACK o_conv;
12961         o_conv.inner = (void*)(o & (~1));
12962         o_conv.is_owned = (o & 1) || (o == 0);
12963         o_conv = RevokeAndACK_clone(&o_conv);
12964         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12965         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
12966         return (uint64_t)ret_conv;
12967 }
12968
12969 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
12970         LDKDecodeError e_conv;
12971         e_conv.inner = (void*)(e & (~1));
12972         e_conv.is_owned = (e & 1) || (e == 0);
12973         e_conv = DecodeError_clone(&e_conv);
12974         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12975         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
12976         return (uint64_t)ret_conv;
12977 }
12978
12979 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
12980         if ((_res & 1) != 0) return;
12981         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12982         CHECK_ACCESS(_res_ptr);
12983         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
12984         FREE((void*)_res);
12985         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
12986 }
12987
12988 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
12989         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
12990         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12991         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
12992         return (uint64_t)ret_conv;
12993 }
12994
12995 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
12996         LDKShutdown o_conv;
12997         o_conv.inner = (void*)(o & (~1));
12998         o_conv.is_owned = (o & 1) || (o == 0);
12999         o_conv = Shutdown_clone(&o_conv);
13000         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13001         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
13002         return (uint64_t)ret_conv;
13003 }
13004
13005 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
13006         LDKDecodeError e_conv;
13007         e_conv.inner = (void*)(e & (~1));
13008         e_conv.is_owned = (e & 1) || (e == 0);
13009         e_conv = DecodeError_clone(&e_conv);
13010         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13011         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
13012         return (uint64_t)ret_conv;
13013 }
13014
13015 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
13016         if ((_res & 1) != 0) return;
13017         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13018         CHECK_ACCESS(_res_ptr);
13019         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
13020         FREE((void*)_res);
13021         CResult_ShutdownDecodeErrorZ_free(_res_conv);
13022 }
13023
13024 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
13025         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
13026         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13027         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
13028         return (uint64_t)ret_conv;
13029 }
13030
13031 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
13032         LDKUpdateFailHTLC o_conv;
13033         o_conv.inner = (void*)(o & (~1));
13034         o_conv.is_owned = (o & 1) || (o == 0);
13035         o_conv = UpdateFailHTLC_clone(&o_conv);
13036         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13037         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
13038         return (uint64_t)ret_conv;
13039 }
13040
13041 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
13042         LDKDecodeError e_conv;
13043         e_conv.inner = (void*)(e & (~1));
13044         e_conv.is_owned = (e & 1) || (e == 0);
13045         e_conv = DecodeError_clone(&e_conv);
13046         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13047         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
13048         return (uint64_t)ret_conv;
13049 }
13050
13051 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
13052         if ((_res & 1) != 0) return;
13053         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13054         CHECK_ACCESS(_res_ptr);
13055         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
13056         FREE((void*)_res);
13057         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
13058 }
13059
13060 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
13061         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
13062         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13063         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
13064         return (uint64_t)ret_conv;
13065 }
13066
13067 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
13068         LDKUpdateFailMalformedHTLC o_conv;
13069         o_conv.inner = (void*)(o & (~1));
13070         o_conv.is_owned = (o & 1) || (o == 0);
13071         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
13072         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13073         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
13074         return (uint64_t)ret_conv;
13075 }
13076
13077 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
13078         LDKDecodeError e_conv;
13079         e_conv.inner = (void*)(e & (~1));
13080         e_conv.is_owned = (e & 1) || (e == 0);
13081         e_conv = DecodeError_clone(&e_conv);
13082         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13083         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
13084         return (uint64_t)ret_conv;
13085 }
13086
13087 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
13088         if ((_res & 1) != 0) return;
13089         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13090         CHECK_ACCESS(_res_ptr);
13091         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
13092         FREE((void*)_res);
13093         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
13094 }
13095
13096 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
13097         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
13098         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13099         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
13100         return (uint64_t)ret_conv;
13101 }
13102
13103 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
13104         LDKUpdateFee o_conv;
13105         o_conv.inner = (void*)(o & (~1));
13106         o_conv.is_owned = (o & 1) || (o == 0);
13107         o_conv = UpdateFee_clone(&o_conv);
13108         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
13109         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
13110         return (uint64_t)ret_conv;
13111 }
13112
13113 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
13114         LDKDecodeError e_conv;
13115         e_conv.inner = (void*)(e & (~1));
13116         e_conv.is_owned = (e & 1) || (e == 0);
13117         e_conv = DecodeError_clone(&e_conv);
13118         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
13119         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
13120         return (uint64_t)ret_conv;
13121 }
13122
13123 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
13124         if ((_res & 1) != 0) return;
13125         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13126         CHECK_ACCESS(_res_ptr);
13127         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
13128         FREE((void*)_res);
13129         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
13130 }
13131
13132 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
13133         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
13134         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
13135         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
13136         return (uint64_t)ret_conv;
13137 }
13138
13139 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
13140         LDKUpdateFulfillHTLC o_conv;
13141         o_conv.inner = (void*)(o & (~1));
13142         o_conv.is_owned = (o & 1) || (o == 0);
13143         o_conv = UpdateFulfillHTLC_clone(&o_conv);
13144         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
13145         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
13146         return (uint64_t)ret_conv;
13147 }
13148
13149 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
13150         LDKDecodeError e_conv;
13151         e_conv.inner = (void*)(e & (~1));
13152         e_conv.is_owned = (e & 1) || (e == 0);
13153         e_conv = DecodeError_clone(&e_conv);
13154         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
13155         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
13156         return (uint64_t)ret_conv;
13157 }
13158
13159 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
13160         if ((_res & 1) != 0) return;
13161         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13162         CHECK_ACCESS(_res_ptr);
13163         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
13164         FREE((void*)_res);
13165         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
13166 }
13167
13168 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
13169         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
13170         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
13171         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
13172         return (uint64_t)ret_conv;
13173 }
13174
13175 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
13176         LDKUpdateAddHTLC o_conv;
13177         o_conv.inner = (void*)(o & (~1));
13178         o_conv.is_owned = (o & 1) || (o == 0);
13179         o_conv = UpdateAddHTLC_clone(&o_conv);
13180         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
13181         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
13182         return (uint64_t)ret_conv;
13183 }
13184
13185 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
13186         LDKDecodeError e_conv;
13187         e_conv.inner = (void*)(e & (~1));
13188         e_conv.is_owned = (e & 1) || (e == 0);
13189         e_conv = DecodeError_clone(&e_conv);
13190         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
13191         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
13192         return (uint64_t)ret_conv;
13193 }
13194
13195 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
13196         if ((_res & 1) != 0) return;
13197         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13198         CHECK_ACCESS(_res_ptr);
13199         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
13200         FREE((void*)_res);
13201         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
13202 }
13203
13204 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
13205         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
13206         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
13207         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
13208         return (uint64_t)ret_conv;
13209 }
13210
13211 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
13212         LDKPing o_conv;
13213         o_conv.inner = (void*)(o & (~1));
13214         o_conv.is_owned = (o & 1) || (o == 0);
13215         o_conv = Ping_clone(&o_conv);
13216         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
13217         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
13218         return (uint64_t)ret_conv;
13219 }
13220
13221 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
13222         LDKDecodeError e_conv;
13223         e_conv.inner = (void*)(e & (~1));
13224         e_conv.is_owned = (e & 1) || (e == 0);
13225         e_conv = DecodeError_clone(&e_conv);
13226         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
13227         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
13228         return (uint64_t)ret_conv;
13229 }
13230
13231 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
13232         if ((_res & 1) != 0) return;
13233         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13234         CHECK_ACCESS(_res_ptr);
13235         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
13236         FREE((void*)_res);
13237         CResult_PingDecodeErrorZ_free(_res_conv);
13238 }
13239
13240 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
13241         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
13242         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
13243         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
13244         return (uint64_t)ret_conv;
13245 }
13246
13247 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
13248         LDKPong o_conv;
13249         o_conv.inner = (void*)(o & (~1));
13250         o_conv.is_owned = (o & 1) || (o == 0);
13251         o_conv = Pong_clone(&o_conv);
13252         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
13253         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
13254         return (uint64_t)ret_conv;
13255 }
13256
13257 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
13258         LDKDecodeError e_conv;
13259         e_conv.inner = (void*)(e & (~1));
13260         e_conv.is_owned = (e & 1) || (e == 0);
13261         e_conv = DecodeError_clone(&e_conv);
13262         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
13263         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
13264         return (uint64_t)ret_conv;
13265 }
13266
13267 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
13268         if ((_res & 1) != 0) return;
13269         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13270         CHECK_ACCESS(_res_ptr);
13271         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
13272         FREE((void*)_res);
13273         CResult_PongDecodeErrorZ_free(_res_conv);
13274 }
13275
13276 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
13277         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
13278         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
13279         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
13280         return (uint64_t)ret_conv;
13281 }
13282
13283 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
13284         LDKUnsignedChannelAnnouncement o_conv;
13285         o_conv.inner = (void*)(o & (~1));
13286         o_conv.is_owned = (o & 1) || (o == 0);
13287         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
13288         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13289         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
13290         return (uint64_t)ret_conv;
13291 }
13292
13293 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
13294         LDKDecodeError e_conv;
13295         e_conv.inner = (void*)(e & (~1));
13296         e_conv.is_owned = (e & 1) || (e == 0);
13297         e_conv = DecodeError_clone(&e_conv);
13298         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13299         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
13300         return (uint64_t)ret_conv;
13301 }
13302
13303 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
13304         if ((_res & 1) != 0) return;
13305         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13306         CHECK_ACCESS(_res_ptr);
13307         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
13308         FREE((void*)_res);
13309         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
13310 }
13311
13312 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
13313         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
13314         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
13315         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
13316         return (uint64_t)ret_conv;
13317 }
13318
13319 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
13320         LDKChannelAnnouncement o_conv;
13321         o_conv.inner = (void*)(o & (~1));
13322         o_conv.is_owned = (o & 1) || (o == 0);
13323         o_conv = ChannelAnnouncement_clone(&o_conv);
13324         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13325         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
13326         return (uint64_t)ret_conv;
13327 }
13328
13329 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
13330         LDKDecodeError e_conv;
13331         e_conv.inner = (void*)(e & (~1));
13332         e_conv.is_owned = (e & 1) || (e == 0);
13333         e_conv = DecodeError_clone(&e_conv);
13334         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13335         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
13336         return (uint64_t)ret_conv;
13337 }
13338
13339 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
13340         if ((_res & 1) != 0) return;
13341         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13342         CHECK_ACCESS(_res_ptr);
13343         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
13344         FREE((void*)_res);
13345         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
13346 }
13347
13348 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
13349         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
13350         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
13351         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
13352         return (uint64_t)ret_conv;
13353 }
13354
13355 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
13356         LDKUnsignedChannelUpdate o_conv;
13357         o_conv.inner = (void*)(o & (~1));
13358         o_conv.is_owned = (o & 1) || (o == 0);
13359         o_conv = UnsignedChannelUpdate_clone(&o_conv);
13360         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13361         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
13362         return (uint64_t)ret_conv;
13363 }
13364
13365 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
13366         LDKDecodeError e_conv;
13367         e_conv.inner = (void*)(e & (~1));
13368         e_conv.is_owned = (e & 1) || (e == 0);
13369         e_conv = DecodeError_clone(&e_conv);
13370         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13371         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
13372         return (uint64_t)ret_conv;
13373 }
13374
13375 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
13376         if ((_res & 1) != 0) return;
13377         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13378         CHECK_ACCESS(_res_ptr);
13379         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
13380         FREE((void*)_res);
13381         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
13382 }
13383
13384 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
13385         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
13386         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
13387         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
13388         return (uint64_t)ret_conv;
13389 }
13390
13391 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
13392         LDKChannelUpdate o_conv;
13393         o_conv.inner = (void*)(o & (~1));
13394         o_conv.is_owned = (o & 1) || (o == 0);
13395         o_conv = ChannelUpdate_clone(&o_conv);
13396         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13397         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
13398         return (uint64_t)ret_conv;
13399 }
13400
13401 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
13402         LDKDecodeError e_conv;
13403         e_conv.inner = (void*)(e & (~1));
13404         e_conv.is_owned = (e & 1) || (e == 0);
13405         e_conv = DecodeError_clone(&e_conv);
13406         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13407         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
13408         return (uint64_t)ret_conv;
13409 }
13410
13411 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
13412         if ((_res & 1) != 0) return;
13413         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13414         CHECK_ACCESS(_res_ptr);
13415         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
13416         FREE((void*)_res);
13417         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
13418 }
13419
13420 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
13421         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
13422         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
13423         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
13424         return (uint64_t)ret_conv;
13425 }
13426
13427 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
13428         LDKErrorMessage o_conv;
13429         o_conv.inner = (void*)(o & (~1));
13430         o_conv.is_owned = (o & 1) || (o == 0);
13431         o_conv = ErrorMessage_clone(&o_conv);
13432         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13433         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
13434         return (uint64_t)ret_conv;
13435 }
13436
13437 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
13438         LDKDecodeError e_conv;
13439         e_conv.inner = (void*)(e & (~1));
13440         e_conv.is_owned = (e & 1) || (e == 0);
13441         e_conv = DecodeError_clone(&e_conv);
13442         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13443         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
13444         return (uint64_t)ret_conv;
13445 }
13446
13447 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
13448         if ((_res & 1) != 0) return;
13449         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13450         CHECK_ACCESS(_res_ptr);
13451         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
13452         FREE((void*)_res);
13453         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
13454 }
13455
13456 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
13457         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
13458         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13459         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
13460         return (uint64_t)ret_conv;
13461 }
13462
13463 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
13464         LDKUnsignedNodeAnnouncement o_conv;
13465         o_conv.inner = (void*)(o & (~1));
13466         o_conv.is_owned = (o & 1) || (o == 0);
13467         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
13468         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13469         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
13470         return (uint64_t)ret_conv;
13471 }
13472
13473 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
13474         LDKDecodeError e_conv;
13475         e_conv.inner = (void*)(e & (~1));
13476         e_conv.is_owned = (e & 1) || (e == 0);
13477         e_conv = DecodeError_clone(&e_conv);
13478         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13479         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
13480         return (uint64_t)ret_conv;
13481 }
13482
13483 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
13484         if ((_res & 1) != 0) return;
13485         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13486         CHECK_ACCESS(_res_ptr);
13487         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
13488         FREE((void*)_res);
13489         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
13490 }
13491
13492 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
13493         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
13494         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13495         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
13496         return (uint64_t)ret_conv;
13497 }
13498
13499 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
13500         LDKNodeAnnouncement o_conv;
13501         o_conv.inner = (void*)(o & (~1));
13502         o_conv.is_owned = (o & 1) || (o == 0);
13503         o_conv = NodeAnnouncement_clone(&o_conv);
13504         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13505         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
13506         return (uint64_t)ret_conv;
13507 }
13508
13509 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
13510         LDKDecodeError e_conv;
13511         e_conv.inner = (void*)(e & (~1));
13512         e_conv.is_owned = (e & 1) || (e == 0);
13513         e_conv = DecodeError_clone(&e_conv);
13514         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13515         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
13516         return (uint64_t)ret_conv;
13517 }
13518
13519 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
13520         if ((_res & 1) != 0) return;
13521         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13522         CHECK_ACCESS(_res_ptr);
13523         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
13524         FREE((void*)_res);
13525         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
13526 }
13527
13528 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
13529         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
13530         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13531         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
13532         return (uint64_t)ret_conv;
13533 }
13534
13535 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
13536         LDKQueryShortChannelIds o_conv;
13537         o_conv.inner = (void*)(o & (~1));
13538         o_conv.is_owned = (o & 1) || (o == 0);
13539         o_conv = QueryShortChannelIds_clone(&o_conv);
13540         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13541         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
13542         return (uint64_t)ret_conv;
13543 }
13544
13545 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
13546         LDKDecodeError e_conv;
13547         e_conv.inner = (void*)(e & (~1));
13548         e_conv.is_owned = (e & 1) || (e == 0);
13549         e_conv = DecodeError_clone(&e_conv);
13550         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13551         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
13552         return (uint64_t)ret_conv;
13553 }
13554
13555 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
13556         if ((_res & 1) != 0) return;
13557         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13558         CHECK_ACCESS(_res_ptr);
13559         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
13560         FREE((void*)_res);
13561         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
13562 }
13563
13564 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
13565         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
13566         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13567         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
13568         return (uint64_t)ret_conv;
13569 }
13570
13571 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
13572         LDKReplyShortChannelIdsEnd o_conv;
13573         o_conv.inner = (void*)(o & (~1));
13574         o_conv.is_owned = (o & 1) || (o == 0);
13575         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
13576         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13577         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
13578         return (uint64_t)ret_conv;
13579 }
13580
13581 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
13582         LDKDecodeError e_conv;
13583         e_conv.inner = (void*)(e & (~1));
13584         e_conv.is_owned = (e & 1) || (e == 0);
13585         e_conv = DecodeError_clone(&e_conv);
13586         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13587         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
13588         return (uint64_t)ret_conv;
13589 }
13590
13591 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
13592         if ((_res & 1) != 0) return;
13593         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13594         CHECK_ACCESS(_res_ptr);
13595         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
13596         FREE((void*)_res);
13597         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
13598 }
13599
13600 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
13601         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
13602         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13603         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
13604         return (uint64_t)ret_conv;
13605 }
13606
13607 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
13608         LDKQueryChannelRange o_conv;
13609         o_conv.inner = (void*)(o & (~1));
13610         o_conv.is_owned = (o & 1) || (o == 0);
13611         o_conv = QueryChannelRange_clone(&o_conv);
13612         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13613         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
13614         return (uint64_t)ret_conv;
13615 }
13616
13617 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
13618         LDKDecodeError e_conv;
13619         e_conv.inner = (void*)(e & (~1));
13620         e_conv.is_owned = (e & 1) || (e == 0);
13621         e_conv = DecodeError_clone(&e_conv);
13622         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13623         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
13624         return (uint64_t)ret_conv;
13625 }
13626
13627 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
13628         if ((_res & 1) != 0) return;
13629         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13630         CHECK_ACCESS(_res_ptr);
13631         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
13632         FREE((void*)_res);
13633         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
13634 }
13635
13636 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
13637         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
13638         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13639         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
13640         return (uint64_t)ret_conv;
13641 }
13642
13643 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
13644         LDKReplyChannelRange o_conv;
13645         o_conv.inner = (void*)(o & (~1));
13646         o_conv.is_owned = (o & 1) || (o == 0);
13647         o_conv = ReplyChannelRange_clone(&o_conv);
13648         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13649         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
13650         return (uint64_t)ret_conv;
13651 }
13652
13653 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
13654         LDKDecodeError e_conv;
13655         e_conv.inner = (void*)(e & (~1));
13656         e_conv.is_owned = (e & 1) || (e == 0);
13657         e_conv = DecodeError_clone(&e_conv);
13658         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13659         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
13660         return (uint64_t)ret_conv;
13661 }
13662
13663 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
13664         if ((_res & 1) != 0) return;
13665         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13666         CHECK_ACCESS(_res_ptr);
13667         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
13668         FREE((void*)_res);
13669         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
13670 }
13671
13672 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
13673         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
13674         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13675         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
13676         return (uint64_t)ret_conv;
13677 }
13678
13679 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
13680         LDKGossipTimestampFilter o_conv;
13681         o_conv.inner = (void*)(o & (~1));
13682         o_conv.is_owned = (o & 1) || (o == 0);
13683         o_conv = GossipTimestampFilter_clone(&o_conv);
13684         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13685         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
13686         return (uint64_t)ret_conv;
13687 }
13688
13689 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
13690         LDKDecodeError e_conv;
13691         e_conv.inner = (void*)(e & (~1));
13692         e_conv.is_owned = (e & 1) || (e == 0);
13693         e_conv = DecodeError_clone(&e_conv);
13694         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13695         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
13696         return (uint64_t)ret_conv;
13697 }
13698
13699 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
13700         if ((_res & 1) != 0) return;
13701         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13702         CHECK_ACCESS(_res_ptr);
13703         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
13704         FREE((void*)_res);
13705         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
13706 }
13707
13708 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
13709         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
13710         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13711         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
13712         return (uint64_t)ret_conv;
13713 }
13714
13715 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
13716         LDKInvoice o_conv;
13717         o_conv.inner = (void*)(o & (~1));
13718         o_conv.is_owned = (o & 1) || (o == 0);
13719         o_conv = Invoice_clone(&o_conv);
13720         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13721         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
13722         return (uint64_t)ret_conv;
13723 }
13724
13725 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
13726         void* e_ptr = (void*)(((uint64_t)e) & ~1);
13727         CHECK_ACCESS(e_ptr);
13728         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
13729         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
13730         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13731         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
13732         return (uint64_t)ret_conv;
13733 }
13734
13735 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
13736         if ((_res & 1) != 0) return;
13737         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13738         CHECK_ACCESS(_res_ptr);
13739         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
13740         FREE((void*)_res);
13741         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
13742 }
13743
13744 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
13745         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
13746         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13747         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
13748         return (uint64_t)ret_conv;
13749 }
13750
13751 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_some(uint32_t o) {
13752         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13753         CHECK_ACCESS(o_ptr);
13754         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
13755         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
13756         *ret_copy = COption_FilterZ_some(o_conv);
13757         uint64_t ret_ref = (uint64_t)ret_copy;
13758         return ret_ref;
13759 }
13760
13761 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_none() {
13762         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
13763         *ret_copy = COption_FilterZ_none();
13764         uint64_t ret_ref = (uint64_t)ret_copy;
13765         return ret_ref;
13766 }
13767
13768 void  __attribute__((visibility("default"))) TS_COption_FilterZ_free(uint32_t _res) {
13769         if ((_res & 1) != 0) return;
13770         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13771         CHECK_ACCESS(_res_ptr);
13772         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
13773         FREE((void*)_res);
13774         COption_FilterZ_free(_res_conv);
13775 }
13776
13777 uint32_t  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
13778         LDKLockedChannelMonitor o_conv;
13779         o_conv.inner = (void*)(o & (~1));
13780         o_conv.is_owned = (o & 1) || (o == 0);
13781         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
13782         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
13783         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
13784         return (uint64_t)ret_conv;
13785 }
13786
13787 uint32_t  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
13788         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
13789         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
13790         return (uint64_t)ret_conv;
13791 }
13792
13793 void  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
13794         if ((_res & 1) != 0) return;
13795         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13796         CHECK_ACCESS(_res_ptr);
13797         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
13798         FREE((void*)_res);
13799         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
13800 }
13801
13802 void  __attribute__((visibility("default"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
13803         LDKCVec_OutPointZ _res_constr;
13804         _res_constr.datalen = *((uint32_t*)_res);
13805         if (_res_constr.datalen > 0)
13806                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
13807         else
13808                 _res_constr.data = NULL;
13809         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13810         for (size_t k = 0; k < _res_constr.datalen; k++) {
13811                 uint32_t _res_conv_10 = _res_vals[k];
13812                 LDKOutPoint _res_conv_10_conv;
13813                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
13814                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
13815                 _res_constr.data[k] = _res_conv_10_conv;
13816         }
13817         CVec_OutPointZ_free(_res_constr);
13818 }
13819
13820 void  __attribute__((visibility("default"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
13821         if ((this_ptr & 1) != 0) return;
13822         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
13823         CHECK_ACCESS(this_ptr_ptr);
13824         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
13825         FREE((void*)this_ptr);
13826         PaymentPurpose_free(this_ptr_conv);
13827 }
13828
13829 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_clone(uint32_t orig) {
13830         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
13831         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
13832         *ret_copy = PaymentPurpose_clone(orig_conv);
13833         uint64_t ret_ref = (uint64_t)ret_copy;
13834         return ret_ref;
13835 }
13836
13837 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret, int64_t user_payment_id) {
13838         LDKThirtyTwoBytes payment_preimage_ref;
13839         CHECK(*((uint32_t*)payment_preimage) == 32);
13840         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
13841         LDKThirtyTwoBytes payment_secret_ref;
13842         CHECK(*((uint32_t*)payment_secret) == 32);
13843         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
13844         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
13845         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
13846         uint64_t ret_ref = (uint64_t)ret_copy;
13847         return ret_ref;
13848 }
13849
13850 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
13851         LDKThirtyTwoBytes a_ref;
13852         CHECK(*((uint32_t*)a) == 32);
13853         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
13854         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
13855         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
13856         uint64_t ret_ref = (uint64_t)ret_copy;
13857         return ret_ref;
13858 }
13859
13860 void  __attribute__((visibility("default"))) TS_ClosureReason_free(uint32_t this_ptr) {
13861         if ((this_ptr & 1) != 0) return;
13862         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
13863         CHECK_ACCESS(this_ptr_ptr);
13864         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
13865         FREE((void*)this_ptr);
13866         ClosureReason_free(this_ptr_conv);
13867 }
13868
13869 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_clone(uint32_t orig) {
13870         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
13871         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
13872         *ret_copy = ClosureReason_clone(orig_conv);
13873         uint64_t ret_ref = (uint64_t)ret_copy;
13874         return ret_ref;
13875 }
13876
13877 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
13878         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
13879         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
13880         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
13881         uint64_t ret_ref = (uint64_t)ret_copy;
13882         return ret_ref;
13883 }
13884
13885 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_holder_force_closed() {
13886         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
13887         *ret_copy = ClosureReason_holder_force_closed();
13888         uint64_t ret_ref = (uint64_t)ret_copy;
13889         return ret_ref;
13890 }
13891
13892 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_cooperative_closure() {
13893         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
13894         *ret_copy = ClosureReason_cooperative_closure();
13895         uint64_t ret_ref = (uint64_t)ret_copy;
13896         return ret_ref;
13897 }
13898
13899 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_commitment_tx_confirmed() {
13900         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
13901         *ret_copy = ClosureReason_commitment_tx_confirmed();
13902         uint64_t ret_ref = (uint64_t)ret_copy;
13903         return ret_ref;
13904 }
13905
13906 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_processing_error(jstring err) {
13907         LDKStr err_conv = str_ref_to_owned_c(err);
13908         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
13909         *ret_copy = ClosureReason_processing_error(err_conv);
13910         uint64_t ret_ref = (uint64_t)ret_copy;
13911         return ret_ref;
13912 }
13913
13914 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_disconnected_peer() {
13915         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
13916         *ret_copy = ClosureReason_disconnected_peer();
13917         uint64_t ret_ref = (uint64_t)ret_copy;
13918         return ret_ref;
13919 }
13920
13921 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_outdated_channel_manager() {
13922         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
13923         *ret_copy = ClosureReason_outdated_channel_manager();
13924         uint64_t ret_ref = (uint64_t)ret_copy;
13925         return ret_ref;
13926 }
13927
13928 int8_tArray  __attribute__((visibility("default"))) TS_ClosureReason_write(uint32_t obj) {
13929         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
13930         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
13931         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13932         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13933         CVec_u8Z_free(ret_var);
13934         return ret_arr;
13935 }
13936
13937 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
13938         if ((this_ptr & 1) != 0) return;
13939         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
13940         CHECK_ACCESS(this_ptr_ptr);
13941         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
13942         FREE((void*)this_ptr);
13943         Event_free(this_ptr_conv);
13944 }
13945
13946 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
13947         LDKEvent* orig_conv = (LDKEvent*)orig;
13948         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13949         *ret_copy = Event_clone(orig_conv);
13950         uint64_t ret_ref = (uint64_t)ret_copy;
13951         return ret_ref;
13952 }
13953
13954 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) {
13955         LDKThirtyTwoBytes temporary_channel_id_ref;
13956         CHECK(*((uint32_t*)temporary_channel_id) == 32);
13957         memcpy(temporary_channel_id_ref.data, (uint8_t*)(temporary_channel_id + 4), 32);
13958         LDKCVec_u8Z output_script_ref;
13959         output_script_ref.datalen = *((uint32_t*)output_script);
13960         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
13961         memcpy(output_script_ref.data, (uint8_t*)(output_script + 4), output_script_ref.datalen);
13962         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13963         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
13964         uint64_t ret_ref = (uint64_t)ret_copy;
13965         return ret_ref;
13966 }
13967
13968 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
13969         LDKThirtyTwoBytes payment_hash_ref;
13970         CHECK(*((uint32_t*)payment_hash) == 32);
13971         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
13972         void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
13973         CHECK_ACCESS(purpose_ptr);
13974         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
13975         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
13976         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13977         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
13978         uint64_t ret_ref = (uint64_t)ret_copy;
13979         return ret_ref;
13980 }
13981
13982 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArray payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, uint32_t fee_paid_msat) {
13983         LDKThirtyTwoBytes payment_id_ref;
13984         CHECK(*((uint32_t*)payment_id) == 32);
13985         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
13986         LDKThirtyTwoBytes payment_preimage_ref;
13987         CHECK(*((uint32_t*)payment_preimage) == 32);
13988         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
13989         LDKThirtyTwoBytes payment_hash_ref;
13990         CHECK(*((uint32_t*)payment_hash) == 32);
13991         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
13992         void* fee_paid_msat_ptr = (void*)(((uint64_t)fee_paid_msat) & ~1);
13993         CHECK_ACCESS(fee_paid_msat_ptr);
13994         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
13995         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_paid_msat) & ~1));
13996         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13997         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
13998         uint64_t ret_ref = (uint64_t)ret_copy;
13999         return ret_ref;
14000 }
14001
14002 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_path_failed(int8_tArray payment_id, int8_tArray payment_hash, jboolean rejected_by_dest, uint32_t network_update, jboolean all_paths_failed, uint32_tArray path, uint32_t short_channel_id, uint32_t retry) {
14003         LDKThirtyTwoBytes payment_id_ref;
14004         CHECK(*((uint32_t*)payment_id) == 32);
14005         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
14006         LDKThirtyTwoBytes payment_hash_ref;
14007         CHECK(*((uint32_t*)payment_hash) == 32);
14008         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
14009         void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
14010         CHECK_ACCESS(network_update_ptr);
14011         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
14012         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
14013         LDKCVec_RouteHopZ path_constr;
14014         path_constr.datalen = *((uint32_t*)path);
14015         if (path_constr.datalen > 0)
14016                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14017         else
14018                 path_constr.data = NULL;
14019         uint32_t* path_vals = (uint32_t*)(path + 4);
14020         for (size_t k = 0; k < path_constr.datalen; k++) {
14021                 uint32_t path_conv_10 = path_vals[k];
14022                 LDKRouteHop path_conv_10_conv;
14023                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
14024                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
14025                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
14026                 path_constr.data[k] = path_conv_10_conv;
14027         }
14028         void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
14029         CHECK_ACCESS(short_channel_id_ptr);
14030         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
14031         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
14032         LDKRouteParameters retry_conv;
14033         retry_conv.inner = (void*)(retry & (~1));
14034         retry_conv.is_owned = (retry & 1) || (retry == 0);
14035         retry_conv = RouteParameters_clone(&retry_conv);
14036         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14037         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
14038         uint64_t ret_ref = (uint64_t)ret_copy;
14039         return ret_ref;
14040 }
14041
14042 uint32_t  __attribute__((visibility("default"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
14043         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14044         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
14045         uint64_t ret_ref = (uint64_t)ret_copy;
14046         return ret_ref;
14047 }
14048
14049 uint32_t  __attribute__((visibility("default"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
14050         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
14051         outputs_constr.datalen = *((uint32_t*)outputs);
14052         if (outputs_constr.datalen > 0)
14053                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
14054         else
14055                 outputs_constr.data = NULL;
14056         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
14057         for (size_t b = 0; b < outputs_constr.datalen; b++) {
14058                 uint32_t outputs_conv_27 = outputs_vals[b];
14059                 void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
14060                 CHECK_ACCESS(outputs_conv_27_ptr);
14061                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
14062                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
14063                 outputs_constr.data[b] = outputs_conv_27_conv;
14064         }
14065         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14066         *ret_copy = Event_spendable_outputs(outputs_constr);
14067         uint64_t ret_ref = (uint64_t)ret_copy;
14068         return ret_ref;
14069 }
14070
14071 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
14072         void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
14073         CHECK_ACCESS(fee_earned_msat_ptr);
14074         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
14075         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
14076         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14077         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
14078         uint64_t ret_ref = (uint64_t)ret_copy;
14079         return ret_ref;
14080 }
14081
14082 uint32_t  __attribute__((visibility("default"))) TS_Event_channel_closed(int8_tArray channel_id, int64_t user_channel_id, uint32_t reason) {
14083         LDKThirtyTwoBytes channel_id_ref;
14084         CHECK(*((uint32_t*)channel_id) == 32);
14085         memcpy(channel_id_ref.data, (uint8_t*)(channel_id + 4), 32);
14086         void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
14087         CHECK_ACCESS(reason_ptr);
14088         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
14089         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
14090         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14091         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
14092         uint64_t ret_ref = (uint64_t)ret_copy;
14093         return ret_ref;
14094 }
14095
14096 uint32_t  __attribute__((visibility("default"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
14097         LDKThirtyTwoBytes channel_id_ref;
14098         CHECK(*((uint32_t*)channel_id) == 32);
14099         memcpy(channel_id_ref.data, (uint8_t*)(channel_id + 4), 32);
14100         LDKTransaction transaction_ref;
14101         transaction_ref.datalen = *((uint32_t*)transaction);
14102         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
14103         memcpy(transaction_ref.data, (uint8_t*)(transaction + 4), transaction_ref.datalen);
14104         transaction_ref.data_is_owned = true;
14105         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14106         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
14107         uint64_t ret_ref = (uint64_t)ret_copy;
14108         return ret_ref;
14109 }
14110
14111 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
14112         LDKEvent* obj_conv = (LDKEvent*)obj;
14113         LDKCVec_u8Z ret_var = Event_write(obj_conv);
14114         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14115         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14116         CVec_u8Z_free(ret_var);
14117         return ret_arr;
14118 }
14119
14120 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
14121         if ((this_ptr & 1) != 0) return;
14122         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
14123         CHECK_ACCESS(this_ptr_ptr);
14124         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
14125         FREE((void*)this_ptr);
14126         MessageSendEvent_free(this_ptr_conv);
14127 }
14128
14129 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
14130         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
14131         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14132         *ret_copy = MessageSendEvent_clone(orig_conv);
14133         uint64_t ret_ref = (uint64_t)ret_copy;
14134         return ret_ref;
14135 }
14136
14137 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
14138         LDKPublicKey node_id_ref;
14139         CHECK(*((uint32_t*)node_id) == 33);
14140         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14141         LDKAcceptChannel msg_conv;
14142         msg_conv.inner = (void*)(msg & (~1));
14143         msg_conv.is_owned = (msg & 1) || (msg == 0);
14144         msg_conv = AcceptChannel_clone(&msg_conv);
14145         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14146         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
14147         uint64_t ret_ref = (uint64_t)ret_copy;
14148         return ret_ref;
14149 }
14150
14151 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
14152         LDKPublicKey node_id_ref;
14153         CHECK(*((uint32_t*)node_id) == 33);
14154         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14155         LDKOpenChannel msg_conv;
14156         msg_conv.inner = (void*)(msg & (~1));
14157         msg_conv.is_owned = (msg & 1) || (msg == 0);
14158         msg_conv = OpenChannel_clone(&msg_conv);
14159         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14160         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
14161         uint64_t ret_ref = (uint64_t)ret_copy;
14162         return ret_ref;
14163 }
14164
14165 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
14166         LDKPublicKey node_id_ref;
14167         CHECK(*((uint32_t*)node_id) == 33);
14168         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14169         LDKFundingCreated msg_conv;
14170         msg_conv.inner = (void*)(msg & (~1));
14171         msg_conv.is_owned = (msg & 1) || (msg == 0);
14172         msg_conv = FundingCreated_clone(&msg_conv);
14173         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14174         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
14175         uint64_t ret_ref = (uint64_t)ret_copy;
14176         return ret_ref;
14177 }
14178
14179 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
14180         LDKPublicKey node_id_ref;
14181         CHECK(*((uint32_t*)node_id) == 33);
14182         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14183         LDKFundingSigned msg_conv;
14184         msg_conv.inner = (void*)(msg & (~1));
14185         msg_conv.is_owned = (msg & 1) || (msg == 0);
14186         msg_conv = FundingSigned_clone(&msg_conv);
14187         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14188         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
14189         uint64_t ret_ref = (uint64_t)ret_copy;
14190         return ret_ref;
14191 }
14192
14193 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
14194         LDKPublicKey node_id_ref;
14195         CHECK(*((uint32_t*)node_id) == 33);
14196         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14197         LDKFundingLocked msg_conv;
14198         msg_conv.inner = (void*)(msg & (~1));
14199         msg_conv.is_owned = (msg & 1) || (msg == 0);
14200         msg_conv = FundingLocked_clone(&msg_conv);
14201         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14202         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
14203         uint64_t ret_ref = (uint64_t)ret_copy;
14204         return ret_ref;
14205 }
14206
14207 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
14208         LDKPublicKey node_id_ref;
14209         CHECK(*((uint32_t*)node_id) == 33);
14210         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14211         LDKAnnouncementSignatures msg_conv;
14212         msg_conv.inner = (void*)(msg & (~1));
14213         msg_conv.is_owned = (msg & 1) || (msg == 0);
14214         msg_conv = AnnouncementSignatures_clone(&msg_conv);
14215         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14216         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
14217         uint64_t ret_ref = (uint64_t)ret_copy;
14218         return ret_ref;
14219 }
14220
14221 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
14222         LDKPublicKey node_id_ref;
14223         CHECK(*((uint32_t*)node_id) == 33);
14224         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14225         LDKCommitmentUpdate updates_conv;
14226         updates_conv.inner = (void*)(updates & (~1));
14227         updates_conv.is_owned = (updates & 1) || (updates == 0);
14228         updates_conv = CommitmentUpdate_clone(&updates_conv);
14229         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14230         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
14231         uint64_t ret_ref = (uint64_t)ret_copy;
14232         return ret_ref;
14233 }
14234
14235 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
14236         LDKPublicKey node_id_ref;
14237         CHECK(*((uint32_t*)node_id) == 33);
14238         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14239         LDKRevokeAndACK msg_conv;
14240         msg_conv.inner = (void*)(msg & (~1));
14241         msg_conv.is_owned = (msg & 1) || (msg == 0);
14242         msg_conv = RevokeAndACK_clone(&msg_conv);
14243         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14244         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
14245         uint64_t ret_ref = (uint64_t)ret_copy;
14246         return ret_ref;
14247 }
14248
14249 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
14250         LDKPublicKey node_id_ref;
14251         CHECK(*((uint32_t*)node_id) == 33);
14252         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14253         LDKClosingSigned msg_conv;
14254         msg_conv.inner = (void*)(msg & (~1));
14255         msg_conv.is_owned = (msg & 1) || (msg == 0);
14256         msg_conv = ClosingSigned_clone(&msg_conv);
14257         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14258         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
14259         uint64_t ret_ref = (uint64_t)ret_copy;
14260         return ret_ref;
14261 }
14262
14263 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
14264         LDKPublicKey node_id_ref;
14265         CHECK(*((uint32_t*)node_id) == 33);
14266         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14267         LDKShutdown msg_conv;
14268         msg_conv.inner = (void*)(msg & (~1));
14269         msg_conv.is_owned = (msg & 1) || (msg == 0);
14270         msg_conv = Shutdown_clone(&msg_conv);
14271         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14272         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
14273         uint64_t ret_ref = (uint64_t)ret_copy;
14274         return ret_ref;
14275 }
14276
14277 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
14278         LDKPublicKey node_id_ref;
14279         CHECK(*((uint32_t*)node_id) == 33);
14280         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14281         LDKChannelReestablish msg_conv;
14282         msg_conv.inner = (void*)(msg & (~1));
14283         msg_conv.is_owned = (msg & 1) || (msg == 0);
14284         msg_conv = ChannelReestablish_clone(&msg_conv);
14285         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14286         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
14287         uint64_t ret_ref = (uint64_t)ret_copy;
14288         return ret_ref;
14289 }
14290
14291 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
14292         LDKChannelAnnouncement msg_conv;
14293         msg_conv.inner = (void*)(msg & (~1));
14294         msg_conv.is_owned = (msg & 1) || (msg == 0);
14295         msg_conv = ChannelAnnouncement_clone(&msg_conv);
14296         LDKChannelUpdate update_msg_conv;
14297         update_msg_conv.inner = (void*)(update_msg & (~1));
14298         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
14299         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
14300         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14301         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
14302         uint64_t ret_ref = (uint64_t)ret_copy;
14303         return ret_ref;
14304 }
14305
14306 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
14307         LDKNodeAnnouncement msg_conv;
14308         msg_conv.inner = (void*)(msg & (~1));
14309         msg_conv.is_owned = (msg & 1) || (msg == 0);
14310         msg_conv = NodeAnnouncement_clone(&msg_conv);
14311         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14312         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
14313         uint64_t ret_ref = (uint64_t)ret_copy;
14314         return ret_ref;
14315 }
14316
14317 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
14318         LDKChannelUpdate msg_conv;
14319         msg_conv.inner = (void*)(msg & (~1));
14320         msg_conv.is_owned = (msg & 1) || (msg == 0);
14321         msg_conv = ChannelUpdate_clone(&msg_conv);
14322         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14323         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
14324         uint64_t ret_ref = (uint64_t)ret_copy;
14325         return ret_ref;
14326 }
14327
14328 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
14329         LDKPublicKey node_id_ref;
14330         CHECK(*((uint32_t*)node_id) == 33);
14331         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14332         LDKChannelUpdate msg_conv;
14333         msg_conv.inner = (void*)(msg & (~1));
14334         msg_conv.is_owned = (msg & 1) || (msg == 0);
14335         msg_conv = ChannelUpdate_clone(&msg_conv);
14336         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14337         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
14338         uint64_t ret_ref = (uint64_t)ret_copy;
14339         return ret_ref;
14340 }
14341
14342 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
14343         LDKPublicKey node_id_ref;
14344         CHECK(*((uint32_t*)node_id) == 33);
14345         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14346         void* action_ptr = (void*)(((uint64_t)action) & ~1);
14347         CHECK_ACCESS(action_ptr);
14348         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
14349         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
14350         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14351         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
14352         uint64_t ret_ref = (uint64_t)ret_copy;
14353         return ret_ref;
14354 }
14355
14356 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
14357         LDKPublicKey node_id_ref;
14358         CHECK(*((uint32_t*)node_id) == 33);
14359         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14360         LDKQueryChannelRange msg_conv;
14361         msg_conv.inner = (void*)(msg & (~1));
14362         msg_conv.is_owned = (msg & 1) || (msg == 0);
14363         msg_conv = QueryChannelRange_clone(&msg_conv);
14364         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14365         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
14366         uint64_t ret_ref = (uint64_t)ret_copy;
14367         return ret_ref;
14368 }
14369
14370 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
14371         LDKPublicKey node_id_ref;
14372         CHECK(*((uint32_t*)node_id) == 33);
14373         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14374         LDKQueryShortChannelIds msg_conv;
14375         msg_conv.inner = (void*)(msg & (~1));
14376         msg_conv.is_owned = (msg & 1) || (msg == 0);
14377         msg_conv = QueryShortChannelIds_clone(&msg_conv);
14378         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14379         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
14380         uint64_t ret_ref = (uint64_t)ret_copy;
14381         return ret_ref;
14382 }
14383
14384 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
14385         LDKPublicKey node_id_ref;
14386         CHECK(*((uint32_t*)node_id) == 33);
14387         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
14388         LDKReplyChannelRange msg_conv;
14389         msg_conv.inner = (void*)(msg & (~1));
14390         msg_conv.is_owned = (msg & 1) || (msg == 0);
14391         msg_conv = ReplyChannelRange_clone(&msg_conv);
14392         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
14393         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
14394         uint64_t ret_ref = (uint64_t)ret_copy;
14395         return ret_ref;
14396 }
14397
14398 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
14399         if ((this_ptr & 1) != 0) return;
14400         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
14401         CHECK_ACCESS(this_ptr_ptr);
14402         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
14403         FREE((void*)this_ptr);
14404         MessageSendEventsProvider_free(this_ptr_conv);
14405 }
14406
14407 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
14408         if ((this_ptr & 1) != 0) return;
14409         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
14410         CHECK_ACCESS(this_ptr_ptr);
14411         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
14412         FREE((void*)this_ptr);
14413         EventsProvider_free(this_ptr_conv);
14414 }
14415
14416 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
14417         if ((this_ptr & 1) != 0) return;
14418         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
14419         CHECK_ACCESS(this_ptr_ptr);
14420         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
14421         FREE((void*)this_ptr);
14422         EventHandler_free(this_ptr_conv);
14423 }
14424
14425 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
14426         if ((this_ptr & 1) != 0) return;
14427         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
14428         CHECK_ACCESS(this_ptr_ptr);
14429         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
14430         FREE((void*)this_ptr);
14431         APIError_free(this_ptr_conv);
14432 }
14433
14434 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
14435         LDKAPIError* orig_conv = (LDKAPIError*)orig;
14436         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14437         *ret_copy = APIError_clone(orig_conv);
14438         uint64_t ret_ref = (uint64_t)ret_copy;
14439         return ret_ref;
14440 }
14441
14442 uint32_t  __attribute__((visibility("default"))) TS_APIError_apimisuse_error(jstring err) {
14443         LDKStr err_conv = str_ref_to_owned_c(err);
14444         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14445         *ret_copy = APIError_apimisuse_error(err_conv);
14446         uint64_t ret_ref = (uint64_t)ret_copy;
14447         return ret_ref;
14448 }
14449
14450 uint32_t  __attribute__((visibility("default"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
14451         LDKStr err_conv = str_ref_to_owned_c(err);
14452         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14453         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
14454         uint64_t ret_ref = (uint64_t)ret_copy;
14455         return ret_ref;
14456 }
14457
14458 uint32_t  __attribute__((visibility("default"))) TS_APIError_route_error(jstring err) {
14459         LDKStr err_conv = str_ref_to_owned_c(err);
14460         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14461         *ret_copy = APIError_route_error(err_conv);
14462         uint64_t ret_ref = (uint64_t)ret_copy;
14463         return ret_ref;
14464 }
14465
14466 uint32_t  __attribute__((visibility("default"))) TS_APIError_channel_unavailable(jstring err) {
14467         LDKStr err_conv = str_ref_to_owned_c(err);
14468         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14469         *ret_copy = APIError_channel_unavailable(err_conv);
14470         uint64_t ret_ref = (uint64_t)ret_copy;
14471         return ret_ref;
14472 }
14473
14474 uint32_t  __attribute__((visibility("default"))) TS_APIError_monitor_update_failed() {
14475         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14476         *ret_copy = APIError_monitor_update_failed();
14477         uint64_t ret_ref = (uint64_t)ret_copy;
14478         return ret_ref;
14479 }
14480
14481 uint32_t  __attribute__((visibility("default"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
14482         LDKShutdownScript script_conv;
14483         script_conv.inner = (void*)(script & (~1));
14484         script_conv.is_owned = (script & 1) || (script == 0);
14485         script_conv = ShutdownScript_clone(&script_conv);
14486         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
14487         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
14488         uint64_t ret_ref = (uint64_t)ret_copy;
14489         return ret_ref;
14490 }
14491
14492 uint32_t  __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_tArray sk) {
14493         LDKu8slice msg_ref;
14494         msg_ref.datalen = *((uint32_t*)msg);
14495         msg_ref.data = (int8_t*)(msg + 4);
14496         unsigned char sk_arr[32];
14497         CHECK(*((uint32_t*)sk) == 32);
14498         memcpy(sk_arr, (uint8_t*)(sk + 4), 32);
14499         unsigned char (*sk_ref)[32] = &sk_arr;
14500         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
14501         *ret_conv = sign(msg_ref, sk_ref);
14502         return (uint64_t)ret_conv;
14503 }
14504
14505 uint32_t  __attribute__((visibility("default"))) TS_recover_pk(int8_tArray msg, jstring sig) {
14506         LDKu8slice msg_ref;
14507         msg_ref.datalen = *((uint32_t*)msg);
14508         msg_ref.data = (int8_t*)(msg + 4);
14509         LDKStr sig_conv = str_ref_to_owned_c(sig);
14510         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14511         *ret_conv = recover_pk(msg_ref, sig_conv);
14512         return (uint64_t)ret_conv;
14513 }
14514
14515 jboolean  __attribute__((visibility("default"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
14516         LDKu8slice msg_ref;
14517         msg_ref.datalen = *((uint32_t*)msg);
14518         msg_ref.data = (int8_t*)(msg + 4);
14519         LDKStr sig_conv = str_ref_to_owned_c(sig);
14520         LDKPublicKey pk_ref;
14521         CHECK(*((uint32_t*)pk) == 33);
14522         memcpy(pk_ref.compressed_form, (uint8_t*)(pk + 4), 33);
14523         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
14524         return ret_val;
14525 }
14526
14527 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
14528         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
14529         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
14530         return ret_conv;
14531 }
14532
14533 uint32_t  __attribute__((visibility("default"))) TS_Level_trace() {
14534         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
14535         return ret_conv;
14536 }
14537
14538 uint32_t  __attribute__((visibility("default"))) TS_Level_debug() {
14539         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
14540         return ret_conv;
14541 }
14542
14543 uint32_t  __attribute__((visibility("default"))) TS_Level_info() {
14544         uint32_t ret_conv = LDKLevel_to_js(Level_info());
14545         return ret_conv;
14546 }
14547
14548 uint32_t  __attribute__((visibility("default"))) TS_Level_warn() {
14549         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
14550         return ret_conv;
14551 }
14552
14553 uint32_t  __attribute__((visibility("default"))) TS_Level_error() {
14554         uint32_t ret_conv = LDKLevel_to_js(Level_error());
14555         return ret_conv;
14556 }
14557
14558 jboolean  __attribute__((visibility("default"))) TS_Level_eq(uint32_t a, uint32_t b) {
14559         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
14560         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
14561         jboolean ret_val = Level_eq(a_conv, b_conv);
14562         return ret_val;
14563 }
14564
14565 int64_t  __attribute__((visibility("default"))) TS_Level_hash(uint32_t o) {
14566         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
14567         int64_t ret_val = Level_hash(o_conv);
14568         return ret_val;
14569 }
14570
14571 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
14572         uint32_t ret_conv = LDKLevel_to_js(Level_max());
14573         return ret_conv;
14574 }
14575
14576 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
14577         if ((this_ptr & 1) != 0) return;
14578         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
14579         CHECK_ACCESS(this_ptr_ptr);
14580         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
14581         FREE((void*)this_ptr);
14582         Logger_free(this_ptr_conv);
14583 }
14584
14585 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
14586         LDKChannelHandshakeConfig this_obj_conv;
14587         this_obj_conv.inner = (void*)(this_obj & (~1));
14588         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14589         ChannelHandshakeConfig_free(this_obj_conv);
14590 }
14591
14592 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
14593         LDKChannelHandshakeConfig this_ptr_conv;
14594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14595         this_ptr_conv.is_owned = false;
14596         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
14597         return ret_val;
14598 }
14599
14600 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
14601         LDKChannelHandshakeConfig this_ptr_conv;
14602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14603         this_ptr_conv.is_owned = false;
14604         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
14605 }
14606
14607 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
14608         LDKChannelHandshakeConfig this_ptr_conv;
14609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14610         this_ptr_conv.is_owned = false;
14611         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
14612         return ret_val;
14613 }
14614
14615 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
14616         LDKChannelHandshakeConfig this_ptr_conv;
14617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14618         this_ptr_conv.is_owned = false;
14619         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
14620 }
14621
14622 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
14623         LDKChannelHandshakeConfig this_ptr_conv;
14624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14625         this_ptr_conv.is_owned = false;
14626         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
14627         return ret_val;
14628 }
14629
14630 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14631         LDKChannelHandshakeConfig this_ptr_conv;
14632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14633         this_ptr_conv.is_owned = false;
14634         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
14635 }
14636
14637 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) {
14638         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
14639         uint64_t ret_ref = 0;
14640         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14641         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14642         ret_ref = (uint64_t)ret_var.inner;
14643         if (ret_var.is_owned) {
14644                 ret_ref |= 1;
14645         }
14646         return ret_ref;
14647 }
14648
14649 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
14650         LDKChannelHandshakeConfig orig_conv;
14651         orig_conv.inner = (void*)(orig & (~1));
14652         orig_conv.is_owned = false;
14653         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
14654         uint64_t ret_ref = 0;
14655         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14656         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14657         ret_ref = (uint64_t)ret_var.inner;
14658         if (ret_var.is_owned) {
14659                 ret_ref |= 1;
14660         }
14661         return ret_ref;
14662 }
14663
14664 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
14665         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
14666         uint64_t ret_ref = 0;
14667         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14668         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14669         ret_ref = (uint64_t)ret_var.inner;
14670         if (ret_var.is_owned) {
14671                 ret_ref |= 1;
14672         }
14673         return ret_ref;
14674 }
14675
14676 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
14677         LDKChannelHandshakeLimits this_obj_conv;
14678         this_obj_conv.inner = (void*)(this_obj & (~1));
14679         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14680         ChannelHandshakeLimits_free(this_obj_conv);
14681 }
14682
14683 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
14684         LDKChannelHandshakeLimits this_ptr_conv;
14685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14686         this_ptr_conv.is_owned = false;
14687         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
14688         return ret_val;
14689 }
14690
14691 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
14692         LDKChannelHandshakeLimits this_ptr_conv;
14693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14694         this_ptr_conv.is_owned = false;
14695         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
14696 }
14697
14698 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
14699         LDKChannelHandshakeLimits this_ptr_conv;
14700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14701         this_ptr_conv.is_owned = false;
14702         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
14703         return ret_val;
14704 }
14705
14706 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14707         LDKChannelHandshakeLimits this_ptr_conv;
14708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14709         this_ptr_conv.is_owned = false;
14710         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
14711 }
14712
14713 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
14714         LDKChannelHandshakeLimits this_ptr_conv;
14715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14716         this_ptr_conv.is_owned = false;
14717         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
14718         return ret_val;
14719 }
14720
14721 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
14722         LDKChannelHandshakeLimits this_ptr_conv;
14723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14724         this_ptr_conv.is_owned = false;
14725         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14726 }
14727
14728 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
14729         LDKChannelHandshakeLimits this_ptr_conv;
14730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14731         this_ptr_conv.is_owned = false;
14732         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
14733         return ret_val;
14734 }
14735
14736 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
14737         LDKChannelHandshakeLimits this_ptr_conv;
14738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14739         this_ptr_conv.is_owned = false;
14740         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
14741 }
14742
14743 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
14744         LDKChannelHandshakeLimits this_ptr_conv;
14745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14746         this_ptr_conv.is_owned = false;
14747         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
14748         return ret_val;
14749 }
14750
14751 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
14752         LDKChannelHandshakeLimits this_ptr_conv;
14753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14754         this_ptr_conv.is_owned = false;
14755         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
14756 }
14757
14758 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
14759         LDKChannelHandshakeLimits this_ptr_conv;
14760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14761         this_ptr_conv.is_owned = false;
14762         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
14763         return ret_val;
14764 }
14765
14766 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
14767         LDKChannelHandshakeLimits this_ptr_conv;
14768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14769         this_ptr_conv.is_owned = false;
14770         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
14771 }
14772
14773 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
14774         LDKChannelHandshakeLimits this_ptr_conv;
14775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14776         this_ptr_conv.is_owned = false;
14777         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
14778         return ret_val;
14779 }
14780
14781 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
14782         LDKChannelHandshakeLimits this_ptr_conv;
14783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14784         this_ptr_conv.is_owned = false;
14785         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
14786 }
14787
14788 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
14789         LDKChannelHandshakeLimits this_ptr_conv;
14790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14791         this_ptr_conv.is_owned = false;
14792         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
14793         return ret_val;
14794 }
14795
14796 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
14797         LDKChannelHandshakeLimits this_ptr_conv;
14798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14799         this_ptr_conv.is_owned = false;
14800         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
14801 }
14802
14803 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) {
14804         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);
14805         uint64_t ret_ref = 0;
14806         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14807         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14808         ret_ref = (uint64_t)ret_var.inner;
14809         if (ret_var.is_owned) {
14810                 ret_ref |= 1;
14811         }
14812         return ret_ref;
14813 }
14814
14815 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
14816         LDKChannelHandshakeLimits orig_conv;
14817         orig_conv.inner = (void*)(orig & (~1));
14818         orig_conv.is_owned = false;
14819         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
14820         uint64_t ret_ref = 0;
14821         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14822         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14823         ret_ref = (uint64_t)ret_var.inner;
14824         if (ret_var.is_owned) {
14825                 ret_ref |= 1;
14826         }
14827         return ret_ref;
14828 }
14829
14830 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
14831         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
14832         uint64_t ret_ref = 0;
14833         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14834         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14835         ret_ref = (uint64_t)ret_var.inner;
14836         if (ret_var.is_owned) {
14837                 ret_ref |= 1;
14838         }
14839         return ret_ref;
14840 }
14841
14842 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
14843         LDKChannelConfig this_obj_conv;
14844         this_obj_conv.inner = (void*)(this_obj & (~1));
14845         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14846         ChannelConfig_free(this_obj_conv);
14847 }
14848
14849 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
14850         LDKChannelConfig this_ptr_conv;
14851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14852         this_ptr_conv.is_owned = false;
14853         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
14854         return ret_val;
14855 }
14856
14857 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
14858         LDKChannelConfig this_ptr_conv;
14859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14860         this_ptr_conv.is_owned = false;
14861         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
14862 }
14863
14864 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
14865         LDKChannelConfig this_ptr_conv;
14866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14867         this_ptr_conv.is_owned = false;
14868         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
14869         return ret_val;
14870 }
14871
14872 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint32_t this_ptr, int32_t val) {
14873         LDKChannelConfig this_ptr_conv;
14874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14875         this_ptr_conv.is_owned = false;
14876         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
14877 }
14878
14879 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
14880         LDKChannelConfig this_ptr_conv;
14881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14882         this_ptr_conv.is_owned = false;
14883         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
14884         return ret_val;
14885 }
14886
14887 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
14888         LDKChannelConfig this_ptr_conv;
14889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14890         this_ptr_conv.is_owned = false;
14891         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
14892 }
14893
14894 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
14895         LDKChannelConfig this_ptr_conv;
14896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14897         this_ptr_conv.is_owned = false;
14898         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
14899         return ret_val;
14900 }
14901
14902 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
14903         LDKChannelConfig this_ptr_conv;
14904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14905         this_ptr_conv.is_owned = false;
14906         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
14907 }
14908
14909 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
14910         LDKChannelConfig this_ptr_conv;
14911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14912         this_ptr_conv.is_owned = false;
14913         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
14914         return ret_val;
14915 }
14916
14917 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
14918         LDKChannelConfig this_ptr_conv;
14919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14920         this_ptr_conv.is_owned = false;
14921         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
14922 }
14923
14924 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_max_dust_htlc_exposure_msat(uint32_t this_ptr) {
14925         LDKChannelConfig this_ptr_conv;
14926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14927         this_ptr_conv.is_owned = false;
14928         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
14929         return ret_val;
14930 }
14931
14932 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_max_dust_htlc_exposure_msat(uint32_t this_ptr, int64_t val) {
14933         LDKChannelConfig this_ptr_conv;
14934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14935         this_ptr_conv.is_owned = false;
14936         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
14937 }
14938
14939 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr) {
14940         LDKChannelConfig this_ptr_conv;
14941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14942         this_ptr_conv.is_owned = false;
14943         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
14944         return ret_val;
14945 }
14946
14947 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
14948         LDKChannelConfig this_ptr_conv;
14949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14950         this_ptr_conv.is_owned = false;
14951         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
14952 }
14953
14954 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) {
14955         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);
14956         uint64_t ret_ref = 0;
14957         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14958         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14959         ret_ref = (uint64_t)ret_var.inner;
14960         if (ret_var.is_owned) {
14961                 ret_ref |= 1;
14962         }
14963         return ret_ref;
14964 }
14965
14966 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
14967         LDKChannelConfig orig_conv;
14968         orig_conv.inner = (void*)(orig & (~1));
14969         orig_conv.is_owned = false;
14970         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
14971         uint64_t ret_ref = 0;
14972         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14973         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14974         ret_ref = (uint64_t)ret_var.inner;
14975         if (ret_var.is_owned) {
14976                 ret_ref |= 1;
14977         }
14978         return ret_ref;
14979 }
14980
14981 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
14982         LDKChannelConfig ret_var = ChannelConfig_default();
14983         uint64_t ret_ref = 0;
14984         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14985         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14986         ret_ref = (uint64_t)ret_var.inner;
14987         if (ret_var.is_owned) {
14988                 ret_ref |= 1;
14989         }
14990         return ret_ref;
14991 }
14992
14993 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
14994         LDKChannelConfig obj_conv;
14995         obj_conv.inner = (void*)(obj & (~1));
14996         obj_conv.is_owned = false;
14997         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
14998         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14999         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15000         CVec_u8Z_free(ret_var);
15001         return ret_arr;
15002 }
15003
15004 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
15005         LDKu8slice ser_ref;
15006         ser_ref.datalen = *((uint32_t*)ser);
15007         ser_ref.data = (int8_t*)(ser + 4);
15008         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
15009         *ret_conv = ChannelConfig_read(ser_ref);
15010         return (uint64_t)ret_conv;
15011 }
15012
15013 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
15014         LDKUserConfig this_obj_conv;
15015         this_obj_conv.inner = (void*)(this_obj & (~1));
15016         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15017         UserConfig_free(this_obj_conv);
15018 }
15019
15020 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
15021         LDKUserConfig this_ptr_conv;
15022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15023         this_ptr_conv.is_owned = false;
15024         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
15025         uint64_t ret_ref = 0;
15026         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15027         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15028         ret_ref = (uint64_t)ret_var.inner;
15029         if (ret_var.is_owned) {
15030                 ret_ref |= 1;
15031         }
15032         return ret_ref;
15033 }
15034
15035 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
15036         LDKUserConfig this_ptr_conv;
15037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15038         this_ptr_conv.is_owned = false;
15039         LDKChannelHandshakeConfig val_conv;
15040         val_conv.inner = (void*)(val & (~1));
15041         val_conv.is_owned = (val & 1) || (val == 0);
15042         val_conv = ChannelHandshakeConfig_clone(&val_conv);
15043         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
15044 }
15045
15046 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
15047         LDKUserConfig this_ptr_conv;
15048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15049         this_ptr_conv.is_owned = false;
15050         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
15051         uint64_t ret_ref = 0;
15052         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15053         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15054         ret_ref = (uint64_t)ret_var.inner;
15055         if (ret_var.is_owned) {
15056                 ret_ref |= 1;
15057         }
15058         return ret_ref;
15059 }
15060
15061 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
15062         LDKUserConfig this_ptr_conv;
15063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15064         this_ptr_conv.is_owned = false;
15065         LDKChannelHandshakeLimits val_conv;
15066         val_conv.inner = (void*)(val & (~1));
15067         val_conv.is_owned = (val & 1) || (val == 0);
15068         val_conv = ChannelHandshakeLimits_clone(&val_conv);
15069         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
15070 }
15071
15072 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
15073         LDKUserConfig this_ptr_conv;
15074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15075         this_ptr_conv.is_owned = false;
15076         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
15077         uint64_t ret_ref = 0;
15078         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15079         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15080         ret_ref = (uint64_t)ret_var.inner;
15081         if (ret_var.is_owned) {
15082                 ret_ref |= 1;
15083         }
15084         return ret_ref;
15085 }
15086
15087 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
15088         LDKUserConfig this_ptr_conv;
15089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15090         this_ptr_conv.is_owned = false;
15091         LDKChannelConfig val_conv;
15092         val_conv.inner = (void*)(val & (~1));
15093         val_conv.is_owned = (val & 1) || (val == 0);
15094         val_conv = ChannelConfig_clone(&val_conv);
15095         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
15096 }
15097
15098 jboolean  __attribute__((visibility("default"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
15099         LDKUserConfig this_ptr_conv;
15100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15101         this_ptr_conv.is_owned = false;
15102         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
15103         return ret_val;
15104 }
15105
15106 void  __attribute__((visibility("default"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint32_t this_ptr, jboolean val) {
15107         LDKUserConfig this_ptr_conv;
15108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15109         this_ptr_conv.is_owned = false;
15110         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
15111 }
15112
15113 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) {
15114         LDKChannelHandshakeConfig own_channel_config_arg_conv;
15115         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
15116         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
15117         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
15118         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
15119         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
15120         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
15121         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
15122         LDKChannelConfig channel_options_arg_conv;
15123         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
15124         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
15125         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
15126         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);
15127         uint64_t ret_ref = 0;
15128         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15129         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15130         ret_ref = (uint64_t)ret_var.inner;
15131         if (ret_var.is_owned) {
15132                 ret_ref |= 1;
15133         }
15134         return ret_ref;
15135 }
15136
15137 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
15138         LDKUserConfig orig_conv;
15139         orig_conv.inner = (void*)(orig & (~1));
15140         orig_conv.is_owned = false;
15141         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
15142         uint64_t ret_ref = 0;
15143         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15144         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15145         ret_ref = (uint64_t)ret_var.inner;
15146         if (ret_var.is_owned) {
15147                 ret_ref |= 1;
15148         }
15149         return ret_ref;
15150 }
15151
15152 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
15153         LDKUserConfig ret_var = UserConfig_default();
15154         uint64_t ret_ref = 0;
15155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15157         ret_ref = (uint64_t)ret_var.inner;
15158         if (ret_var.is_owned) {
15159                 ret_ref |= 1;
15160         }
15161         return ret_ref;
15162 }
15163
15164 void  __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) {
15165         LDKBestBlock this_obj_conv;
15166         this_obj_conv.inner = (void*)(this_obj & (~1));
15167         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15168         BestBlock_free(this_obj_conv);
15169 }
15170
15171 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) {
15172         LDKBestBlock orig_conv;
15173         orig_conv.inner = (void*)(orig & (~1));
15174         orig_conv.is_owned = false;
15175         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
15176         uint64_t ret_ref = 0;
15177         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15178         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15179         ret_ref = (uint64_t)ret_var.inner;
15180         if (ret_var.is_owned) {
15181                 ret_ref |= 1;
15182         }
15183         return ret_ref;
15184 }
15185
15186 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
15187         LDKNetwork network_conv = LDKNetwork_from_js(network);
15188         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
15189         uint64_t ret_ref = 0;
15190         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15191         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15192         ret_ref = (uint64_t)ret_var.inner;
15193         if (ret_var.is_owned) {
15194                 ret_ref |= 1;
15195         }
15196         return ret_ref;
15197 }
15198
15199 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
15200         LDKThirtyTwoBytes block_hash_ref;
15201         CHECK(*((uint32_t*)block_hash) == 32);
15202         memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
15203         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
15204         uint64_t ret_ref = 0;
15205         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15206         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15207         ret_ref = (uint64_t)ret_var.inner;
15208         if (ret_var.is_owned) {
15209                 ret_ref |= 1;
15210         }
15211         return ret_ref;
15212 }
15213
15214 int8_tArray  __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) {
15215         LDKBestBlock this_arg_conv;
15216         this_arg_conv.inner = (void*)(this_arg & (~1));
15217         this_arg_conv.is_owned = false;
15218         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15219         memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32);
15220         return ret_arr;
15221 }
15222
15223 int32_t  __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) {
15224         LDKBestBlock this_arg_conv;
15225         this_arg_conv.inner = (void*)(this_arg & (~1));
15226         this_arg_conv.is_owned = false;
15227         int32_t ret_val = BestBlock_height(&this_arg_conv);
15228         return ret_val;
15229 }
15230
15231 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
15232         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
15233         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
15234         return ret_conv;
15235 }
15236
15237 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_chain() {
15238         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
15239         return ret_conv;
15240 }
15241
15242 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_tx() {
15243         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
15244         return ret_conv;
15245 }
15246
15247 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
15248         if ((this_ptr & 1) != 0) return;
15249         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15250         CHECK_ACCESS(this_ptr_ptr);
15251         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
15252         FREE((void*)this_ptr);
15253         Access_free(this_ptr_conv);
15254 }
15255
15256 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
15257         if ((this_ptr & 1) != 0) return;
15258         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15259         CHECK_ACCESS(this_ptr_ptr);
15260         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
15261         FREE((void*)this_ptr);
15262         Listen_free(this_ptr_conv);
15263 }
15264
15265 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
15266         if ((this_ptr & 1) != 0) return;
15267         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15268         CHECK_ACCESS(this_ptr_ptr);
15269         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
15270         FREE((void*)this_ptr);
15271         Confirm_free(this_ptr_conv);
15272 }
15273
15274 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
15275         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
15276         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
15277         return ret_conv;
15278 }
15279
15280 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
15281         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
15282         return ret_conv;
15283 }
15284
15285 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
15286         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
15287         return ret_conv;
15288 }
15289
15290 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
15291         if ((this_ptr & 1) != 0) return;
15292         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15293         CHECK_ACCESS(this_ptr_ptr);
15294         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
15295         FREE((void*)this_ptr);
15296         Watch_free(this_ptr_conv);
15297 }
15298
15299 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
15300         if ((this_ptr & 1) != 0) return;
15301         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15302         CHECK_ACCESS(this_ptr_ptr);
15303         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
15304         FREE((void*)this_ptr);
15305         Filter_free(this_ptr_conv);
15306 }
15307
15308 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
15309         LDKWatchedOutput this_obj_conv;
15310         this_obj_conv.inner = (void*)(this_obj & (~1));
15311         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15312         WatchedOutput_free(this_obj_conv);
15313 }
15314
15315 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
15316         LDKWatchedOutput this_ptr_conv;
15317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15318         this_ptr_conv.is_owned = false;
15319         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15320         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
15321         return ret_arr;
15322 }
15323
15324 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
15325         LDKWatchedOutput this_ptr_conv;
15326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15327         this_ptr_conv.is_owned = false;
15328         LDKThirtyTwoBytes val_ref;
15329         CHECK(*((uint32_t*)val) == 32);
15330         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15331         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
15332 }
15333
15334 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
15335         LDKWatchedOutput this_ptr_conv;
15336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15337         this_ptr_conv.is_owned = false;
15338         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
15339         uint64_t ret_ref = 0;
15340         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15341         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15342         ret_ref = (uint64_t)ret_var.inner;
15343         if (ret_var.is_owned) {
15344                 ret_ref |= 1;
15345         }
15346         return ret_ref;
15347 }
15348
15349 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
15350         LDKWatchedOutput this_ptr_conv;
15351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15352         this_ptr_conv.is_owned = false;
15353         LDKOutPoint val_conv;
15354         val_conv.inner = (void*)(val & (~1));
15355         val_conv.is_owned = (val & 1) || (val == 0);
15356         val_conv = OutPoint_clone(&val_conv);
15357         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
15358 }
15359
15360 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
15361         LDKWatchedOutput this_ptr_conv;
15362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15363         this_ptr_conv.is_owned = false;
15364         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
15365         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15366         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15367         return ret_arr;
15368 }
15369
15370 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
15371         LDKWatchedOutput this_ptr_conv;
15372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15373         this_ptr_conv.is_owned = false;
15374         LDKCVec_u8Z val_ref;
15375         val_ref.datalen = *((uint32_t*)val);
15376         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
15377         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
15378         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
15379 }
15380
15381 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
15382         LDKThirtyTwoBytes block_hash_arg_ref;
15383         CHECK(*((uint32_t*)block_hash_arg) == 32);
15384         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
15385         LDKOutPoint outpoint_arg_conv;
15386         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15387         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15388         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15389         LDKCVec_u8Z script_pubkey_arg_ref;
15390         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
15391         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
15392         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
15393         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
15394         uint64_t ret_ref = 0;
15395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15397         ret_ref = (uint64_t)ret_var.inner;
15398         if (ret_var.is_owned) {
15399                 ret_ref |= 1;
15400         }
15401         return ret_ref;
15402 }
15403
15404 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t orig) {
15405         LDKWatchedOutput orig_conv;
15406         orig_conv.inner = (void*)(orig & (~1));
15407         orig_conv.is_owned = false;
15408         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
15409         uint64_t ret_ref = 0;
15410         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15411         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15412         ret_ref = (uint64_t)ret_var.inner;
15413         if (ret_var.is_owned) {
15414                 ret_ref |= 1;
15415         }
15416         return ret_ref;
15417 }
15418
15419 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o) {
15420         LDKWatchedOutput o_conv;
15421         o_conv.inner = (void*)(o & (~1));
15422         o_conv.is_owned = false;
15423         int64_t ret_val = WatchedOutput_hash(&o_conv);
15424         return ret_val;
15425 }
15426
15427 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
15428         if ((this_ptr & 1) != 0) return;
15429         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15430         CHECK_ACCESS(this_ptr_ptr);
15431         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
15432         FREE((void*)this_ptr);
15433         BroadcasterInterface_free(this_ptr_conv);
15434 }
15435
15436 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
15437         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
15438         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
15439         return ret_conv;
15440 }
15441
15442 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_background() {
15443         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
15444         return ret_conv;
15445 }
15446
15447 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_normal() {
15448         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
15449         return ret_conv;
15450 }
15451
15452 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_high_priority() {
15453         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
15454         return ret_conv;
15455 }
15456
15457 jboolean  __attribute__((visibility("default"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
15458         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
15459         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
15460         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
15461         return ret_val;
15462 }
15463
15464 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
15465         if ((this_ptr & 1) != 0) return;
15466         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15467         CHECK_ACCESS(this_ptr_ptr);
15468         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
15469         FREE((void*)this_ptr);
15470         FeeEstimator_free(this_ptr_conv);
15471 }
15472
15473 void  __attribute__((visibility("default"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
15474         LDKMonitorUpdateId this_obj_conv;
15475         this_obj_conv.inner = (void*)(this_obj & (~1));
15476         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15477         MonitorUpdateId_free(this_obj_conv);
15478 }
15479
15480 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateId_clone(uint32_t orig) {
15481         LDKMonitorUpdateId orig_conv;
15482         orig_conv.inner = (void*)(orig & (~1));
15483         orig_conv.is_owned = false;
15484         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
15485         uint64_t ret_ref = 0;
15486         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15487         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15488         ret_ref = (uint64_t)ret_var.inner;
15489         if (ret_var.is_owned) {
15490                 ret_ref |= 1;
15491         }
15492         return ret_ref;
15493 }
15494
15495 int64_t  __attribute__((visibility("default"))) TS_MonitorUpdateId_hash(uint32_t o) {
15496         LDKMonitorUpdateId o_conv;
15497         o_conv.inner = (void*)(o & (~1));
15498         o_conv.is_owned = false;
15499         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
15500         return ret_val;
15501 }
15502
15503 jboolean  __attribute__((visibility("default"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
15504         LDKMonitorUpdateId a_conv;
15505         a_conv.inner = (void*)(a & (~1));
15506         a_conv.is_owned = false;
15507         LDKMonitorUpdateId b_conv;
15508         b_conv.inner = (void*)(b & (~1));
15509         b_conv.is_owned = false;
15510         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
15511         return ret_val;
15512 }
15513
15514 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
15515         if ((this_ptr & 1) != 0) return;
15516         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15517         CHECK_ACCESS(this_ptr_ptr);
15518         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
15519         FREE((void*)this_ptr);
15520         Persist_free(this_ptr_conv);
15521 }
15522
15523 void  __attribute__((visibility("default"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
15524         LDKLockedChannelMonitor this_obj_conv;
15525         this_obj_conv.inner = (void*)(this_obj & (~1));
15526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15527         LockedChannelMonitor_free(this_obj_conv);
15528 }
15529
15530 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
15531         LDKChainMonitor this_obj_conv;
15532         this_obj_conv.inner = (void*)(this_obj & (~1));
15533         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15534         ChainMonitor_free(this_obj_conv);
15535 }
15536
15537 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
15538         void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
15539         CHECK_ACCESS(chain_source_ptr);
15540         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
15541         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
15542         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
15543                 // Manually implement clone for Java trait instances
15544         }
15545         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
15546         CHECK_ACCESS(broadcaster_ptr);
15547         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
15548         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
15549         CHECK_ACCESS(logger_ptr);
15550         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
15551         void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
15552         CHECK_ACCESS(feeest_ptr);
15553         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
15554         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
15555         CHECK_ACCESS(persister_ptr);
15556         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
15557         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
15558         uint64_t ret_ref = 0;
15559         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15560         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15561         ret_ref = (uint64_t)ret_var.inner;
15562         if (ret_var.is_owned) {
15563                 ret_ref |= 1;
15564         }
15565         return ret_ref;
15566 }
15567
15568 uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
15569         LDKChainMonitor this_arg_conv;
15570         this_arg_conv.inner = (void*)(this_arg & (~1));
15571         this_arg_conv.is_owned = false;
15572         LDKCVec_ChannelDetailsZ ignored_channels_constr;
15573         ignored_channels_constr.datalen = *((uint32_t*)ignored_channels);
15574         if (ignored_channels_constr.datalen > 0)
15575                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15576         else
15577                 ignored_channels_constr.data = NULL;
15578         uint32_t* ignored_channels_vals = (uint32_t*)(ignored_channels + 4);
15579         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
15580                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
15581                 LDKChannelDetails ignored_channels_conv_16_conv;
15582                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
15583                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
15584                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
15585                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
15586         }
15587         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
15588         uint32_tArray ret_arr = NULL;
15589         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
15590         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
15591         for (size_t j = 0; j < ret_var.datalen; j++) {
15592                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
15593                 *ret_conv_9_copy = ret_var.data[j];
15594                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
15595                 ret_arr_ptr[j] = ret_conv_9_ref;
15596         }
15597         
15598         FREE(ret_var.data);
15599         return ret_arr;
15600 }
15601
15602 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
15603         LDKChainMonitor this_arg_conv;
15604         this_arg_conv.inner = (void*)(this_arg & (~1));
15605         this_arg_conv.is_owned = false;
15606         LDKOutPoint funding_txo_conv;
15607         funding_txo_conv.inner = (void*)(funding_txo & (~1));
15608         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
15609         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
15610         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15611         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
15612         return (uint64_t)ret_conv;
15613 }
15614
15615 uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
15616         LDKChainMonitor this_arg_conv;
15617         this_arg_conv.inner = (void*)(this_arg & (~1));
15618         this_arg_conv.is_owned = false;
15619         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
15620         uint32_tArray ret_arr = NULL;
15621         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
15622         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
15623         for (size_t k = 0; k < ret_var.datalen; k++) {
15624                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
15625                 uint64_t ret_conv_10_ref = 0;
15626                 CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15627                 CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15628                 ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
15629                 if (ret_conv_10_var.is_owned) {
15630                         ret_conv_10_ref |= 1;
15631                 }
15632                 ret_arr_ptr[k] = ret_conv_10_ref;
15633         }
15634         
15635         FREE(ret_var.data);
15636         return ret_arr;
15637 }
15638
15639 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, uint32_t completed_update_id) {
15640         LDKChainMonitor this_arg_conv;
15641         this_arg_conv.inner = (void*)(this_arg & (~1));
15642         this_arg_conv.is_owned = false;
15643         LDKOutPoint funding_txo_conv;
15644         funding_txo_conv.inner = (void*)(funding_txo & (~1));
15645         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
15646         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
15647         LDKMonitorUpdateId completed_update_id_conv;
15648         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
15649         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
15650         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
15651         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15652         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
15653         return (uint64_t)ret_conv;
15654 }
15655
15656 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
15657         LDKChainMonitor this_arg_conv;
15658         this_arg_conv.inner = (void*)(this_arg & (~1));
15659         this_arg_conv.is_owned = false;
15660         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
15661         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
15662         return (uint64_t)ret_ret;
15663 }
15664
15665 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
15666         LDKChainMonitor this_arg_conv;
15667         this_arg_conv.inner = (void*)(this_arg & (~1));
15668         this_arg_conv.is_owned = false;
15669         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
15670         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
15671         return (uint64_t)ret_ret;
15672 }
15673
15674 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
15675         LDKChainMonitor this_arg_conv;
15676         this_arg_conv.inner = (void*)(this_arg & (~1));
15677         this_arg_conv.is_owned = false;
15678         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
15679         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
15680         return (uint64_t)ret_ret;
15681 }
15682
15683 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
15684         LDKChainMonitor this_arg_conv;
15685         this_arg_conv.inner = (void*)(this_arg & (~1));
15686         this_arg_conv.is_owned = false;
15687         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
15688         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
15689         return (uint64_t)ret_ret;
15690 }
15691
15692 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
15693         LDKChannelMonitorUpdate this_obj_conv;
15694         this_obj_conv.inner = (void*)(this_obj & (~1));
15695         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15696         ChannelMonitorUpdate_free(this_obj_conv);
15697 }
15698
15699 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
15700         LDKChannelMonitorUpdate this_ptr_conv;
15701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15702         this_ptr_conv.is_owned = false;
15703         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
15704         return ret_val;
15705 }
15706
15707 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
15708         LDKChannelMonitorUpdate this_ptr_conv;
15709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15710         this_ptr_conv.is_owned = false;
15711         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
15712 }
15713
15714 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
15715         LDKChannelMonitorUpdate orig_conv;
15716         orig_conv.inner = (void*)(orig & (~1));
15717         orig_conv.is_owned = false;
15718         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
15719         uint64_t ret_ref = 0;
15720         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15721         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15722         ret_ref = (uint64_t)ret_var.inner;
15723         if (ret_var.is_owned) {
15724                 ret_ref |= 1;
15725         }
15726         return ret_ref;
15727 }
15728
15729 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
15730         LDKChannelMonitorUpdate obj_conv;
15731         obj_conv.inner = (void*)(obj & (~1));
15732         obj_conv.is_owned = false;
15733         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
15734         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15735         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15736         CVec_u8Z_free(ret_var);
15737         return ret_arr;
15738 }
15739
15740 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
15741         LDKu8slice ser_ref;
15742         ser_ref.datalen = *((uint32_t*)ser);
15743         ser_ref.data = (int8_t*)(ser + 4);
15744         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15745         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
15746         return (uint64_t)ret_conv;
15747 }
15748
15749 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
15750         LDKMonitorUpdateError this_obj_conv;
15751         this_obj_conv.inner = (void*)(this_obj & (~1));
15752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15753         MonitorUpdateError_free(this_obj_conv);
15754 }
15755
15756 jstring  __attribute__((visibility("default"))) TS_MonitorUpdateError_get_a(uint32_t this_ptr) {
15757         LDKMonitorUpdateError this_ptr_conv;
15758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15759         this_ptr_conv.is_owned = false;
15760         LDKStr ret_str = MonitorUpdateError_get_a(&this_ptr_conv);
15761         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
15762         Str_free(ret_str);
15763         return ret_conv;
15764 }
15765
15766 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_set_a(uint32_t this_ptr, jstring val) {
15767         LDKMonitorUpdateError this_ptr_conv;
15768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15769         this_ptr_conv.is_owned = false;
15770         LDKStr val_conv = str_ref_to_owned_c(val);
15771         MonitorUpdateError_set_a(&this_ptr_conv, val_conv);
15772 }
15773
15774 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_new(jstring a_arg) {
15775         LDKStr a_arg_conv = str_ref_to_owned_c(a_arg);
15776         LDKMonitorUpdateError ret_var = MonitorUpdateError_new(a_arg_conv);
15777         uint64_t ret_ref = 0;
15778         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15779         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15780         ret_ref = (uint64_t)ret_var.inner;
15781         if (ret_var.is_owned) {
15782                 ret_ref |= 1;
15783         }
15784         return ret_ref;
15785 }
15786
15787 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
15788         LDKMonitorUpdateError orig_conv;
15789         orig_conv.inner = (void*)(orig & (~1));
15790         orig_conv.is_owned = false;
15791         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
15792         uint64_t ret_ref = 0;
15793         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15794         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15795         ret_ref = (uint64_t)ret_var.inner;
15796         if (ret_var.is_owned) {
15797                 ret_ref |= 1;
15798         }
15799         return ret_ref;
15800 }
15801
15802 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
15803         if ((this_ptr & 1) != 0) return;
15804         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15805         CHECK_ACCESS(this_ptr_ptr);
15806         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
15807         FREE((void*)this_ptr);
15808         MonitorEvent_free(this_ptr_conv);
15809 }
15810
15811 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
15812         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
15813         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15814         *ret_copy = MonitorEvent_clone(orig_conv);
15815         uint64_t ret_ref = (uint64_t)ret_copy;
15816         return ret_ref;
15817 }
15818
15819 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_htlcevent(uint32_t a) {
15820         LDKHTLCUpdate a_conv;
15821         a_conv.inner = (void*)(a & (~1));
15822         a_conv.is_owned = (a & 1) || (a == 0);
15823         a_conv = HTLCUpdate_clone(&a_conv);
15824         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15825         *ret_copy = MonitorEvent_htlcevent(a_conv);
15826         uint64_t ret_ref = (uint64_t)ret_copy;
15827         return ret_ref;
15828 }
15829
15830 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
15831         LDKOutPoint a_conv;
15832         a_conv.inner = (void*)(a & (~1));
15833         a_conv.is_owned = (a & 1) || (a == 0);
15834         a_conv = OutPoint_clone(&a_conv);
15835         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15836         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
15837         uint64_t ret_ref = (uint64_t)ret_copy;
15838         return ret_ref;
15839 }
15840
15841 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
15842         LDKOutPoint funding_txo_conv;
15843         funding_txo_conv.inner = (void*)(funding_txo & (~1));
15844         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
15845         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
15846         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15847         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
15848         uint64_t ret_ref = (uint64_t)ret_copy;
15849         return ret_ref;
15850 }
15851
15852 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_update_failed(uint32_t a) {
15853         LDKOutPoint a_conv;
15854         a_conv.inner = (void*)(a & (~1));
15855         a_conv.is_owned = (a & 1) || (a == 0);
15856         a_conv = OutPoint_clone(&a_conv);
15857         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
15858         *ret_copy = MonitorEvent_update_failed(a_conv);
15859         uint64_t ret_ref = (uint64_t)ret_copy;
15860         return ret_ref;
15861 }
15862
15863 int8_tArray  __attribute__((visibility("default"))) TS_MonitorEvent_write(uint32_t obj) {
15864         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
15865         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
15866         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15867         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15868         CVec_u8Z_free(ret_var);
15869         return ret_arr;
15870 }
15871
15872 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
15873         LDKHTLCUpdate this_obj_conv;
15874         this_obj_conv.inner = (void*)(this_obj & (~1));
15875         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15876         HTLCUpdate_free(this_obj_conv);
15877 }
15878
15879 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
15880         LDKHTLCUpdate orig_conv;
15881         orig_conv.inner = (void*)(orig & (~1));
15882         orig_conv.is_owned = false;
15883         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
15884         uint64_t ret_ref = 0;
15885         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15886         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15887         ret_ref = (uint64_t)ret_var.inner;
15888         if (ret_var.is_owned) {
15889                 ret_ref |= 1;
15890         }
15891         return ret_ref;
15892 }
15893
15894 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
15895         LDKHTLCUpdate obj_conv;
15896         obj_conv.inner = (void*)(obj & (~1));
15897         obj_conv.is_owned = false;
15898         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
15899         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15900         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15901         CVec_u8Z_free(ret_var);
15902         return ret_arr;
15903 }
15904
15905 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
15906         LDKu8slice ser_ref;
15907         ser_ref.datalen = *((uint32_t*)ser);
15908         ser_ref.data = (int8_t*)(ser + 4);
15909         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15910         *ret_conv = HTLCUpdate_read(ser_ref);
15911         return (uint64_t)ret_conv;
15912 }
15913
15914 void  __attribute__((visibility("default"))) TS_Balance_free(uint32_t this_ptr) {
15915         if ((this_ptr & 1) != 0) return;
15916         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15917         CHECK_ACCESS(this_ptr_ptr);
15918         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
15919         FREE((void*)this_ptr);
15920         Balance_free(this_ptr_conv);
15921 }
15922
15923 uint32_t  __attribute__((visibility("default"))) TS_Balance_clone(uint32_t orig) {
15924         LDKBalance* orig_conv = (LDKBalance*)orig;
15925         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
15926         *ret_copy = Balance_clone(orig_conv);
15927         uint64_t ret_ref = (uint64_t)ret_copy;
15928         return ret_ref;
15929 }
15930
15931 uint32_t  __attribute__((visibility("default"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
15932         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
15933         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
15934         uint64_t ret_ref = (uint64_t)ret_copy;
15935         return ret_ref;
15936 }
15937
15938 uint32_t  __attribute__((visibility("default"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
15939         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
15940         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
15941         uint64_t ret_ref = (uint64_t)ret_copy;
15942         return ret_ref;
15943 }
15944
15945 uint32_t  __attribute__((visibility("default"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
15946         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
15947         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
15948         uint64_t ret_ref = (uint64_t)ret_copy;
15949         return ret_ref;
15950 }
15951
15952 uint32_t  __attribute__((visibility("default"))) TS_Balance_maybe_claimable_htlcawaiting_timeout(int64_t claimable_amount_satoshis, int32_t claimable_height) {
15953         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
15954         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
15955         uint64_t ret_ref = (uint64_t)ret_copy;
15956         return ret_ref;
15957 }
15958
15959 jboolean  __attribute__((visibility("default"))) TS_Balance_eq(uint32_t a, uint32_t b) {
15960         LDKBalance* a_conv = (LDKBalance*)a;
15961         LDKBalance* b_conv = (LDKBalance*)b;
15962         jboolean ret_val = Balance_eq(a_conv, b_conv);
15963         return ret_val;
15964 }
15965
15966 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
15967         LDKChannelMonitor this_obj_conv;
15968         this_obj_conv.inner = (void*)(this_obj & (~1));
15969         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15970         ChannelMonitor_free(this_obj_conv);
15971 }
15972
15973 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
15974         LDKChannelMonitor orig_conv;
15975         orig_conv.inner = (void*)(orig & (~1));
15976         orig_conv.is_owned = false;
15977         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
15978         uint64_t ret_ref = 0;
15979         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15980         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15981         ret_ref = (uint64_t)ret_var.inner;
15982         if (ret_var.is_owned) {
15983                 ret_ref |= 1;
15984         }
15985         return ret_ref;
15986 }
15987
15988 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
15989         LDKChannelMonitor obj_conv;
15990         obj_conv.inner = (void*)(obj & (~1));
15991         obj_conv.is_owned = false;
15992         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
15993         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15994         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15995         CVec_u8Z_free(ret_var);
15996         return ret_arr;
15997 }
15998
15999 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) {
16000         LDKChannelMonitor this_arg_conv;
16001         this_arg_conv.inner = (void*)(this_arg & (~1));
16002         this_arg_conv.is_owned = false;
16003         LDKChannelMonitorUpdate updates_conv;
16004         updates_conv.inner = (void*)(updates & (~1));
16005         updates_conv.is_owned = false;
16006         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
16007         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
16008         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
16009         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
16010         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
16011         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
16012         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
16013         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
16014         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
16015         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
16016         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
16017         return (uint64_t)ret_conv;
16018 }
16019
16020 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
16021         LDKChannelMonitor this_arg_conv;
16022         this_arg_conv.inner = (void*)(this_arg & (~1));
16023         this_arg_conv.is_owned = false;
16024         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
16025         return ret_val;
16026 }
16027
16028 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
16029         LDKChannelMonitor this_arg_conv;
16030         this_arg_conv.inner = (void*)(this_arg & (~1));
16031         this_arg_conv.is_owned = false;
16032         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
16033         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
16034         return ((uint64_t)ret_conv);
16035 }
16036
16037 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
16038         LDKChannelMonitor this_arg_conv;
16039         this_arg_conv.inner = (void*)(this_arg & (~1));
16040         this_arg_conv.is_owned = false;
16041         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
16042         uint32_tArray ret_arr = NULL;
16043         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
16044         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
16045         for (size_t o = 0; o < ret_var.datalen; o++) {
16046                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
16047                 *ret_conv_40_conv = ret_var.data[o];
16048                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
16049         }
16050         
16051         FREE(ret_var.data);
16052         return ret_arr;
16053 }
16054
16055 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
16056         LDKChannelMonitor this_arg_conv;
16057         this_arg_conv.inner = (void*)(this_arg & (~1));
16058         this_arg_conv.is_owned = false;
16059         void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
16060         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
16061         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
16062         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
16063 }
16064
16065 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
16066         LDKChannelMonitor this_arg_conv;
16067         this_arg_conv.inner = (void*)(this_arg & (~1));
16068         this_arg_conv.is_owned = false;
16069         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
16070         uint32_tArray ret_arr = NULL;
16071         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
16072         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
16073         for (size_t o = 0; o < ret_var.datalen; o++) {
16074                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
16075                 *ret_conv_14_copy = ret_var.data[o];
16076                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
16077                 ret_arr_ptr[o] = ret_conv_14_ref;
16078         }
16079         
16080         FREE(ret_var.data);
16081         return ret_arr;
16082 }
16083
16084 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
16085         LDKChannelMonitor this_arg_conv;
16086         this_arg_conv.inner = (void*)(this_arg & (~1));
16087         this_arg_conv.is_owned = false;
16088         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
16089         uint32_tArray ret_arr = NULL;
16090         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
16091         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
16092         for (size_t h = 0; h < ret_var.datalen; h++) {
16093                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16094                 *ret_conv_7_copy = ret_var.data[h];
16095                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
16096                 ret_arr_ptr[h] = ret_conv_7_ref;
16097         }
16098         
16099         FREE(ret_var.data);
16100         return ret_arr;
16101 }
16102
16103 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
16104         LDKChannelMonitor this_arg_conv;
16105         this_arg_conv.inner = (void*)(this_arg & (~1));
16106         this_arg_conv.is_owned = false;
16107         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
16108         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
16109         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
16110         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
16111         ptrArray ret_arr = NULL;
16112         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
16113         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
16114         for (size_t m = 0; m < ret_var.datalen; m++) {
16115                 LDKTransaction ret_conv_12_var = ret_var.data[m];
16116                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16117                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
16118                 Transaction_free(ret_conv_12_var);
16119                 ret_arr_ptr[m] = ret_conv_12_arr;
16120         }
16121         
16122         FREE(ret_var.data);
16123         return ret_arr;
16124 }
16125
16126 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) {
16127         LDKChannelMonitor this_arg_conv;
16128         this_arg_conv.inner = (void*)(this_arg & (~1));
16129         this_arg_conv.is_owned = false;
16130         unsigned char header_arr[80];
16131         CHECK(*((uint32_t*)header) == 80);
16132         memcpy(header_arr, (uint8_t*)(header + 4), 80);
16133         unsigned char (*header_ref)[80] = &header_arr;
16134         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
16135         txdata_constr.datalen = *((uint32_t*)txdata);
16136         if (txdata_constr.datalen > 0)
16137                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
16138         else
16139                 txdata_constr.data = NULL;
16140         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
16141         for (size_t c = 0; c < txdata_constr.datalen; c++) {
16142                 uint32_t txdata_conv_28 = txdata_vals[c];
16143                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
16144                 CHECK_ACCESS(txdata_conv_28_ptr);
16145                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
16146                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
16147                 txdata_constr.data[c] = txdata_conv_28_conv;
16148         }
16149         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
16150         CHECK_ACCESS(broadcaster_ptr);
16151         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
16152         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
16153         CHECK_ACCESS(fee_estimator_ptr);
16154         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
16155         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
16156         CHECK_ACCESS(logger_ptr);
16157         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
16158         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);
16159         uint32_tArray ret_arr = NULL;
16160         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
16161         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
16162         for (size_t n = 0; n < ret_var.datalen; n++) {
16163                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16164                 *ret_conv_39_conv = ret_var.data[n];
16165                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
16166         }
16167         
16168         FREE(ret_var.data);
16169         return ret_arr;
16170 }
16171
16172 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) {
16173         LDKChannelMonitor this_arg_conv;
16174         this_arg_conv.inner = (void*)(this_arg & (~1));
16175         this_arg_conv.is_owned = false;
16176         unsigned char header_arr[80];
16177         CHECK(*((uint32_t*)header) == 80);
16178         memcpy(header_arr, (uint8_t*)(header + 4), 80);
16179         unsigned char (*header_ref)[80] = &header_arr;
16180         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
16181         CHECK_ACCESS(broadcaster_ptr);
16182         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
16183         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
16184         CHECK_ACCESS(fee_estimator_ptr);
16185         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
16186         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
16187         CHECK_ACCESS(logger_ptr);
16188         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
16189         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
16190 }
16191
16192 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) {
16193         LDKChannelMonitor this_arg_conv;
16194         this_arg_conv.inner = (void*)(this_arg & (~1));
16195         this_arg_conv.is_owned = false;
16196         unsigned char header_arr[80];
16197         CHECK(*((uint32_t*)header) == 80);
16198         memcpy(header_arr, (uint8_t*)(header + 4), 80);
16199         unsigned char (*header_ref)[80] = &header_arr;
16200         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
16201         txdata_constr.datalen = *((uint32_t*)txdata);
16202         if (txdata_constr.datalen > 0)
16203                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
16204         else
16205                 txdata_constr.data = NULL;
16206         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
16207         for (size_t c = 0; c < txdata_constr.datalen; c++) {
16208                 uint32_t txdata_conv_28 = txdata_vals[c];
16209                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
16210                 CHECK_ACCESS(txdata_conv_28_ptr);
16211                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
16212                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
16213                 txdata_constr.data[c] = txdata_conv_28_conv;
16214         }
16215         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
16216         CHECK_ACCESS(broadcaster_ptr);
16217         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
16218         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
16219         CHECK_ACCESS(fee_estimator_ptr);
16220         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
16221         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
16222         CHECK_ACCESS(logger_ptr);
16223         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
16224         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);
16225         uint32_tArray ret_arr = NULL;
16226         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
16227         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
16228         for (size_t n = 0; n < ret_var.datalen; n++) {
16229                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16230                 *ret_conv_39_conv = ret_var.data[n];
16231                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
16232         }
16233         
16234         FREE(ret_var.data);
16235         return ret_arr;
16236 }
16237
16238 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) {
16239         LDKChannelMonitor this_arg_conv;
16240         this_arg_conv.inner = (void*)(this_arg & (~1));
16241         this_arg_conv.is_owned = false;
16242         unsigned char txid_arr[32];
16243         CHECK(*((uint32_t*)txid) == 32);
16244         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
16245         unsigned char (*txid_ref)[32] = &txid_arr;
16246         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
16247         CHECK_ACCESS(broadcaster_ptr);
16248         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
16249         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
16250         CHECK_ACCESS(fee_estimator_ptr);
16251         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
16252         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
16253         CHECK_ACCESS(logger_ptr);
16254         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
16255         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
16256 }
16257
16258 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) {
16259         LDKChannelMonitor this_arg_conv;
16260         this_arg_conv.inner = (void*)(this_arg & (~1));
16261         this_arg_conv.is_owned = false;
16262         unsigned char header_arr[80];
16263         CHECK(*((uint32_t*)header) == 80);
16264         memcpy(header_arr, (uint8_t*)(header + 4), 80);
16265         unsigned char (*header_ref)[80] = &header_arr;
16266         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
16267         CHECK_ACCESS(broadcaster_ptr);
16268         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
16269         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
16270         CHECK_ACCESS(fee_estimator_ptr);
16271         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
16272         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
16273         CHECK_ACCESS(logger_ptr);
16274         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
16275         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
16276         uint32_tArray ret_arr = NULL;
16277         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
16278         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
16279         for (size_t n = 0; n < ret_var.datalen; n++) {
16280                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16281                 *ret_conv_39_conv = ret_var.data[n];
16282                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
16283         }
16284         
16285         FREE(ret_var.data);
16286         return ret_arr;
16287 }
16288
16289 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
16290         LDKChannelMonitor this_arg_conv;
16291         this_arg_conv.inner = (void*)(this_arg & (~1));
16292         this_arg_conv.is_owned = false;
16293         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
16294         ptrArray ret_arr = NULL;
16295         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
16296         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
16297         for (size_t m = 0; m < ret_var.datalen; m++) {
16298                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16299                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
16300                 ret_arr_ptr[m] = ret_conv_12_arr;
16301         }
16302         
16303         FREE(ret_var.data);
16304         return ret_arr;
16305 }
16306
16307 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
16308         LDKChannelMonitor this_arg_conv;
16309         this_arg_conv.inner = (void*)(this_arg & (~1));
16310         this_arg_conv.is_owned = false;
16311         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
16312         uint64_t ret_ref = 0;
16313         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16314         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16315         ret_ref = (uint64_t)ret_var.inner;
16316         if (ret_var.is_owned) {
16317                 ret_ref |= 1;
16318         }
16319         return ret_ref;
16320 }
16321
16322 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
16323         LDKChannelMonitor this_arg_conv;
16324         this_arg_conv.inner = (void*)(this_arg & (~1));
16325         this_arg_conv.is_owned = false;
16326         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
16327         uint32_tArray ret_arr = NULL;
16328         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
16329         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
16330         for (size_t j = 0; j < ret_var.datalen; j++) {
16331                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
16332                 *ret_conv_9_copy = ret_var.data[j];
16333                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
16334                 ret_arr_ptr[j] = ret_conv_9_ref;
16335         }
16336         
16337         FREE(ret_var.data);
16338         return ret_arr;
16339 }
16340
16341 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
16342         LDKu8slice ser_ref;
16343         ser_ref.datalen = *((uint32_t*)ser);
16344         ser_ref.data = (int8_t*)(ser + 4);
16345         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
16346         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
16347         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
16348         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16349         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
16350         return (uint64_t)ret_conv;
16351 }
16352
16353 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
16354         LDKOutPoint this_obj_conv;
16355         this_obj_conv.inner = (void*)(this_obj & (~1));
16356         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16357         OutPoint_free(this_obj_conv);
16358 }
16359
16360 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
16361         LDKOutPoint this_ptr_conv;
16362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16363         this_ptr_conv.is_owned = false;
16364         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16365         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
16366         return ret_arr;
16367 }
16368
16369 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
16370         LDKOutPoint this_ptr_conv;
16371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16372         this_ptr_conv.is_owned = false;
16373         LDKThirtyTwoBytes val_ref;
16374         CHECK(*((uint32_t*)val) == 32);
16375         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16376         OutPoint_set_txid(&this_ptr_conv, val_ref);
16377 }
16378
16379 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
16380         LDKOutPoint this_ptr_conv;
16381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16382         this_ptr_conv.is_owned = false;
16383         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
16384         return ret_val;
16385 }
16386
16387 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
16388         LDKOutPoint this_ptr_conv;
16389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16390         this_ptr_conv.is_owned = false;
16391         OutPoint_set_index(&this_ptr_conv, val);
16392 }
16393
16394 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
16395         LDKThirtyTwoBytes txid_arg_ref;
16396         CHECK(*((uint32_t*)txid_arg) == 32);
16397         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
16398         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
16399         uint64_t ret_ref = 0;
16400         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16401         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16402         ret_ref = (uint64_t)ret_var.inner;
16403         if (ret_var.is_owned) {
16404                 ret_ref |= 1;
16405         }
16406         return ret_ref;
16407 }
16408
16409 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
16410         LDKOutPoint orig_conv;
16411         orig_conv.inner = (void*)(orig & (~1));
16412         orig_conv.is_owned = false;
16413         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
16414         uint64_t ret_ref = 0;
16415         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16416         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16417         ret_ref = (uint64_t)ret_var.inner;
16418         if (ret_var.is_owned) {
16419                 ret_ref |= 1;
16420         }
16421         return ret_ref;
16422 }
16423
16424 jboolean  __attribute__((visibility("default"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
16425         LDKOutPoint a_conv;
16426         a_conv.inner = (void*)(a & (~1));
16427         a_conv.is_owned = false;
16428         LDKOutPoint b_conv;
16429         b_conv.inner = (void*)(b & (~1));
16430         b_conv.is_owned = false;
16431         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
16432         return ret_val;
16433 }
16434
16435 int64_t  __attribute__((visibility("default"))) TS_OutPoint_hash(uint32_t o) {
16436         LDKOutPoint o_conv;
16437         o_conv.inner = (void*)(o & (~1));
16438         o_conv.is_owned = false;
16439         int64_t ret_val = OutPoint_hash(&o_conv);
16440         return ret_val;
16441 }
16442
16443 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
16444         LDKOutPoint this_arg_conv;
16445         this_arg_conv.inner = (void*)(this_arg & (~1));
16446         this_arg_conv.is_owned = false;
16447         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16448         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
16449         return ret_arr;
16450 }
16451
16452 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
16453         LDKOutPoint obj_conv;
16454         obj_conv.inner = (void*)(obj & (~1));
16455         obj_conv.is_owned = false;
16456         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
16457         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16458         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16459         CVec_u8Z_free(ret_var);
16460         return ret_arr;
16461 }
16462
16463 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
16464         LDKu8slice ser_ref;
16465         ser_ref.datalen = *((uint32_t*)ser);
16466         ser_ref.data = (int8_t*)(ser + 4);
16467         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16468         *ret_conv = OutPoint_read(ser_ref);
16469         return (uint64_t)ret_conv;
16470 }
16471
16472 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
16473         LDKDelayedPaymentOutputDescriptor this_obj_conv;
16474         this_obj_conv.inner = (void*)(this_obj & (~1));
16475         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16476         DelayedPaymentOutputDescriptor_free(this_obj_conv);
16477 }
16478
16479 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
16480         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16482         this_ptr_conv.is_owned = false;
16483         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
16484         uint64_t ret_ref = 0;
16485         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16486         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16487         ret_ref = (uint64_t)ret_var.inner;
16488         if (ret_var.is_owned) {
16489                 ret_ref |= 1;
16490         }
16491         return ret_ref;
16492 }
16493
16494 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
16495         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16497         this_ptr_conv.is_owned = false;
16498         LDKOutPoint val_conv;
16499         val_conv.inner = (void*)(val & (~1));
16500         val_conv.is_owned = (val & 1) || (val == 0);
16501         val_conv = OutPoint_clone(&val_conv);
16502         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
16503 }
16504
16505 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
16506         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16508         this_ptr_conv.is_owned = false;
16509         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16510         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
16511         return ret_arr;
16512 }
16513
16514 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
16515         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16517         this_ptr_conv.is_owned = false;
16518         LDKPublicKey val_ref;
16519         CHECK(*((uint32_t*)val) == 33);
16520         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16521         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
16522 }
16523
16524 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
16525         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16527         this_ptr_conv.is_owned = false;
16528         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
16529         return ret_val;
16530 }
16531
16532 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
16533         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16535         this_ptr_conv.is_owned = false;
16536         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
16537 }
16538
16539 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
16540         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16542         this_ptr_conv.is_owned = false;
16543         void* val_ptr = (void*)(((uint64_t)val) & ~1);
16544         CHECK_ACCESS(val_ptr);
16545         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
16546         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
16547         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
16548 }
16549
16550 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
16551         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16553         this_ptr_conv.is_owned = false;
16554         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16555         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
16556         return ret_arr;
16557 }
16558
16559 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
16560         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16562         this_ptr_conv.is_owned = false;
16563         LDKPublicKey val_ref;
16564         CHECK(*((uint32_t*)val) == 33);
16565         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16566         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
16567 }
16568
16569 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
16570         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16572         this_ptr_conv.is_owned = false;
16573         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16574         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
16575         return ret_arr;
16576 }
16577
16578 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
16579         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16581         this_ptr_conv.is_owned = false;
16582         LDKThirtyTwoBytes val_ref;
16583         CHECK(*((uint32_t*)val) == 32);
16584         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16585         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
16586 }
16587
16588 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
16589         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16591         this_ptr_conv.is_owned = false;
16592         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
16593         return ret_val;
16594 }
16595
16596 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
16597         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
16598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16599         this_ptr_conv.is_owned = false;
16600         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
16601 }
16602
16603 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) {
16604         LDKOutPoint outpoint_arg_conv;
16605         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
16606         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
16607         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
16608         LDKPublicKey per_commitment_point_arg_ref;
16609         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
16610         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
16611         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
16612         CHECK_ACCESS(output_arg_ptr);
16613         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
16614         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
16615         LDKPublicKey revocation_pubkey_arg_ref;
16616         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
16617         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
16618         LDKThirtyTwoBytes channel_keys_id_arg_ref;
16619         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
16620         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
16621         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);
16622         uint64_t ret_ref = 0;
16623         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16624         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16625         ret_ref = (uint64_t)ret_var.inner;
16626         if (ret_var.is_owned) {
16627                 ret_ref |= 1;
16628         }
16629         return ret_ref;
16630 }
16631
16632 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
16633         LDKDelayedPaymentOutputDescriptor orig_conv;
16634         orig_conv.inner = (void*)(orig & (~1));
16635         orig_conv.is_owned = false;
16636         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
16637         uint64_t ret_ref = 0;
16638         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16639         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16640         ret_ref = (uint64_t)ret_var.inner;
16641         if (ret_var.is_owned) {
16642                 ret_ref |= 1;
16643         }
16644         return ret_ref;
16645 }
16646
16647 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
16648         LDKDelayedPaymentOutputDescriptor obj_conv;
16649         obj_conv.inner = (void*)(obj & (~1));
16650         obj_conv.is_owned = false;
16651         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
16652         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16653         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16654         CVec_u8Z_free(ret_var);
16655         return ret_arr;
16656 }
16657
16658 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
16659         LDKu8slice ser_ref;
16660         ser_ref.datalen = *((uint32_t*)ser);
16661         ser_ref.data = (int8_t*)(ser + 4);
16662         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16663         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
16664         return (uint64_t)ret_conv;
16665 }
16666
16667 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
16668         LDKStaticPaymentOutputDescriptor this_obj_conv;
16669         this_obj_conv.inner = (void*)(this_obj & (~1));
16670         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16671         StaticPaymentOutputDescriptor_free(this_obj_conv);
16672 }
16673
16674 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
16675         LDKStaticPaymentOutputDescriptor this_ptr_conv;
16676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16677         this_ptr_conv.is_owned = false;
16678         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
16679         uint64_t ret_ref = 0;
16680         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16681         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16682         ret_ref = (uint64_t)ret_var.inner;
16683         if (ret_var.is_owned) {
16684                 ret_ref |= 1;
16685         }
16686         return ret_ref;
16687 }
16688
16689 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
16690         LDKStaticPaymentOutputDescriptor this_ptr_conv;
16691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16692         this_ptr_conv.is_owned = false;
16693         LDKOutPoint val_conv;
16694         val_conv.inner = (void*)(val & (~1));
16695         val_conv.is_owned = (val & 1) || (val == 0);
16696         val_conv = OutPoint_clone(&val_conv);
16697         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
16698 }
16699
16700 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
16701         LDKStaticPaymentOutputDescriptor this_ptr_conv;
16702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16703         this_ptr_conv.is_owned = false;
16704         void* val_ptr = (void*)(((uint64_t)val) & ~1);
16705         CHECK_ACCESS(val_ptr);
16706         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
16707         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
16708         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
16709 }
16710
16711 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
16712         LDKStaticPaymentOutputDescriptor this_ptr_conv;
16713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16714         this_ptr_conv.is_owned = false;
16715         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16716         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
16717         return ret_arr;
16718 }
16719
16720 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
16721         LDKStaticPaymentOutputDescriptor this_ptr_conv;
16722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16723         this_ptr_conv.is_owned = false;
16724         LDKThirtyTwoBytes val_ref;
16725         CHECK(*((uint32_t*)val) == 32);
16726         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16727         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
16728 }
16729
16730 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
16731         LDKStaticPaymentOutputDescriptor this_ptr_conv;
16732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16733         this_ptr_conv.is_owned = false;
16734         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
16735         return ret_val;
16736 }
16737
16738 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
16739         LDKStaticPaymentOutputDescriptor this_ptr_conv;
16740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16741         this_ptr_conv.is_owned = false;
16742         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
16743 }
16744
16745 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) {
16746         LDKOutPoint outpoint_arg_conv;
16747         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
16748         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
16749         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
16750         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
16751         CHECK_ACCESS(output_arg_ptr);
16752         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
16753         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
16754         LDKThirtyTwoBytes channel_keys_id_arg_ref;
16755         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
16756         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
16757         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
16758         uint64_t ret_ref = 0;
16759         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16760         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16761         ret_ref = (uint64_t)ret_var.inner;
16762         if (ret_var.is_owned) {
16763                 ret_ref |= 1;
16764         }
16765         return ret_ref;
16766 }
16767
16768 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
16769         LDKStaticPaymentOutputDescriptor orig_conv;
16770         orig_conv.inner = (void*)(orig & (~1));
16771         orig_conv.is_owned = false;
16772         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
16773         uint64_t ret_ref = 0;
16774         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16775         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16776         ret_ref = (uint64_t)ret_var.inner;
16777         if (ret_var.is_owned) {
16778                 ret_ref |= 1;
16779         }
16780         return ret_ref;
16781 }
16782
16783 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
16784         LDKStaticPaymentOutputDescriptor obj_conv;
16785         obj_conv.inner = (void*)(obj & (~1));
16786         obj_conv.is_owned = false;
16787         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
16788         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16789         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16790         CVec_u8Z_free(ret_var);
16791         return ret_arr;
16792 }
16793
16794 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
16795         LDKu8slice ser_ref;
16796         ser_ref.datalen = *((uint32_t*)ser);
16797         ser_ref.data = (int8_t*)(ser + 4);
16798         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16799         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
16800         return (uint64_t)ret_conv;
16801 }
16802
16803 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
16804         if ((this_ptr & 1) != 0) return;
16805         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16806         CHECK_ACCESS(this_ptr_ptr);
16807         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
16808         FREE((void*)this_ptr);
16809         SpendableOutputDescriptor_free(this_ptr_conv);
16810 }
16811
16812 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
16813         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
16814         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
16815         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
16816         uint64_t ret_ref = (uint64_t)ret_copy;
16817         return ret_ref;
16818 }
16819
16820 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
16821         LDKOutPoint outpoint_conv;
16822         outpoint_conv.inner = (void*)(outpoint & (~1));
16823         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
16824         outpoint_conv = OutPoint_clone(&outpoint_conv);
16825         void* output_ptr = (void*)(((uint64_t)output) & ~1);
16826         CHECK_ACCESS(output_ptr);
16827         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
16828         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
16829         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
16830         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
16831         uint64_t ret_ref = (uint64_t)ret_copy;
16832         return ret_ref;
16833 }
16834
16835 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
16836         LDKDelayedPaymentOutputDescriptor a_conv;
16837         a_conv.inner = (void*)(a & (~1));
16838         a_conv.is_owned = (a & 1) || (a == 0);
16839         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
16840         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
16841         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
16842         uint64_t ret_ref = (uint64_t)ret_copy;
16843         return ret_ref;
16844 }
16845
16846 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
16847         LDKStaticPaymentOutputDescriptor a_conv;
16848         a_conv.inner = (void*)(a & (~1));
16849         a_conv.is_owned = (a & 1) || (a == 0);
16850         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
16851         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
16852         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
16853         uint64_t ret_ref = (uint64_t)ret_copy;
16854         return ret_ref;
16855 }
16856
16857 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
16858         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
16859         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
16860         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16861         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16862         CVec_u8Z_free(ret_var);
16863         return ret_arr;
16864 }
16865
16866 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
16867         LDKu8slice ser_ref;
16868         ser_ref.datalen = *((uint32_t*)ser);
16869         ser_ref.data = (int8_t*)(ser + 4);
16870         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16871         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
16872         return (uint64_t)ret_conv;
16873 }
16874
16875 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
16876         if ((this_ptr & 1) != 0) return;
16877         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16878         CHECK_ACCESS(this_ptr_ptr);
16879         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
16880         FREE((void*)this_ptr);
16881         BaseSign_free(this_ptr_conv);
16882 }
16883
16884 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
16885         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
16886         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
16887         LDKSign* orig_conv = (LDKSign*)orig_ptr;
16888         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
16889         *ret_ret = Sign_clone(orig_conv);
16890         return (uint64_t)ret_ret;
16891 }
16892
16893 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
16894         if ((this_ptr & 1) != 0) return;
16895         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16896         CHECK_ACCESS(this_ptr_ptr);
16897         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
16898         FREE((void*)this_ptr);
16899         Sign_free(this_ptr_conv);
16900 }
16901
16902 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
16903         if ((this_ptr & 1) != 0) return;
16904         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16905         CHECK_ACCESS(this_ptr_ptr);
16906         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
16907         FREE((void*)this_ptr);
16908         KeysInterface_free(this_ptr_conv);
16909 }
16910
16911 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
16912         LDKInMemorySigner this_obj_conv;
16913         this_obj_conv.inner = (void*)(this_obj & (~1));
16914         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16915         InMemorySigner_free(this_obj_conv);
16916 }
16917
16918 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
16919         LDKInMemorySigner this_ptr_conv;
16920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16921         this_ptr_conv.is_owned = false;
16922         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16923         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
16924         return ret_arr;
16925 }
16926
16927 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
16928         LDKInMemorySigner this_ptr_conv;
16929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16930         this_ptr_conv.is_owned = false;
16931         LDKSecretKey val_ref;
16932         CHECK(*((uint32_t*)val) == 32);
16933         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
16934         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
16935 }
16936
16937 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
16938         LDKInMemorySigner this_ptr_conv;
16939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16940         this_ptr_conv.is_owned = false;
16941         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16942         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
16943         return ret_arr;
16944 }
16945
16946 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
16947         LDKInMemorySigner this_ptr_conv;
16948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16949         this_ptr_conv.is_owned = false;
16950         LDKSecretKey val_ref;
16951         CHECK(*((uint32_t*)val) == 32);
16952         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
16953         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
16954 }
16955
16956 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
16957         LDKInMemorySigner this_ptr_conv;
16958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16959         this_ptr_conv.is_owned = false;
16960         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16961         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
16962         return ret_arr;
16963 }
16964
16965 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
16966         LDKInMemorySigner this_ptr_conv;
16967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16968         this_ptr_conv.is_owned = false;
16969         LDKSecretKey val_ref;
16970         CHECK(*((uint32_t*)val) == 32);
16971         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
16972         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
16973 }
16974
16975 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
16976         LDKInMemorySigner this_ptr_conv;
16977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16978         this_ptr_conv.is_owned = false;
16979         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16980         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
16981         return ret_arr;
16982 }
16983
16984 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
16985         LDKInMemorySigner this_ptr_conv;
16986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16987         this_ptr_conv.is_owned = false;
16988         LDKSecretKey val_ref;
16989         CHECK(*((uint32_t*)val) == 32);
16990         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
16991         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
16992 }
16993
16994 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
16995         LDKInMemorySigner this_ptr_conv;
16996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16997         this_ptr_conv.is_owned = false;
16998         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16999         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
17000         return ret_arr;
17001 }
17002
17003 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
17004         LDKInMemorySigner this_ptr_conv;
17005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17006         this_ptr_conv.is_owned = false;
17007         LDKSecretKey val_ref;
17008         CHECK(*((uint32_t*)val) == 32);
17009         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
17010         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
17011 }
17012
17013 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
17014         LDKInMemorySigner 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), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
17019         return ret_arr;
17020 }
17021
17022 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
17023         LDKInMemorySigner 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         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
17030 }
17031
17032 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
17033         LDKInMemorySigner orig_conv;
17034         orig_conv.inner = (void*)(orig & (~1));
17035         orig_conv.is_owned = false;
17036         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
17037         uint64_t ret_ref = 0;
17038         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17039         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17040         ret_ref = (uint64_t)ret_var.inner;
17041         if (ret_var.is_owned) {
17042                 ret_ref |= 1;
17043         }
17044         return ret_ref;
17045 }
17046
17047 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) {
17048         LDKSecretKey funding_key_ref;
17049         CHECK(*((uint32_t*)funding_key) == 32);
17050         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
17051         LDKSecretKey revocation_base_key_ref;
17052         CHECK(*((uint32_t*)revocation_base_key) == 32);
17053         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
17054         LDKSecretKey payment_key_ref;
17055         CHECK(*((uint32_t*)payment_key) == 32);
17056         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
17057         LDKSecretKey delayed_payment_base_key_ref;
17058         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
17059         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
17060         LDKSecretKey htlc_base_key_ref;
17061         CHECK(*((uint32_t*)htlc_base_key) == 32);
17062         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
17063         LDKThirtyTwoBytes commitment_seed_ref;
17064         CHECK(*((uint32_t*)commitment_seed) == 32);
17065         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
17066         LDKThirtyTwoBytes channel_keys_id_ref;
17067         CHECK(*((uint32_t*)channel_keys_id) == 32);
17068         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
17069         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);
17070         uint64_t ret_ref = 0;
17071         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17072         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17073         ret_ref = (uint64_t)ret_var.inner;
17074         if (ret_var.is_owned) {
17075                 ret_ref |= 1;
17076         }
17077         return ret_ref;
17078 }
17079
17080 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
17081         LDKInMemorySigner this_arg_conv;
17082         this_arg_conv.inner = (void*)(this_arg & (~1));
17083         this_arg_conv.is_owned = false;
17084         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
17085         uint64_t ret_ref = 0;
17086         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17087         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17088         ret_ref = (uint64_t)ret_var.inner;
17089         if (ret_var.is_owned) {
17090                 ret_ref |= 1;
17091         }
17092         return ret_ref;
17093 }
17094
17095 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
17096         LDKInMemorySigner this_arg_conv;
17097         this_arg_conv.inner = (void*)(this_arg & (~1));
17098         this_arg_conv.is_owned = false;
17099         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
17100         return ret_val;
17101 }
17102
17103 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
17104         LDKInMemorySigner this_arg_conv;
17105         this_arg_conv.inner = (void*)(this_arg & (~1));
17106         this_arg_conv.is_owned = false;
17107         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
17108         return ret_val;
17109 }
17110
17111 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
17112         LDKInMemorySigner this_arg_conv;
17113         this_arg_conv.inner = (void*)(this_arg & (~1));
17114         this_arg_conv.is_owned = false;
17115         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
17116         return ret_val;
17117 }
17118
17119 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
17120         LDKInMemorySigner this_arg_conv;
17121         this_arg_conv.inner = (void*)(this_arg & (~1));
17122         this_arg_conv.is_owned = false;
17123         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
17124         uint64_t ret_ref = 0;
17125         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17126         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17127         ret_ref = (uint64_t)ret_var.inner;
17128         if (ret_var.is_owned) {
17129                 ret_ref |= 1;
17130         }
17131         return ret_ref;
17132 }
17133
17134 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
17135         LDKInMemorySigner this_arg_conv;
17136         this_arg_conv.inner = (void*)(this_arg & (~1));
17137         this_arg_conv.is_owned = false;
17138         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
17139         uint64_t ret_ref = 0;
17140         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17141         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17142         ret_ref = (uint64_t)ret_var.inner;
17143         if (ret_var.is_owned) {
17144                 ret_ref |= 1;
17145         }
17146         return ret_ref;
17147 }
17148
17149 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) {
17150         LDKInMemorySigner this_arg_conv;
17151         this_arg_conv.inner = (void*)(this_arg & (~1));
17152         this_arg_conv.is_owned = false;
17153         LDKTransaction spend_tx_ref;
17154         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
17155         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
17156         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
17157         spend_tx_ref.data_is_owned = true;
17158         LDKStaticPaymentOutputDescriptor descriptor_conv;
17159         descriptor_conv.inner = (void*)(descriptor & (~1));
17160         descriptor_conv.is_owned = false;
17161         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17162         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
17163         return (uint64_t)ret_conv;
17164 }
17165
17166 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) {
17167         LDKInMemorySigner this_arg_conv;
17168         this_arg_conv.inner = (void*)(this_arg & (~1));
17169         this_arg_conv.is_owned = false;
17170         LDKTransaction spend_tx_ref;
17171         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
17172         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
17173         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
17174         spend_tx_ref.data_is_owned = true;
17175         LDKDelayedPaymentOutputDescriptor descriptor_conv;
17176         descriptor_conv.inner = (void*)(descriptor & (~1));
17177         descriptor_conv.is_owned = false;
17178         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17179         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
17180         return (uint64_t)ret_conv;
17181 }
17182
17183 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
17184         LDKInMemorySigner this_arg_conv;
17185         this_arg_conv.inner = (void*)(this_arg & (~1));
17186         this_arg_conv.is_owned = false;
17187         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
17188         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
17189         return (uint64_t)ret_ret;
17190 }
17191
17192 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
17193         LDKInMemorySigner this_arg_conv;
17194         this_arg_conv.inner = (void*)(this_arg & (~1));
17195         this_arg_conv.is_owned = false;
17196         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
17197         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
17198         return (uint64_t)ret_ret;
17199 }
17200
17201 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
17202         LDKInMemorySigner obj_conv;
17203         obj_conv.inner = (void*)(obj & (~1));
17204         obj_conv.is_owned = false;
17205         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
17206         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17207         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17208         CVec_u8Z_free(ret_var);
17209         return ret_arr;
17210 }
17211
17212 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
17213         LDKu8slice ser_ref;
17214         ser_ref.datalen = *((uint32_t*)ser);
17215         ser_ref.data = (int8_t*)(ser + 4);
17216         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17217         *ret_conv = InMemorySigner_read(ser_ref);
17218         return (uint64_t)ret_conv;
17219 }
17220
17221 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
17222         LDKKeysManager this_obj_conv;
17223         this_obj_conv.inner = (void*)(this_obj & (~1));
17224         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17225         KeysManager_free(this_obj_conv);
17226 }
17227
17228 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
17229         unsigned char seed_arr[32];
17230         CHECK(*((uint32_t*)seed) == 32);
17231         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
17232         unsigned char (*seed_ref)[32] = &seed_arr;
17233         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
17234         uint64_t ret_ref = 0;
17235         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17236         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17237         ret_ref = (uint64_t)ret_var.inner;
17238         if (ret_var.is_owned) {
17239                 ret_ref |= 1;
17240         }
17241         return ret_ref;
17242 }
17243
17244 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
17245         LDKKeysManager this_arg_conv;
17246         this_arg_conv.inner = (void*)(this_arg & (~1));
17247         this_arg_conv.is_owned = false;
17248         unsigned char params_arr[32];
17249         CHECK(*((uint32_t*)params) == 32);
17250         memcpy(params_arr, (uint8_t*)(params + 4), 32);
17251         unsigned char (*params_ref)[32] = &params_arr;
17252         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
17253         uint64_t ret_ref = 0;
17254         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17255         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17256         ret_ref = (uint64_t)ret_var.inner;
17257         if (ret_var.is_owned) {
17258                 ret_ref |= 1;
17259         }
17260         return ret_ref;
17261 }
17262
17263 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) {
17264         LDKKeysManager this_arg_conv;
17265         this_arg_conv.inner = (void*)(this_arg & (~1));
17266         this_arg_conv.is_owned = false;
17267         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
17268         descriptors_constr.datalen = *((uint32_t*)descriptors);
17269         if (descriptors_constr.datalen > 0)
17270                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
17271         else
17272                 descriptors_constr.data = NULL;
17273         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
17274         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
17275                 uint32_t descriptors_conv_27 = descriptors_vals[b];
17276                 void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
17277                 CHECK_ACCESS(descriptors_conv_27_ptr);
17278                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
17279                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
17280                 descriptors_constr.data[b] = descriptors_conv_27_conv;
17281         }
17282         LDKCVec_TxOutZ outputs_constr;
17283         outputs_constr.datalen = *((uint32_t*)outputs);
17284         if (outputs_constr.datalen > 0)
17285                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
17286         else
17287                 outputs_constr.data = NULL;
17288         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
17289         for (size_t h = 0; h < outputs_constr.datalen; h++) {
17290                 uint32_t outputs_conv_7 = outputs_vals[h];
17291                 void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
17292                 CHECK_ACCESS(outputs_conv_7_ptr);
17293                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
17294                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
17295                 outputs_constr.data[h] = outputs_conv_7_conv;
17296         }
17297         LDKCVec_u8Z change_destination_script_ref;
17298         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
17299         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
17300         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
17301         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17302         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
17303         return (uint64_t)ret_conv;
17304 }
17305
17306 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
17307         LDKKeysManager this_arg_conv;
17308         this_arg_conv.inner = (void*)(this_arg & (~1));
17309         this_arg_conv.is_owned = false;
17310         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
17311         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
17312         return (uint64_t)ret_ret;
17313 }
17314
17315 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
17316         LDKChannelManager this_obj_conv;
17317         this_obj_conv.inner = (void*)(this_obj & (~1));
17318         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17319         ChannelManager_free(this_obj_conv);
17320 }
17321
17322 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
17323         LDKChainParameters this_obj_conv;
17324         this_obj_conv.inner = (void*)(this_obj & (~1));
17325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17326         ChainParameters_free(this_obj_conv);
17327 }
17328
17329 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
17330         LDKChainParameters this_ptr_conv;
17331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17332         this_ptr_conv.is_owned = false;
17333         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
17334         return ret_conv;
17335 }
17336
17337 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
17338         LDKChainParameters this_ptr_conv;
17339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17340         this_ptr_conv.is_owned = false;
17341         LDKNetwork val_conv = LDKNetwork_from_js(val);
17342         ChainParameters_set_network(&this_ptr_conv, val_conv);
17343 }
17344
17345 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
17346         LDKChainParameters this_ptr_conv;
17347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17348         this_ptr_conv.is_owned = false;
17349         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
17350         uint64_t ret_ref = 0;
17351         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17352         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17353         ret_ref = (uint64_t)ret_var.inner;
17354         if (ret_var.is_owned) {
17355                 ret_ref |= 1;
17356         }
17357         return ret_ref;
17358 }
17359
17360 void  __attribute__((visibility("default"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
17361         LDKChainParameters this_ptr_conv;
17362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17363         this_ptr_conv.is_owned = false;
17364         LDKBestBlock val_conv;
17365         val_conv.inner = (void*)(val & (~1));
17366         val_conv.is_owned = (val & 1) || (val == 0);
17367         val_conv = BestBlock_clone(&val_conv);
17368         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
17369 }
17370
17371 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
17372         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
17373         LDKBestBlock best_block_arg_conv;
17374         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
17375         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
17376         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
17377         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
17378         uint64_t ret_ref = 0;
17379         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17380         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17381         ret_ref = (uint64_t)ret_var.inner;
17382         if (ret_var.is_owned) {
17383                 ret_ref |= 1;
17384         }
17385         return ret_ref;
17386 }
17387
17388 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32_t orig) {
17389         LDKChainParameters orig_conv;
17390         orig_conv.inner = (void*)(orig & (~1));
17391         orig_conv.is_owned = false;
17392         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
17393         uint64_t ret_ref = 0;
17394         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17395         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17396         ret_ref = (uint64_t)ret_var.inner;
17397         if (ret_var.is_owned) {
17398                 ret_ref |= 1;
17399         }
17400         return ret_ref;
17401 }
17402
17403 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
17404         LDKCounterpartyForwardingInfo this_obj_conv;
17405         this_obj_conv.inner = (void*)(this_obj & (~1));
17406         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17407         CounterpartyForwardingInfo_free(this_obj_conv);
17408 }
17409
17410 int32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
17411         LDKCounterpartyForwardingInfo this_ptr_conv;
17412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17413         this_ptr_conv.is_owned = false;
17414         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
17415         return ret_val;
17416 }
17417
17418 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
17419         LDKCounterpartyForwardingInfo this_ptr_conv;
17420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17421         this_ptr_conv.is_owned = false;
17422         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
17423 }
17424
17425 int32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
17426         LDKCounterpartyForwardingInfo this_ptr_conv;
17427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17428         this_ptr_conv.is_owned = false;
17429         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
17430         return ret_val;
17431 }
17432
17433 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
17434         LDKCounterpartyForwardingInfo this_ptr_conv;
17435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17436         this_ptr_conv.is_owned = false;
17437         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
17438 }
17439
17440 int16_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
17441         LDKCounterpartyForwardingInfo this_ptr_conv;
17442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17443         this_ptr_conv.is_owned = false;
17444         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
17445         return ret_val;
17446 }
17447
17448 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
17449         LDKCounterpartyForwardingInfo this_ptr_conv;
17450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17451         this_ptr_conv.is_owned = false;
17452         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
17453 }
17454
17455 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) {
17456         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
17457         uint64_t ret_ref = 0;
17458         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17459         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17460         ret_ref = (uint64_t)ret_var.inner;
17461         if (ret_var.is_owned) {
17462                 ret_ref |= 1;
17463         }
17464         return ret_ref;
17465 }
17466
17467 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
17468         LDKCounterpartyForwardingInfo orig_conv;
17469         orig_conv.inner = (void*)(orig & (~1));
17470         orig_conv.is_owned = false;
17471         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
17472         uint64_t ret_ref = 0;
17473         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17474         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17475         ret_ref = (uint64_t)ret_var.inner;
17476         if (ret_var.is_owned) {
17477                 ret_ref |= 1;
17478         }
17479         return ret_ref;
17480 }
17481
17482 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
17483         LDKChannelCounterparty this_obj_conv;
17484         this_obj_conv.inner = (void*)(this_obj & (~1));
17485         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17486         ChannelCounterparty_free(this_obj_conv);
17487 }
17488
17489 int8_tArray  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
17490         LDKChannelCounterparty this_ptr_conv;
17491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17492         this_ptr_conv.is_owned = false;
17493         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17494         memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
17495         return ret_arr;
17496 }
17497
17498 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
17499         LDKChannelCounterparty this_ptr_conv;
17500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17501         this_ptr_conv.is_owned = false;
17502         LDKPublicKey val_ref;
17503         CHECK(*((uint32_t*)val) == 33);
17504         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17505         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
17506 }
17507
17508 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
17509         LDKChannelCounterparty this_ptr_conv;
17510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17511         this_ptr_conv.is_owned = false;
17512         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
17513         uint64_t ret_ref = 0;
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         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_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
17524         LDKChannelCounterparty this_ptr_conv;
17525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17526         this_ptr_conv.is_owned = false;
17527         LDKInitFeatures val_conv;
17528         val_conv.inner = (void*)(val & (~1));
17529         val_conv.is_owned = (val & 1) || (val == 0);
17530         val_conv = InitFeatures_clone(&val_conv);
17531         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
17532 }
17533
17534 int64_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
17535         LDKChannelCounterparty this_ptr_conv;
17536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17537         this_ptr_conv.is_owned = false;
17538         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
17539         return ret_val;
17540 }
17541
17542 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
17543         LDKChannelCounterparty this_ptr_conv;
17544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17545         this_ptr_conv.is_owned = false;
17546         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
17547 }
17548
17549 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
17550         LDKChannelCounterparty this_ptr_conv;
17551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17552         this_ptr_conv.is_owned = false;
17553         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
17554         uint64_t ret_ref = 0;
17555         if ((uint64_t)ret_var.inner > 4096) {
17556                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17557                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17558                 ret_ref = (uint64_t)ret_var.inner;
17559                 if (ret_var.is_owned) {
17560                         ret_ref |= 1;
17561                 }
17562         }
17563         return ret_ref;
17564 }
17565
17566 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
17567         LDKChannelCounterparty this_ptr_conv;
17568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17569         this_ptr_conv.is_owned = false;
17570         LDKCounterpartyForwardingInfo val_conv;
17571         val_conv.inner = (void*)(val & (~1));
17572         val_conv.is_owned = (val & 1) || (val == 0);
17573         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
17574         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
17575 }
17576
17577 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) {
17578         LDKPublicKey node_id_arg_ref;
17579         CHECK(*((uint32_t*)node_id_arg) == 33);
17580         memcpy(node_id_arg_ref.compressed_form, (uint8_t*)(node_id_arg + 4), 33);
17581         LDKInitFeatures features_arg_conv;
17582         features_arg_conv.inner = (void*)(features_arg & (~1));
17583         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
17584         features_arg_conv = InitFeatures_clone(&features_arg_conv);
17585         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
17586         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
17587         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
17588         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
17589         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
17590         uint64_t ret_ref = 0;
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         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_ChannelCounterparty_clone(uint32_t orig) {
17601         LDKChannelCounterparty orig_conv;
17602         orig_conv.inner = (void*)(orig & (~1));
17603         orig_conv.is_owned = false;
17604         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
17605         uint64_t ret_ref = 0;
17606         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17607         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17608         ret_ref = (uint64_t)ret_var.inner;
17609         if (ret_var.is_owned) {
17610                 ret_ref |= 1;
17611         }
17612         return ret_ref;
17613 }
17614
17615 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
17616         LDKChannelDetails this_obj_conv;
17617         this_obj_conv.inner = (void*)(this_obj & (~1));
17618         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17619         ChannelDetails_free(this_obj_conv);
17620 }
17621
17622 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
17623         LDKChannelDetails this_ptr_conv;
17624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17625         this_ptr_conv.is_owned = false;
17626         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17627         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
17628         return ret_arr;
17629 }
17630
17631 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17632         LDKChannelDetails this_ptr_conv;
17633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17634         this_ptr_conv.is_owned = false;
17635         LDKThirtyTwoBytes val_ref;
17636         CHECK(*((uint32_t*)val) == 32);
17637         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17638         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
17639 }
17640
17641 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
17642         LDKChannelDetails this_ptr_conv;
17643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17644         this_ptr_conv.is_owned = false;
17645         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
17646         uint64_t ret_ref = 0;
17647         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17648         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17649         ret_ref = (uint64_t)ret_var.inner;
17650         if (ret_var.is_owned) {
17651                 ret_ref |= 1;
17652         }
17653         return ret_ref;
17654 }
17655
17656 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
17657         LDKChannelDetails this_ptr_conv;
17658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17659         this_ptr_conv.is_owned = false;
17660         LDKChannelCounterparty val_conv;
17661         val_conv.inner = (void*)(val & (~1));
17662         val_conv.is_owned = (val & 1) || (val == 0);
17663         val_conv = ChannelCounterparty_clone(&val_conv);
17664         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
17665 }
17666
17667 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
17668         LDKChannelDetails this_ptr_conv;
17669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17670         this_ptr_conv.is_owned = false;
17671         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
17672         uint64_t ret_ref = 0;
17673         if ((uint64_t)ret_var.inner > 4096) {
17674                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17675                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17676                 ret_ref = (uint64_t)ret_var.inner;
17677                 if (ret_var.is_owned) {
17678                         ret_ref |= 1;
17679                 }
17680         }
17681         return ret_ref;
17682 }
17683
17684 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
17685         LDKChannelDetails this_ptr_conv;
17686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17687         this_ptr_conv.is_owned = false;
17688         LDKOutPoint val_conv;
17689         val_conv.inner = (void*)(val & (~1));
17690         val_conv.is_owned = (val & 1) || (val == 0);
17691         val_conv = OutPoint_clone(&val_conv);
17692         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
17693 }
17694
17695 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
17696         LDKChannelDetails this_ptr_conv;
17697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17698         this_ptr_conv.is_owned = false;
17699         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17700         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
17701         uint64_t ret_ref = (uint64_t)ret_copy;
17702         return ret_ref;
17703 }
17704
17705 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
17706         LDKChannelDetails this_ptr_conv;
17707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17708         this_ptr_conv.is_owned = false;
17709         void* val_ptr = (void*)(((uint64_t)val) & ~1);
17710         CHECK_ACCESS(val_ptr);
17711         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
17712         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
17713         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
17714 }
17715
17716 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
17717         LDKChannelDetails this_ptr_conv;
17718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17719         this_ptr_conv.is_owned = false;
17720         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
17721         return ret_val;
17722 }
17723
17724 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
17725         LDKChannelDetails this_ptr_conv;
17726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17727         this_ptr_conv.is_owned = false;
17728         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
17729 }
17730
17731 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
17732         LDKChannelDetails this_ptr_conv;
17733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17734         this_ptr_conv.is_owned = false;
17735         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17736         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
17737         uint64_t ret_ref = (uint64_t)ret_copy;
17738         return ret_ref;
17739 }
17740
17741 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
17742         LDKChannelDetails this_ptr_conv;
17743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17744         this_ptr_conv.is_owned = false;
17745         void* val_ptr = (void*)(((uint64_t)val) & ~1);
17746         CHECK_ACCESS(val_ptr);
17747         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
17748         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
17749         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
17750 }
17751
17752 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
17753         LDKChannelDetails this_ptr_conv;
17754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17755         this_ptr_conv.is_owned = false;
17756         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
17757         return ret_val;
17758 }
17759
17760 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
17761         LDKChannelDetails this_ptr_conv;
17762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17763         this_ptr_conv.is_owned = false;
17764         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
17765 }
17766
17767 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
17768         LDKChannelDetails this_ptr_conv;
17769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17770         this_ptr_conv.is_owned = false;
17771         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
17772         return ret_val;
17773 }
17774
17775 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
17776         LDKChannelDetails this_ptr_conv;
17777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17778         this_ptr_conv.is_owned = false;
17779         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
17780 }
17781
17782 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
17783         LDKChannelDetails this_ptr_conv;
17784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17785         this_ptr_conv.is_owned = false;
17786         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
17787         return ret_val;
17788 }
17789
17790 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
17791         LDKChannelDetails this_ptr_conv;
17792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17793         this_ptr_conv.is_owned = false;
17794         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
17795 }
17796
17797 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
17798         LDKChannelDetails this_ptr_conv;
17799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17800         this_ptr_conv.is_owned = false;
17801         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
17802         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
17803         uint64_t ret_ref = (uint64_t)ret_copy;
17804         return ret_ref;
17805 }
17806
17807 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
17808         LDKChannelDetails this_ptr_conv;
17809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17810         this_ptr_conv.is_owned = false;
17811         void* val_ptr = (void*)(((uint64_t)val) & ~1);
17812         CHECK_ACCESS(val_ptr);
17813         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
17814         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
17815         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
17816 }
17817
17818 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
17819         LDKChannelDetails this_ptr_conv;
17820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17821         this_ptr_conv.is_owned = false;
17822         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17823         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
17824         uint64_t ret_ref = (uint64_t)ret_copy;
17825         return ret_ref;
17826 }
17827
17828 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_spend_delay(uint32_t this_ptr, uint32_t val) {
17829         LDKChannelDetails this_ptr_conv;
17830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17831         this_ptr_conv.is_owned = false;
17832         void* val_ptr = (void*)(((uint64_t)val) & ~1);
17833         CHECK_ACCESS(val_ptr);
17834         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
17835         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
17836         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
17837 }
17838
17839 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
17840         LDKChannelDetails this_ptr_conv;
17841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17842         this_ptr_conv.is_owned = false;
17843         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
17844         return ret_val;
17845 }
17846
17847 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
17848         LDKChannelDetails this_ptr_conv;
17849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17850         this_ptr_conv.is_owned = false;
17851         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
17852 }
17853
17854 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
17855         LDKChannelDetails this_ptr_conv;
17856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17857         this_ptr_conv.is_owned = false;
17858         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
17859         return ret_val;
17860 }
17861
17862 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
17863         LDKChannelDetails this_ptr_conv;
17864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17865         this_ptr_conv.is_owned = false;
17866         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
17867 }
17868
17869 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
17870         LDKChannelDetails this_ptr_conv;
17871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17872         this_ptr_conv.is_owned = false;
17873         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
17874         return ret_val;
17875 }
17876
17877 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
17878         LDKChannelDetails this_ptr_conv;
17879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17880         this_ptr_conv.is_owned = false;
17881         ChannelDetails_set_is_usable(&this_ptr_conv, val);
17882 }
17883
17884 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
17885         LDKChannelDetails this_ptr_conv;
17886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17887         this_ptr_conv.is_owned = false;
17888         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
17889         return ret_val;
17890 }
17891
17892 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
17893         LDKChannelDetails this_ptr_conv;
17894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17895         this_ptr_conv.is_owned = false;
17896         ChannelDetails_set_is_public(&this_ptr_conv, val);
17897 }
17898
17899 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_channel_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) {
17900         LDKThirtyTwoBytes channel_id_arg_ref;
17901         CHECK(*((uint32_t*)channel_id_arg) == 32);
17902         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17903         LDKChannelCounterparty counterparty_arg_conv;
17904         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
17905         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
17906         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
17907         LDKOutPoint funding_txo_arg_conv;
17908         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
17909         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
17910         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
17911         void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
17912         CHECK_ACCESS(short_channel_id_arg_ptr);
17913         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
17914         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
17915         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
17916         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
17917         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
17918         void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
17919         CHECK_ACCESS(confirmations_required_arg_ptr);
17920         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
17921         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
17922         void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
17923         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
17924         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
17925         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
17926         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_channel_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);
17927         uint64_t ret_ref = 0;
17928         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17929         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17930         ret_ref = (uint64_t)ret_var.inner;
17931         if (ret_var.is_owned) {
17932                 ret_ref |= 1;
17933         }
17934         return ret_ref;
17935 }
17936
17937 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
17938         LDKChannelDetails orig_conv;
17939         orig_conv.inner = (void*)(orig & (~1));
17940         orig_conv.is_owned = false;
17941         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
17942         uint64_t ret_ref = 0;
17943         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17944         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17945         ret_ref = (uint64_t)ret_var.inner;
17946         if (ret_var.is_owned) {
17947                 ret_ref |= 1;
17948         }
17949         return ret_ref;
17950 }
17951
17952 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
17953         if ((this_ptr & 1) != 0) return;
17954         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17955         CHECK_ACCESS(this_ptr_ptr);
17956         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
17957         FREE((void*)this_ptr);
17958         PaymentSendFailure_free(this_ptr_conv);
17959 }
17960
17961 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
17962         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
17963         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17964         *ret_copy = PaymentSendFailure_clone(orig_conv);
17965         uint64_t ret_ref = (uint64_t)ret_copy;
17966         return ret_ref;
17967 }
17968
17969 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
17970         void* a_ptr = (void*)(((uint64_t)a) & ~1);
17971         CHECK_ACCESS(a_ptr);
17972         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
17973         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
17974         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17975         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
17976         uint64_t ret_ref = (uint64_t)ret_copy;
17977         return ret_ref;
17978 }
17979
17980 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
17981         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
17982         a_constr.datalen = *((uint32_t*)a);
17983         if (a_constr.datalen > 0)
17984                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
17985         else
17986                 a_constr.data = NULL;
17987         uint32_t* a_vals = (uint32_t*)(a + 4);
17988         for (size_t w = 0; w < a_constr.datalen; w++) {
17989                 uint32_t a_conv_22 = a_vals[w];
17990                 void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
17991                 CHECK_ACCESS(a_conv_22_ptr);
17992                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
17993                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
17994                 a_constr.data[w] = a_conv_22_conv;
17995         }
17996         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
17997         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
17998         uint64_t ret_ref = (uint64_t)ret_copy;
17999         return ret_ref;
18000 }
18001
18002 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
18003         LDKCVec_APIErrorZ a_constr;
18004         a_constr.datalen = *((uint32_t*)a);
18005         if (a_constr.datalen > 0)
18006                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
18007         else
18008                 a_constr.data = NULL;
18009         uint32_t* a_vals = (uint32_t*)(a + 4);
18010         for (size_t k = 0; k < a_constr.datalen; k++) {
18011                 uint32_t a_conv_10 = a_vals[k];
18012                 void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
18013                 CHECK_ACCESS(a_conv_10_ptr);
18014                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
18015                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
18016                 a_constr.data[k] = a_conv_10_conv;
18017         }
18018         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
18019         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
18020         uint64_t ret_ref = (uint64_t)ret_copy;
18021         return ret_ref;
18022 }
18023
18024 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_partial_failure(uint32_tArray results, uint32_t failed_paths_retry, int8_tArray payment_id) {
18025         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
18026         results_constr.datalen = *((uint32_t*)results);
18027         if (results_constr.datalen > 0)
18028                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
18029         else
18030                 results_constr.data = NULL;
18031         uint32_t* results_vals = (uint32_t*)(results + 4);
18032         for (size_t w = 0; w < results_constr.datalen; w++) {
18033                 uint32_t results_conv_22 = results_vals[w];
18034                 void* results_conv_22_ptr = (void*)(((uint64_t)results_conv_22) & ~1);
18035                 CHECK_ACCESS(results_conv_22_ptr);
18036                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
18037                 results_constr.data[w] = results_conv_22_conv;
18038         }
18039         LDKRouteParameters failed_paths_retry_conv;
18040         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
18041         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
18042         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
18043         LDKThirtyTwoBytes payment_id_ref;
18044         CHECK(*((uint32_t*)payment_id) == 32);
18045         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
18046         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
18047         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
18048         uint64_t ret_ref = (uint64_t)ret_copy;
18049         return ret_ref;
18050 }
18051
18052 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) {
18053         void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
18054         CHECK_ACCESS(fee_est_ptr);
18055         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
18056         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
18057         CHECK_ACCESS(chain_monitor_ptr);
18058         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
18059         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
18060         CHECK_ACCESS(tx_broadcaster_ptr);
18061         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
18062         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18063         CHECK_ACCESS(logger_ptr);
18064         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18065         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
18066         CHECK_ACCESS(keys_manager_ptr);
18067         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
18068         LDKUserConfig config_conv;
18069         config_conv.inner = (void*)(config & (~1));
18070         config_conv.is_owned = (config & 1) || (config == 0);
18071         config_conv = UserConfig_clone(&config_conv);
18072         LDKChainParameters params_conv;
18073         params_conv.inner = (void*)(params & (~1));
18074         params_conv.is_owned = (params & 1) || (params == 0);
18075         params_conv = ChainParameters_clone(&params_conv);
18076         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
18077         uint64_t ret_ref = 0;
18078         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18079         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18080         ret_ref = (uint64_t)ret_var.inner;
18081         if (ret_var.is_owned) {
18082                 ret_ref |= 1;
18083         }
18084         return ret_ref;
18085 }
18086
18087 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
18088         LDKChannelManager this_arg_conv;
18089         this_arg_conv.inner = (void*)(this_arg & (~1));
18090         this_arg_conv.is_owned = false;
18091         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
18092         uint64_t ret_ref = 0;
18093         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18094         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18095         ret_ref = (uint64_t)ret_var.inner;
18096         if (ret_var.is_owned) {
18097                 ret_ref |= 1;
18098         }
18099         return ret_ref;
18100 }
18101
18102 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_channel_id, uint32_t override_config) {
18103         LDKChannelManager this_arg_conv;
18104         this_arg_conv.inner = (void*)(this_arg & (~1));
18105         this_arg_conv.is_owned = false;
18106         LDKPublicKey their_network_key_ref;
18107         CHECK(*((uint32_t*)their_network_key) == 33);
18108         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
18109         LDKUserConfig override_config_conv;
18110         override_config_conv.inner = (void*)(override_config & (~1));
18111         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
18112         override_config_conv = UserConfig_clone(&override_config_conv);
18113         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
18114         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
18115         return (uint64_t)ret_conv;
18116 }
18117
18118 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
18119         LDKChannelManager this_arg_conv;
18120         this_arg_conv.inner = (void*)(this_arg & (~1));
18121         this_arg_conv.is_owned = false;
18122         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
18123         uint32_tArray ret_arr = NULL;
18124         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
18125         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
18126         for (size_t q = 0; q < ret_var.datalen; q++) {
18127                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
18128                 uint64_t ret_conv_16_ref = 0;
18129                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18130                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18131                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
18132                 if (ret_conv_16_var.is_owned) {
18133                         ret_conv_16_ref |= 1;
18134                 }
18135                 ret_arr_ptr[q] = ret_conv_16_ref;
18136         }
18137         
18138         FREE(ret_var.data);
18139         return ret_arr;
18140 }
18141
18142 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
18143         LDKChannelManager this_arg_conv;
18144         this_arg_conv.inner = (void*)(this_arg & (~1));
18145         this_arg_conv.is_owned = false;
18146         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
18147         uint32_tArray ret_arr = NULL;
18148         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
18149         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
18150         for (size_t q = 0; q < ret_var.datalen; q++) {
18151                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
18152                 uint64_t ret_conv_16_ref = 0;
18153                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18154                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18155                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
18156                 if (ret_conv_16_var.is_owned) {
18157                         ret_conv_16_ref |= 1;
18158                 }
18159                 ret_arr_ptr[q] = ret_conv_16_ref;
18160         }
18161         
18162         FREE(ret_var.data);
18163         return ret_arr;
18164 }
18165
18166 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
18167         LDKChannelManager this_arg_conv;
18168         this_arg_conv.inner = (void*)(this_arg & (~1));
18169         this_arg_conv.is_owned = false;
18170         unsigned char channel_id_arr[32];
18171         CHECK(*((uint32_t*)channel_id) == 32);
18172         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
18173         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
18174         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18175         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
18176         return (uint64_t)ret_conv;
18177 }
18178
18179 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) {
18180         LDKChannelManager this_arg_conv;
18181         this_arg_conv.inner = (void*)(this_arg & (~1));
18182         this_arg_conv.is_owned = false;
18183         unsigned char channel_id_arr[32];
18184         CHECK(*((uint32_t*)channel_id) == 32);
18185         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
18186         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
18187         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18188         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
18189         return (uint64_t)ret_conv;
18190 }
18191
18192 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
18193         LDKChannelManager this_arg_conv;
18194         this_arg_conv.inner = (void*)(this_arg & (~1));
18195         this_arg_conv.is_owned = false;
18196         unsigned char channel_id_arr[32];
18197         CHECK(*((uint32_t*)channel_id) == 32);
18198         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
18199         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
18200         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18201         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
18202         return (uint64_t)ret_conv;
18203 }
18204
18205 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
18206         LDKChannelManager this_arg_conv;
18207         this_arg_conv.inner = (void*)(this_arg & (~1));
18208         this_arg_conv.is_owned = false;
18209         ChannelManager_force_close_all_channels(&this_arg_conv);
18210 }
18211
18212 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
18213         LDKChannelManager this_arg_conv;
18214         this_arg_conv.inner = (void*)(this_arg & (~1));
18215         this_arg_conv.is_owned = false;
18216         LDKRoute route_conv;
18217         route_conv.inner = (void*)(route & (~1));
18218         route_conv.is_owned = false;
18219         LDKThirtyTwoBytes payment_hash_ref;
18220         CHECK(*((uint32_t*)payment_hash) == 32);
18221         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
18222         LDKThirtyTwoBytes payment_secret_ref;
18223         CHECK(*((uint32_t*)payment_secret) == 32);
18224         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
18225         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
18226         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
18227         return (uint64_t)ret_conv;
18228 }
18229
18230 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
18231         LDKChannelManager this_arg_conv;
18232         this_arg_conv.inner = (void*)(this_arg & (~1));
18233         this_arg_conv.is_owned = false;
18234         LDKRoute route_conv;
18235         route_conv.inner = (void*)(route & (~1));
18236         route_conv.is_owned = false;
18237         LDKThirtyTwoBytes payment_id_ref;
18238         CHECK(*((uint32_t*)payment_id) == 32);
18239         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
18240         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
18241         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
18242         return (uint64_t)ret_conv;
18243 }
18244
18245 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_spontaneous_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_preimage) {
18246         LDKChannelManager this_arg_conv;
18247         this_arg_conv.inner = (void*)(this_arg & (~1));
18248         this_arg_conv.is_owned = false;
18249         LDKRoute route_conv;
18250         route_conv.inner = (void*)(route & (~1));
18251         route_conv.is_owned = false;
18252         LDKThirtyTwoBytes payment_preimage_ref;
18253         CHECK(*((uint32_t*)payment_preimage) == 32);
18254         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
18255         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
18256         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
18257         return (uint64_t)ret_conv;
18258 }
18259
18260 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
18261         LDKChannelManager this_arg_conv;
18262         this_arg_conv.inner = (void*)(this_arg & (~1));
18263         this_arg_conv.is_owned = false;
18264         unsigned char temporary_channel_id_arr[32];
18265         CHECK(*((uint32_t*)temporary_channel_id) == 32);
18266         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
18267         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
18268         LDKTransaction funding_transaction_ref;
18269         funding_transaction_ref.datalen = *((uint32_t*)funding_transaction);
18270         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
18271         memcpy(funding_transaction_ref.data, (uint8_t*)(funding_transaction + 4), funding_transaction_ref.datalen);
18272         funding_transaction_ref.data_is_owned = true;
18273         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18274         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
18275         return (uint64_t)ret_conv;
18276 }
18277
18278 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
18279         LDKChannelManager this_arg_conv;
18280         this_arg_conv.inner = (void*)(this_arg & (~1));
18281         this_arg_conv.is_owned = false;
18282         LDKThreeBytes rgb_ref;
18283         CHECK(*((uint32_t*)rgb) == 3);
18284         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
18285         LDKThirtyTwoBytes alias_ref;
18286         CHECK(*((uint32_t*)alias) == 32);
18287         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
18288         LDKCVec_NetAddressZ addresses_constr;
18289         addresses_constr.datalen = *((uint32_t*)addresses);
18290         if (addresses_constr.datalen > 0)
18291                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18292         else
18293                 addresses_constr.data = NULL;
18294         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
18295         for (size_t m = 0; m < addresses_constr.datalen; m++) {
18296                 uint32_t addresses_conv_12 = addresses_vals[m];
18297                 void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
18298                 CHECK_ACCESS(addresses_conv_12_ptr);
18299                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
18300                 addresses_constr.data[m] = addresses_conv_12_conv;
18301         }
18302         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
18303 }
18304
18305 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
18306         LDKChannelManager this_arg_conv;
18307         this_arg_conv.inner = (void*)(this_arg & (~1));
18308         this_arg_conv.is_owned = false;
18309         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
18310 }
18311
18312 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
18313         LDKChannelManager this_arg_conv;
18314         this_arg_conv.inner = (void*)(this_arg & (~1));
18315         this_arg_conv.is_owned = false;
18316         ChannelManager_timer_tick_occurred(&this_arg_conv);
18317 }
18318
18319 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
18320         LDKChannelManager this_arg_conv;
18321         this_arg_conv.inner = (void*)(this_arg & (~1));
18322         this_arg_conv.is_owned = false;
18323         unsigned char payment_hash_arr[32];
18324         CHECK(*((uint32_t*)payment_hash) == 32);
18325         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
18326         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
18327         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
18328         return ret_val;
18329 }
18330
18331 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
18332         LDKChannelManager this_arg_conv;
18333         this_arg_conv.inner = (void*)(this_arg & (~1));
18334         this_arg_conv.is_owned = false;
18335         LDKThirtyTwoBytes payment_preimage_ref;
18336         CHECK(*((uint32_t*)payment_preimage) == 32);
18337         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
18338         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
18339         return ret_val;
18340 }
18341
18342 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
18343         LDKChannelManager this_arg_conv;
18344         this_arg_conv.inner = (void*)(this_arg & (~1));
18345         this_arg_conv.is_owned = false;
18346         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18347         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
18348         return ret_arr;
18349 }
18350
18351 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) {
18352         LDKChannelManager this_arg_conv;
18353         this_arg_conv.inner = (void*)(this_arg & (~1));
18354         this_arg_conv.is_owned = false;
18355         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
18356         CHECK_ACCESS(min_value_msat_ptr);
18357         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
18358         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
18359         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
18360         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
18361         return ((uint64_t)ret_conv);
18362 }
18363
18364 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) {
18365         LDKChannelManager this_arg_conv;
18366         this_arg_conv.inner = (void*)(this_arg & (~1));
18367         this_arg_conv.is_owned = false;
18368         LDKThirtyTwoBytes payment_hash_ref;
18369         CHECK(*((uint32_t*)payment_hash) == 32);
18370         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
18371         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
18372         CHECK_ACCESS(min_value_msat_ptr);
18373         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
18374         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
18375         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18376         *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);
18377         return (uint64_t)ret_conv;
18378 }
18379
18380 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
18381         LDKChannelManager this_arg_conv;
18382         this_arg_conv.inner = (void*)(this_arg & (~1));
18383         this_arg_conv.is_owned = false;
18384         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18385         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
18386         return (uint64_t)ret_ret;
18387 }
18388
18389 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
18390         LDKChannelManager this_arg_conv;
18391         this_arg_conv.inner = (void*)(this_arg & (~1));
18392         this_arg_conv.is_owned = false;
18393         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
18394         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
18395         return (uint64_t)ret_ret;
18396 }
18397
18398 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
18399         LDKChannelManager this_arg_conv;
18400         this_arg_conv.inner = (void*)(this_arg & (~1));
18401         this_arg_conv.is_owned = false;
18402         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
18403         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
18404         return (uint64_t)ret_ret;
18405 }
18406
18407 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
18408         LDKChannelManager this_arg_conv;
18409         this_arg_conv.inner = (void*)(this_arg & (~1));
18410         this_arg_conv.is_owned = false;
18411         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
18412         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
18413         return (uint64_t)ret_ret;
18414 }
18415
18416 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
18417         LDKChannelManager this_arg_conv;
18418         this_arg_conv.inner = (void*)(this_arg & (~1));
18419         this_arg_conv.is_owned = false;
18420         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
18421         return ret_val;
18422 }
18423
18424 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
18425         LDKChannelManager this_arg_conv;
18426         this_arg_conv.inner = (void*)(this_arg & (~1));
18427         this_arg_conv.is_owned = false;
18428         ChannelManager_await_persistable_update(&this_arg_conv);
18429 }
18430
18431 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
18432         LDKChannelManager this_arg_conv;
18433         this_arg_conv.inner = (void*)(this_arg & (~1));
18434         this_arg_conv.is_owned = false;
18435         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
18436         uint64_t ret_ref = 0;
18437         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18438         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18439         ret_ref = (uint64_t)ret_var.inner;
18440         if (ret_var.is_owned) {
18441                 ret_ref |= 1;
18442         }
18443         return ret_ref;
18444 }
18445
18446 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
18447         LDKChannelManager this_arg_conv;
18448         this_arg_conv.inner = (void*)(this_arg & (~1));
18449         this_arg_conv.is_owned = false;
18450         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
18451         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
18452         return (uint64_t)ret_ret;
18453 }
18454
18455 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
18456         LDKChannelManager obj_conv;
18457         obj_conv.inner = (void*)(obj & (~1));
18458         obj_conv.is_owned = false;
18459         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
18460         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18461         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18462         CVec_u8Z_free(ret_var);
18463         return ret_arr;
18464 }
18465
18466 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
18467         LDKChannelManagerReadArgs this_obj_conv;
18468         this_obj_conv.inner = (void*)(this_obj & (~1));
18469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18470         ChannelManagerReadArgs_free(this_obj_conv);
18471 }
18472
18473 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
18474         LDKChannelManagerReadArgs this_ptr_conv;
18475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18476         this_ptr_conv.is_owned = false;
18477         // WARNING: This object doesn't live past this scope, needs clone!
18478         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
18479         return ret_ret;
18480 }
18481
18482 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
18483         LDKChannelManagerReadArgs this_ptr_conv;
18484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18485         this_ptr_conv.is_owned = false;
18486         void* val_ptr = (void*)(((uint64_t)val) & ~1);
18487         CHECK_ACCESS(val_ptr);
18488         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
18489         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
18490 }
18491
18492 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
18493         LDKChannelManagerReadArgs this_ptr_conv;
18494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18495         this_ptr_conv.is_owned = false;
18496         // WARNING: This object doesn't live past this scope, needs clone!
18497         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
18498         return ret_ret;
18499 }
18500
18501 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
18502         LDKChannelManagerReadArgs this_ptr_conv;
18503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18504         this_ptr_conv.is_owned = false;
18505         void* val_ptr = (void*)(((uint64_t)val) & ~1);
18506         CHECK_ACCESS(val_ptr);
18507         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
18508         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
18509 }
18510
18511 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
18512         LDKChannelManagerReadArgs this_ptr_conv;
18513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18514         this_ptr_conv.is_owned = false;
18515         // WARNING: This object doesn't live past this scope, needs clone!
18516         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
18517         return ret_ret;
18518 }
18519
18520 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
18521         LDKChannelManagerReadArgs this_ptr_conv;
18522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18523         this_ptr_conv.is_owned = false;
18524         void* val_ptr = (void*)(((uint64_t)val) & ~1);
18525         CHECK_ACCESS(val_ptr);
18526         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
18527         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
18528 }
18529
18530 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
18531         LDKChannelManagerReadArgs this_ptr_conv;
18532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18533         this_ptr_conv.is_owned = false;
18534         // WARNING: This object doesn't live past this scope, needs clone!
18535         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
18536         return ret_ret;
18537 }
18538
18539 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
18540         LDKChannelManagerReadArgs this_ptr_conv;
18541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18542         this_ptr_conv.is_owned = false;
18543         void* val_ptr = (void*)(((uint64_t)val) & ~1);
18544         CHECK_ACCESS(val_ptr);
18545         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
18546         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
18547 }
18548
18549 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
18550         LDKChannelManagerReadArgs this_ptr_conv;
18551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18552         this_ptr_conv.is_owned = false;
18553         // WARNING: This object doesn't live past this scope, needs clone!
18554         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
18555         return ret_ret;
18556 }
18557
18558 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
18559         LDKChannelManagerReadArgs this_ptr_conv;
18560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18561         this_ptr_conv.is_owned = false;
18562         void* val_ptr = (void*)(((uint64_t)val) & ~1);
18563         CHECK_ACCESS(val_ptr);
18564         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
18565         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
18566 }
18567
18568 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
18569         LDKChannelManagerReadArgs this_ptr_conv;
18570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18571         this_ptr_conv.is_owned = false;
18572         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
18573         uint64_t ret_ref = 0;
18574         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18575         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18576         ret_ref = (uint64_t)ret_var.inner;
18577         if (ret_var.is_owned) {
18578                 ret_ref |= 1;
18579         }
18580         return ret_ref;
18581 }
18582
18583 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
18584         LDKChannelManagerReadArgs this_ptr_conv;
18585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18586         this_ptr_conv.is_owned = false;
18587         LDKUserConfig val_conv;
18588         val_conv.inner = (void*)(val & (~1));
18589         val_conv.is_owned = (val & 1) || (val == 0);
18590         val_conv = UserConfig_clone(&val_conv);
18591         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
18592 }
18593
18594 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) {
18595         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
18596         CHECK_ACCESS(keys_manager_ptr);
18597         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
18598         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
18599         CHECK_ACCESS(fee_estimator_ptr);
18600         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
18601         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
18602         CHECK_ACCESS(chain_monitor_ptr);
18603         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
18604         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
18605         CHECK_ACCESS(tx_broadcaster_ptr);
18606         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
18607         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18608         CHECK_ACCESS(logger_ptr);
18609         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18610         LDKUserConfig default_config_conv;
18611         default_config_conv.inner = (void*)(default_config & (~1));
18612         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
18613         default_config_conv = UserConfig_clone(&default_config_conv);
18614         LDKCVec_ChannelMonitorZ channel_monitors_constr;
18615         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
18616         if (channel_monitors_constr.datalen > 0)
18617                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
18618         else
18619                 channel_monitors_constr.data = NULL;
18620         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
18621         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
18622                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
18623                 LDKChannelMonitor channel_monitors_conv_16_conv;
18624                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
18625                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
18626                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
18627         }
18628         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);
18629         uint64_t ret_ref = 0;
18630         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18631         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18632         ret_ref = (uint64_t)ret_var.inner;
18633         if (ret_var.is_owned) {
18634                 ret_ref |= 1;
18635         }
18636         return ret_ref;
18637 }
18638
18639 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
18640         LDKu8slice ser_ref;
18641         ser_ref.datalen = *((uint32_t*)ser);
18642         ser_ref.data = (int8_t*)(ser + 4);
18643         LDKChannelManagerReadArgs arg_conv;
18644         arg_conv.inner = (void*)(arg & (~1));
18645         arg_conv.is_owned = (arg & 1) || (arg == 0);
18646         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
18647         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
18648         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
18649         return (uint64_t)ret_conv;
18650 }
18651
18652 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
18653         LDKDecodeError this_obj_conv;
18654         this_obj_conv.inner = (void*)(this_obj & (~1));
18655         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18656         DecodeError_free(this_obj_conv);
18657 }
18658
18659 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
18660         LDKDecodeError orig_conv;
18661         orig_conv.inner = (void*)(orig & (~1));
18662         orig_conv.is_owned = false;
18663         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
18664         uint64_t ret_ref = 0;
18665         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18666         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18667         ret_ref = (uint64_t)ret_var.inner;
18668         if (ret_var.is_owned) {
18669                 ret_ref |= 1;
18670         }
18671         return ret_ref;
18672 }
18673
18674 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
18675         LDKInit this_obj_conv;
18676         this_obj_conv.inner = (void*)(this_obj & (~1));
18677         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18678         Init_free(this_obj_conv);
18679 }
18680
18681 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
18682         LDKInit this_ptr_conv;
18683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18684         this_ptr_conv.is_owned = false;
18685         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
18686         uint64_t ret_ref = 0;
18687         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18688         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18689         ret_ref = (uint64_t)ret_var.inner;
18690         if (ret_var.is_owned) {
18691                 ret_ref |= 1;
18692         }
18693         return ret_ref;
18694 }
18695
18696 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
18697         LDKInit this_ptr_conv;
18698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18699         this_ptr_conv.is_owned = false;
18700         LDKInitFeatures val_conv;
18701         val_conv.inner = (void*)(val & (~1));
18702         val_conv.is_owned = (val & 1) || (val == 0);
18703         val_conv = InitFeatures_clone(&val_conv);
18704         Init_set_features(&this_ptr_conv, val_conv);
18705 }
18706
18707 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
18708         LDKInitFeatures features_arg_conv;
18709         features_arg_conv.inner = (void*)(features_arg & (~1));
18710         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
18711         features_arg_conv = InitFeatures_clone(&features_arg_conv);
18712         LDKInit ret_var = Init_new(features_arg_conv);
18713         uint64_t ret_ref = 0;
18714         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18715         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18716         ret_ref = (uint64_t)ret_var.inner;
18717         if (ret_var.is_owned) {
18718                 ret_ref |= 1;
18719         }
18720         return ret_ref;
18721 }
18722
18723 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
18724         LDKInit orig_conv;
18725         orig_conv.inner = (void*)(orig & (~1));
18726         orig_conv.is_owned = false;
18727         LDKInit ret_var = Init_clone(&orig_conv);
18728         uint64_t ret_ref = 0;
18729         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18730         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18731         ret_ref = (uint64_t)ret_var.inner;
18732         if (ret_var.is_owned) {
18733                 ret_ref |= 1;
18734         }
18735         return ret_ref;
18736 }
18737
18738 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
18739         LDKErrorMessage this_obj_conv;
18740         this_obj_conv.inner = (void*)(this_obj & (~1));
18741         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18742         ErrorMessage_free(this_obj_conv);
18743 }
18744
18745 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
18746         LDKErrorMessage this_ptr_conv;
18747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18748         this_ptr_conv.is_owned = false;
18749         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18750         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
18751         return ret_arr;
18752 }
18753
18754 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18755         LDKErrorMessage this_ptr_conv;
18756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18757         this_ptr_conv.is_owned = false;
18758         LDKThirtyTwoBytes val_ref;
18759         CHECK(*((uint32_t*)val) == 32);
18760         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18761         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
18762 }
18763
18764 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
18765         LDKErrorMessage this_ptr_conv;
18766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18767         this_ptr_conv.is_owned = false;
18768         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
18769         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
18770         Str_free(ret_str);
18771         return ret_conv;
18772 }
18773
18774 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
18775         LDKErrorMessage this_ptr_conv;
18776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18777         this_ptr_conv.is_owned = false;
18778         LDKStr val_conv = str_ref_to_owned_c(val);
18779         ErrorMessage_set_data(&this_ptr_conv, val_conv);
18780 }
18781
18782 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
18783         LDKThirtyTwoBytes channel_id_arg_ref;
18784         CHECK(*((uint32_t*)channel_id_arg) == 32);
18785         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
18786         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
18787         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
18788         uint64_t ret_ref = 0;
18789         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18790         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18791         ret_ref = (uint64_t)ret_var.inner;
18792         if (ret_var.is_owned) {
18793                 ret_ref |= 1;
18794         }
18795         return ret_ref;
18796 }
18797
18798 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
18799         LDKErrorMessage orig_conv;
18800         orig_conv.inner = (void*)(orig & (~1));
18801         orig_conv.is_owned = false;
18802         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
18803         uint64_t ret_ref = 0;
18804         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18805         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18806         ret_ref = (uint64_t)ret_var.inner;
18807         if (ret_var.is_owned) {
18808                 ret_ref |= 1;
18809         }
18810         return ret_ref;
18811 }
18812
18813 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
18814         LDKPing this_obj_conv;
18815         this_obj_conv.inner = (void*)(this_obj & (~1));
18816         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18817         Ping_free(this_obj_conv);
18818 }
18819
18820 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
18821         LDKPing this_ptr_conv;
18822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18823         this_ptr_conv.is_owned = false;
18824         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
18825         return ret_val;
18826 }
18827
18828 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
18829         LDKPing this_ptr_conv;
18830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18831         this_ptr_conv.is_owned = false;
18832         Ping_set_ponglen(&this_ptr_conv, val);
18833 }
18834
18835 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
18836         LDKPing this_ptr_conv;
18837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18838         this_ptr_conv.is_owned = false;
18839         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
18840         return ret_val;
18841 }
18842
18843 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
18844         LDKPing this_ptr_conv;
18845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18846         this_ptr_conv.is_owned = false;
18847         Ping_set_byteslen(&this_ptr_conv, val);
18848 }
18849
18850 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
18851         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
18852         uint64_t ret_ref = 0;
18853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18855         ret_ref = (uint64_t)ret_var.inner;
18856         if (ret_var.is_owned) {
18857                 ret_ref |= 1;
18858         }
18859         return ret_ref;
18860 }
18861
18862 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
18863         LDKPing orig_conv;
18864         orig_conv.inner = (void*)(orig & (~1));
18865         orig_conv.is_owned = false;
18866         LDKPing ret_var = Ping_clone(&orig_conv);
18867         uint64_t ret_ref = 0;
18868         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18869         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18870         ret_ref = (uint64_t)ret_var.inner;
18871         if (ret_var.is_owned) {
18872                 ret_ref |= 1;
18873         }
18874         return ret_ref;
18875 }
18876
18877 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
18878         LDKPong this_obj_conv;
18879         this_obj_conv.inner = (void*)(this_obj & (~1));
18880         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18881         Pong_free(this_obj_conv);
18882 }
18883
18884 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
18885         LDKPong this_ptr_conv;
18886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18887         this_ptr_conv.is_owned = false;
18888         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
18889         return ret_val;
18890 }
18891
18892 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
18893         LDKPong this_ptr_conv;
18894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18895         this_ptr_conv.is_owned = false;
18896         Pong_set_byteslen(&this_ptr_conv, val);
18897 }
18898
18899 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
18900         LDKPong ret_var = Pong_new(byteslen_arg);
18901         uint64_t ret_ref = 0;
18902         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18903         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18904         ret_ref = (uint64_t)ret_var.inner;
18905         if (ret_var.is_owned) {
18906                 ret_ref |= 1;
18907         }
18908         return ret_ref;
18909 }
18910
18911 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
18912         LDKPong orig_conv;
18913         orig_conv.inner = (void*)(orig & (~1));
18914         orig_conv.is_owned = false;
18915         LDKPong ret_var = Pong_clone(&orig_conv);
18916         uint64_t ret_ref = 0;
18917         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18918         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18919         ret_ref = (uint64_t)ret_var.inner;
18920         if (ret_var.is_owned) {
18921                 ret_ref |= 1;
18922         }
18923         return ret_ref;
18924 }
18925
18926 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
18927         LDKOpenChannel this_obj_conv;
18928         this_obj_conv.inner = (void*)(this_obj & (~1));
18929         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18930         OpenChannel_free(this_obj_conv);
18931 }
18932
18933 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
18934         LDKOpenChannel this_ptr_conv;
18935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18936         this_ptr_conv.is_owned = false;
18937         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18938         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
18939         return ret_arr;
18940 }
18941
18942 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
18943         LDKOpenChannel this_ptr_conv;
18944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18945         this_ptr_conv.is_owned = false;
18946         LDKThirtyTwoBytes val_ref;
18947         CHECK(*((uint32_t*)val) == 32);
18948         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18949         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
18950 }
18951
18952 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
18953         LDKOpenChannel this_ptr_conv;
18954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18955         this_ptr_conv.is_owned = false;
18956         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18957         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
18958         return ret_arr;
18959 }
18960
18961 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
18962         LDKOpenChannel this_ptr_conv;
18963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18964         this_ptr_conv.is_owned = false;
18965         LDKThirtyTwoBytes val_ref;
18966         CHECK(*((uint32_t*)val) == 32);
18967         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18968         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
18969 }
18970
18971 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
18972         LDKOpenChannel this_ptr_conv;
18973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18974         this_ptr_conv.is_owned = false;
18975         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
18976         return ret_val;
18977 }
18978
18979 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
18980         LDKOpenChannel this_ptr_conv;
18981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18982         this_ptr_conv.is_owned = false;
18983         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
18984 }
18985
18986 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
18987         LDKOpenChannel this_ptr_conv;
18988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18989         this_ptr_conv.is_owned = false;
18990         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
18991         return ret_val;
18992 }
18993
18994 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
18995         LDKOpenChannel this_ptr_conv;
18996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18997         this_ptr_conv.is_owned = false;
18998         OpenChannel_set_push_msat(&this_ptr_conv, val);
18999 }
19000
19001 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
19002         LDKOpenChannel this_ptr_conv;
19003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19004         this_ptr_conv.is_owned = false;
19005         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
19006         return ret_val;
19007 }
19008
19009 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
19010         LDKOpenChannel this_ptr_conv;
19011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19012         this_ptr_conv.is_owned = false;
19013         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
19014 }
19015
19016 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
19017         LDKOpenChannel this_ptr_conv;
19018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19019         this_ptr_conv.is_owned = false;
19020         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
19021         return ret_val;
19022 }
19023
19024 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
19025         LDKOpenChannel this_ptr_conv;
19026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19027         this_ptr_conv.is_owned = false;
19028         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
19029 }
19030
19031 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
19032         LDKOpenChannel this_ptr_conv;
19033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19034         this_ptr_conv.is_owned = false;
19035         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
19036         return ret_val;
19037 }
19038
19039 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
19040         LDKOpenChannel this_ptr_conv;
19041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19042         this_ptr_conv.is_owned = false;
19043         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
19044 }
19045
19046 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
19047         LDKOpenChannel this_ptr_conv;
19048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19049         this_ptr_conv.is_owned = false;
19050         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
19051         return ret_val;
19052 }
19053
19054 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
19055         LDKOpenChannel this_ptr_conv;
19056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19057         this_ptr_conv.is_owned = false;
19058         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
19059 }
19060
19061 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
19062         LDKOpenChannel this_ptr_conv;
19063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19064         this_ptr_conv.is_owned = false;
19065         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
19066         return ret_val;
19067 }
19068
19069 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
19070         LDKOpenChannel this_ptr_conv;
19071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19072         this_ptr_conv.is_owned = false;
19073         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
19074 }
19075
19076 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
19077         LDKOpenChannel this_ptr_conv;
19078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19079         this_ptr_conv.is_owned = false;
19080         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
19081         return ret_val;
19082 }
19083
19084 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
19085         LDKOpenChannel this_ptr_conv;
19086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19087         this_ptr_conv.is_owned = false;
19088         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
19089 }
19090
19091 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
19092         LDKOpenChannel this_ptr_conv;
19093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19094         this_ptr_conv.is_owned = false;
19095         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
19096         return ret_val;
19097 }
19098
19099 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
19100         LDKOpenChannel this_ptr_conv;
19101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19102         this_ptr_conv.is_owned = false;
19103         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
19104 }
19105
19106 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
19107         LDKOpenChannel this_ptr_conv;
19108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19109         this_ptr_conv.is_owned = false;
19110         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19111         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
19112         return ret_arr;
19113 }
19114
19115 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
19116         LDKOpenChannel this_ptr_conv;
19117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19118         this_ptr_conv.is_owned = false;
19119         LDKPublicKey val_ref;
19120         CHECK(*((uint32_t*)val) == 33);
19121         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19122         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
19123 }
19124
19125 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
19126         LDKOpenChannel this_ptr_conv;
19127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19128         this_ptr_conv.is_owned = false;
19129         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19130         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
19131         return ret_arr;
19132 }
19133
19134 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
19135         LDKOpenChannel this_ptr_conv;
19136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19137         this_ptr_conv.is_owned = false;
19138         LDKPublicKey val_ref;
19139         CHECK(*((uint32_t*)val) == 33);
19140         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19141         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
19142 }
19143
19144 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
19145         LDKOpenChannel this_ptr_conv;
19146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19147         this_ptr_conv.is_owned = false;
19148         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19149         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
19150         return ret_arr;
19151 }
19152
19153 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
19154         LDKOpenChannel this_ptr_conv;
19155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19156         this_ptr_conv.is_owned = false;
19157         LDKPublicKey val_ref;
19158         CHECK(*((uint32_t*)val) == 33);
19159         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19160         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
19161 }
19162
19163 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
19164         LDKOpenChannel this_ptr_conv;
19165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19166         this_ptr_conv.is_owned = false;
19167         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19168         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
19169         return ret_arr;
19170 }
19171
19172 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
19173         LDKOpenChannel this_ptr_conv;
19174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19175         this_ptr_conv.is_owned = false;
19176         LDKPublicKey val_ref;
19177         CHECK(*((uint32_t*)val) == 33);
19178         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19179         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
19180 }
19181
19182 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
19183         LDKOpenChannel this_ptr_conv;
19184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19185         this_ptr_conv.is_owned = false;
19186         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19187         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
19188         return ret_arr;
19189 }
19190
19191 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
19192         LDKOpenChannel this_ptr_conv;
19193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19194         this_ptr_conv.is_owned = false;
19195         LDKPublicKey val_ref;
19196         CHECK(*((uint32_t*)val) == 33);
19197         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19198         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
19199 }
19200
19201 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
19202         LDKOpenChannel this_ptr_conv;
19203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19204         this_ptr_conv.is_owned = false;
19205         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19206         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
19207         return ret_arr;
19208 }
19209
19210 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
19211         LDKOpenChannel this_ptr_conv;
19212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19213         this_ptr_conv.is_owned = false;
19214         LDKPublicKey val_ref;
19215         CHECK(*((uint32_t*)val) == 33);
19216         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19217         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
19218 }
19219
19220 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
19221         LDKOpenChannel this_ptr_conv;
19222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19223         this_ptr_conv.is_owned = false;
19224         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
19225         return ret_val;
19226 }
19227
19228 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
19229         LDKOpenChannel this_ptr_conv;
19230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19231         this_ptr_conv.is_owned = false;
19232         OpenChannel_set_channel_flags(&this_ptr_conv, val);
19233 }
19234
19235 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
19236         LDKOpenChannel orig_conv;
19237         orig_conv.inner = (void*)(orig & (~1));
19238         orig_conv.is_owned = false;
19239         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
19240         uint64_t ret_ref = 0;
19241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19243         ret_ref = (uint64_t)ret_var.inner;
19244         if (ret_var.is_owned) {
19245                 ret_ref |= 1;
19246         }
19247         return ret_ref;
19248 }
19249
19250 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
19251         LDKAcceptChannel this_obj_conv;
19252         this_obj_conv.inner = (void*)(this_obj & (~1));
19253         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19254         AcceptChannel_free(this_obj_conv);
19255 }
19256
19257 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
19258         LDKAcceptChannel this_ptr_conv;
19259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19260         this_ptr_conv.is_owned = false;
19261         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19262         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
19263         return ret_arr;
19264 }
19265
19266 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
19267         LDKAcceptChannel this_ptr_conv;
19268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19269         this_ptr_conv.is_owned = false;
19270         LDKThirtyTwoBytes val_ref;
19271         CHECK(*((uint32_t*)val) == 32);
19272         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19273         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
19274 }
19275
19276 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
19277         LDKAcceptChannel this_ptr_conv;
19278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19279         this_ptr_conv.is_owned = false;
19280         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
19281         return ret_val;
19282 }
19283
19284 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
19285         LDKAcceptChannel this_ptr_conv;
19286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19287         this_ptr_conv.is_owned = false;
19288         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
19289 }
19290
19291 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
19292         LDKAcceptChannel this_ptr_conv;
19293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19294         this_ptr_conv.is_owned = false;
19295         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
19296         return ret_val;
19297 }
19298
19299 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
19300         LDKAcceptChannel this_ptr_conv;
19301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19302         this_ptr_conv.is_owned = false;
19303         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
19304 }
19305
19306 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
19307         LDKAcceptChannel this_ptr_conv;
19308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19309         this_ptr_conv.is_owned = false;
19310         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
19311         return ret_val;
19312 }
19313
19314 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
19315         LDKAcceptChannel this_ptr_conv;
19316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19317         this_ptr_conv.is_owned = false;
19318         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
19319 }
19320
19321 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
19322         LDKAcceptChannel this_ptr_conv;
19323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19324         this_ptr_conv.is_owned = false;
19325         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
19326         return ret_val;
19327 }
19328
19329 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
19330         LDKAcceptChannel this_ptr_conv;
19331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19332         this_ptr_conv.is_owned = false;
19333         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
19334 }
19335
19336 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
19337         LDKAcceptChannel this_ptr_conv;
19338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19339         this_ptr_conv.is_owned = false;
19340         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
19341         return ret_val;
19342 }
19343
19344 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
19345         LDKAcceptChannel this_ptr_conv;
19346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19347         this_ptr_conv.is_owned = false;
19348         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
19349 }
19350
19351 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
19352         LDKAcceptChannel this_ptr_conv;
19353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19354         this_ptr_conv.is_owned = false;
19355         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
19356         return ret_val;
19357 }
19358
19359 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
19360         LDKAcceptChannel this_ptr_conv;
19361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19362         this_ptr_conv.is_owned = false;
19363         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
19364 }
19365
19366 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
19367         LDKAcceptChannel this_ptr_conv;
19368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19369         this_ptr_conv.is_owned = false;
19370         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
19371         return ret_val;
19372 }
19373
19374 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
19375         LDKAcceptChannel this_ptr_conv;
19376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19377         this_ptr_conv.is_owned = false;
19378         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
19379 }
19380
19381 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
19382         LDKAcceptChannel this_ptr_conv;
19383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19384         this_ptr_conv.is_owned = false;
19385         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19386         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
19387         return ret_arr;
19388 }
19389
19390 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
19391         LDKAcceptChannel this_ptr_conv;
19392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19393         this_ptr_conv.is_owned = false;
19394         LDKPublicKey val_ref;
19395         CHECK(*((uint32_t*)val) == 33);
19396         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19397         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
19398 }
19399
19400 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
19401         LDKAcceptChannel this_ptr_conv;
19402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19403         this_ptr_conv.is_owned = false;
19404         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19405         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
19406         return ret_arr;
19407 }
19408
19409 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
19410         LDKAcceptChannel this_ptr_conv;
19411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19412         this_ptr_conv.is_owned = false;
19413         LDKPublicKey val_ref;
19414         CHECK(*((uint32_t*)val) == 33);
19415         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19416         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
19417 }
19418
19419 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
19420         LDKAcceptChannel this_ptr_conv;
19421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19422         this_ptr_conv.is_owned = false;
19423         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19424         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
19425         return ret_arr;
19426 }
19427
19428 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
19429         LDKAcceptChannel this_ptr_conv;
19430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19431         this_ptr_conv.is_owned = false;
19432         LDKPublicKey val_ref;
19433         CHECK(*((uint32_t*)val) == 33);
19434         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19435         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
19436 }
19437
19438 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
19439         LDKAcceptChannel this_ptr_conv;
19440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19441         this_ptr_conv.is_owned = false;
19442         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19443         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
19444         return ret_arr;
19445 }
19446
19447 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
19448         LDKAcceptChannel this_ptr_conv;
19449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19450         this_ptr_conv.is_owned = false;
19451         LDKPublicKey val_ref;
19452         CHECK(*((uint32_t*)val) == 33);
19453         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19454         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
19455 }
19456
19457 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
19458         LDKAcceptChannel this_ptr_conv;
19459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19460         this_ptr_conv.is_owned = false;
19461         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19462         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
19463         return ret_arr;
19464 }
19465
19466 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
19467         LDKAcceptChannel this_ptr_conv;
19468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19469         this_ptr_conv.is_owned = false;
19470         LDKPublicKey val_ref;
19471         CHECK(*((uint32_t*)val) == 33);
19472         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19473         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
19474 }
19475
19476 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
19477         LDKAcceptChannel this_ptr_conv;
19478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19479         this_ptr_conv.is_owned = false;
19480         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19481         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
19482         return ret_arr;
19483 }
19484
19485 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
19486         LDKAcceptChannel this_ptr_conv;
19487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19488         this_ptr_conv.is_owned = false;
19489         LDKPublicKey val_ref;
19490         CHECK(*((uint32_t*)val) == 33);
19491         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19492         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
19493 }
19494
19495 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
19496         LDKAcceptChannel orig_conv;
19497         orig_conv.inner = (void*)(orig & (~1));
19498         orig_conv.is_owned = false;
19499         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
19500         uint64_t ret_ref = 0;
19501         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19502         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19503         ret_ref = (uint64_t)ret_var.inner;
19504         if (ret_var.is_owned) {
19505                 ret_ref |= 1;
19506         }
19507         return ret_ref;
19508 }
19509
19510 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
19511         LDKFundingCreated this_obj_conv;
19512         this_obj_conv.inner = (void*)(this_obj & (~1));
19513         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19514         FundingCreated_free(this_obj_conv);
19515 }
19516
19517 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
19518         LDKFundingCreated this_ptr_conv;
19519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19520         this_ptr_conv.is_owned = false;
19521         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19522         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
19523         return ret_arr;
19524 }
19525
19526 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
19527         LDKFundingCreated this_ptr_conv;
19528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19529         this_ptr_conv.is_owned = false;
19530         LDKThirtyTwoBytes val_ref;
19531         CHECK(*((uint32_t*)val) == 32);
19532         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19533         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
19534 }
19535
19536 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
19537         LDKFundingCreated this_ptr_conv;
19538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19539         this_ptr_conv.is_owned = false;
19540         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19541         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
19542         return ret_arr;
19543 }
19544
19545 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
19546         LDKFundingCreated this_ptr_conv;
19547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19548         this_ptr_conv.is_owned = false;
19549         LDKThirtyTwoBytes val_ref;
19550         CHECK(*((uint32_t*)val) == 32);
19551         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19552         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
19553 }
19554
19555 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
19556         LDKFundingCreated this_ptr_conv;
19557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19558         this_ptr_conv.is_owned = false;
19559         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
19560         return ret_val;
19561 }
19562
19563 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
19564         LDKFundingCreated this_ptr_conv;
19565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19566         this_ptr_conv.is_owned = false;
19567         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
19568 }
19569
19570 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
19571         LDKFundingCreated this_ptr_conv;
19572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19573         this_ptr_conv.is_owned = false;
19574         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19575         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
19576         return ret_arr;
19577 }
19578
19579 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
19580         LDKFundingCreated this_ptr_conv;
19581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19582         this_ptr_conv.is_owned = false;
19583         LDKSignature val_ref;
19584         CHECK(*((uint32_t*)val) == 64);
19585         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19586         FundingCreated_set_signature(&this_ptr_conv, val_ref);
19587 }
19588
19589 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) {
19590         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
19591         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
19592         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
19593         LDKThirtyTwoBytes funding_txid_arg_ref;
19594         CHECK(*((uint32_t*)funding_txid_arg) == 32);
19595         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
19596         LDKSignature signature_arg_ref;
19597         CHECK(*((uint32_t*)signature_arg) == 64);
19598         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
19599         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
19600         uint64_t ret_ref = 0;
19601         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19602         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19603         ret_ref = (uint64_t)ret_var.inner;
19604         if (ret_var.is_owned) {
19605                 ret_ref |= 1;
19606         }
19607         return ret_ref;
19608 }
19609
19610 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
19611         LDKFundingCreated orig_conv;
19612         orig_conv.inner = (void*)(orig & (~1));
19613         orig_conv.is_owned = false;
19614         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
19615         uint64_t ret_ref = 0;
19616         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19617         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19618         ret_ref = (uint64_t)ret_var.inner;
19619         if (ret_var.is_owned) {
19620                 ret_ref |= 1;
19621         }
19622         return ret_ref;
19623 }
19624
19625 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
19626         LDKFundingSigned this_obj_conv;
19627         this_obj_conv.inner = (void*)(this_obj & (~1));
19628         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19629         FundingSigned_free(this_obj_conv);
19630 }
19631
19632 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
19633         LDKFundingSigned this_ptr_conv;
19634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19635         this_ptr_conv.is_owned = false;
19636         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19637         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
19638         return ret_arr;
19639 }
19640
19641 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
19642         LDKFundingSigned this_ptr_conv;
19643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19644         this_ptr_conv.is_owned = false;
19645         LDKThirtyTwoBytes val_ref;
19646         CHECK(*((uint32_t*)val) == 32);
19647         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19648         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
19649 }
19650
19651 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
19652         LDKFundingSigned this_ptr_conv;
19653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19654         this_ptr_conv.is_owned = false;
19655         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19656         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
19657         return ret_arr;
19658 }
19659
19660 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
19661         LDKFundingSigned this_ptr_conv;
19662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19663         this_ptr_conv.is_owned = false;
19664         LDKSignature val_ref;
19665         CHECK(*((uint32_t*)val) == 64);
19666         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19667         FundingSigned_set_signature(&this_ptr_conv, val_ref);
19668 }
19669
19670 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
19671         LDKThirtyTwoBytes channel_id_arg_ref;
19672         CHECK(*((uint32_t*)channel_id_arg) == 32);
19673         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
19674         LDKSignature signature_arg_ref;
19675         CHECK(*((uint32_t*)signature_arg) == 64);
19676         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
19677         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
19678         uint64_t ret_ref = 0;
19679         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19680         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19681         ret_ref = (uint64_t)ret_var.inner;
19682         if (ret_var.is_owned) {
19683                 ret_ref |= 1;
19684         }
19685         return ret_ref;
19686 }
19687
19688 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
19689         LDKFundingSigned orig_conv;
19690         orig_conv.inner = (void*)(orig & (~1));
19691         orig_conv.is_owned = false;
19692         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
19693         uint64_t ret_ref = 0;
19694         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19695         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19696         ret_ref = (uint64_t)ret_var.inner;
19697         if (ret_var.is_owned) {
19698                 ret_ref |= 1;
19699         }
19700         return ret_ref;
19701 }
19702
19703 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
19704         LDKFundingLocked this_obj_conv;
19705         this_obj_conv.inner = (void*)(this_obj & (~1));
19706         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19707         FundingLocked_free(this_obj_conv);
19708 }
19709
19710 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
19711         LDKFundingLocked this_ptr_conv;
19712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19713         this_ptr_conv.is_owned = false;
19714         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19715         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
19716         return ret_arr;
19717 }
19718
19719 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
19720         LDKFundingLocked this_ptr_conv;
19721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19722         this_ptr_conv.is_owned = false;
19723         LDKThirtyTwoBytes val_ref;
19724         CHECK(*((uint32_t*)val) == 32);
19725         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19726         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
19727 }
19728
19729 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
19730         LDKFundingLocked this_ptr_conv;
19731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19732         this_ptr_conv.is_owned = false;
19733         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19734         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
19735         return ret_arr;
19736 }
19737
19738 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
19739         LDKFundingLocked this_ptr_conv;
19740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19741         this_ptr_conv.is_owned = false;
19742         LDKPublicKey val_ref;
19743         CHECK(*((uint32_t*)val) == 33);
19744         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19745         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
19746 }
19747
19748 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
19749         LDKThirtyTwoBytes channel_id_arg_ref;
19750         CHECK(*((uint32_t*)channel_id_arg) == 32);
19751         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
19752         LDKPublicKey next_per_commitment_point_arg_ref;
19753         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
19754         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
19755         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
19756         uint64_t ret_ref = 0;
19757         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19758         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19759         ret_ref = (uint64_t)ret_var.inner;
19760         if (ret_var.is_owned) {
19761                 ret_ref |= 1;
19762         }
19763         return ret_ref;
19764 }
19765
19766 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
19767         LDKFundingLocked orig_conv;
19768         orig_conv.inner = (void*)(orig & (~1));
19769         orig_conv.is_owned = false;
19770         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
19771         uint64_t ret_ref = 0;
19772         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19773         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19774         ret_ref = (uint64_t)ret_var.inner;
19775         if (ret_var.is_owned) {
19776                 ret_ref |= 1;
19777         }
19778         return ret_ref;
19779 }
19780
19781 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
19782         LDKShutdown this_obj_conv;
19783         this_obj_conv.inner = (void*)(this_obj & (~1));
19784         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19785         Shutdown_free(this_obj_conv);
19786 }
19787
19788 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
19789         LDKShutdown this_ptr_conv;
19790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19791         this_ptr_conv.is_owned = false;
19792         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19793         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
19794         return ret_arr;
19795 }
19796
19797 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
19798         LDKShutdown this_ptr_conv;
19799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19800         this_ptr_conv.is_owned = false;
19801         LDKThirtyTwoBytes val_ref;
19802         CHECK(*((uint32_t*)val) == 32);
19803         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19804         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
19805 }
19806
19807 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
19808         LDKShutdown this_ptr_conv;
19809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19810         this_ptr_conv.is_owned = false;
19811         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
19812         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19813         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19814         return ret_arr;
19815 }
19816
19817 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
19818         LDKShutdown this_ptr_conv;
19819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19820         this_ptr_conv.is_owned = false;
19821         LDKCVec_u8Z val_ref;
19822         val_ref.datalen = *((uint32_t*)val);
19823         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
19824         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
19825         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
19826 }
19827
19828 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
19829         LDKThirtyTwoBytes channel_id_arg_ref;
19830         CHECK(*((uint32_t*)channel_id_arg) == 32);
19831         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
19832         LDKCVec_u8Z scriptpubkey_arg_ref;
19833         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
19834         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
19835         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
19836         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
19837         uint64_t ret_ref = 0;
19838         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19839         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19840         ret_ref = (uint64_t)ret_var.inner;
19841         if (ret_var.is_owned) {
19842                 ret_ref |= 1;
19843         }
19844         return ret_ref;
19845 }
19846
19847 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
19848         LDKShutdown orig_conv;
19849         orig_conv.inner = (void*)(orig & (~1));
19850         orig_conv.is_owned = false;
19851         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
19852         uint64_t ret_ref = 0;
19853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19855         ret_ref = (uint64_t)ret_var.inner;
19856         if (ret_var.is_owned) {
19857                 ret_ref |= 1;
19858         }
19859         return ret_ref;
19860 }
19861
19862 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
19863         LDKClosingSignedFeeRange this_obj_conv;
19864         this_obj_conv.inner = (void*)(this_obj & (~1));
19865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19866         ClosingSignedFeeRange_free(this_obj_conv);
19867 }
19868
19869 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
19870         LDKClosingSignedFeeRange this_ptr_conv;
19871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19872         this_ptr_conv.is_owned = false;
19873         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
19874         return ret_val;
19875 }
19876
19877 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
19878         LDKClosingSignedFeeRange this_ptr_conv;
19879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19880         this_ptr_conv.is_owned = false;
19881         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
19882 }
19883
19884 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
19885         LDKClosingSignedFeeRange this_ptr_conv;
19886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19887         this_ptr_conv.is_owned = false;
19888         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
19889         return ret_val;
19890 }
19891
19892 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
19893         LDKClosingSignedFeeRange this_ptr_conv;
19894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19895         this_ptr_conv.is_owned = false;
19896         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
19897 }
19898
19899 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
19900         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
19901         uint64_t ret_ref = 0;
19902         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19903         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19904         ret_ref = (uint64_t)ret_var.inner;
19905         if (ret_var.is_owned) {
19906                 ret_ref |= 1;
19907         }
19908         return ret_ref;
19909 }
19910
19911 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
19912         LDKClosingSignedFeeRange orig_conv;
19913         orig_conv.inner = (void*)(orig & (~1));
19914         orig_conv.is_owned = false;
19915         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
19916         uint64_t ret_ref = 0;
19917         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19918         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19919         ret_ref = (uint64_t)ret_var.inner;
19920         if (ret_var.is_owned) {
19921                 ret_ref |= 1;
19922         }
19923         return ret_ref;
19924 }
19925
19926 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
19927         LDKClosingSigned this_obj_conv;
19928         this_obj_conv.inner = (void*)(this_obj & (~1));
19929         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19930         ClosingSigned_free(this_obj_conv);
19931 }
19932
19933 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
19934         LDKClosingSigned this_ptr_conv;
19935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19936         this_ptr_conv.is_owned = false;
19937         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19938         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
19939         return ret_arr;
19940 }
19941
19942 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
19943         LDKClosingSigned this_ptr_conv;
19944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19945         this_ptr_conv.is_owned = false;
19946         LDKThirtyTwoBytes val_ref;
19947         CHECK(*((uint32_t*)val) == 32);
19948         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19949         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
19950 }
19951
19952 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
19953         LDKClosingSigned this_ptr_conv;
19954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19955         this_ptr_conv.is_owned = false;
19956         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
19957         return ret_val;
19958 }
19959
19960 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
19961         LDKClosingSigned this_ptr_conv;
19962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19963         this_ptr_conv.is_owned = false;
19964         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
19965 }
19966
19967 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
19968         LDKClosingSigned this_ptr_conv;
19969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19970         this_ptr_conv.is_owned = false;
19971         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19972         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
19973         return ret_arr;
19974 }
19975
19976 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
19977         LDKClosingSigned this_ptr_conv;
19978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19979         this_ptr_conv.is_owned = false;
19980         LDKSignature val_ref;
19981         CHECK(*((uint32_t*)val) == 64);
19982         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19983         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
19984 }
19985
19986 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
19987         LDKClosingSigned this_ptr_conv;
19988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19989         this_ptr_conv.is_owned = false;
19990         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
19991         uint64_t ret_ref = 0;
19992         if ((uint64_t)ret_var.inner > 4096) {
19993                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19994                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19995                 ret_ref = (uint64_t)ret_var.inner;
19996                 if (ret_var.is_owned) {
19997                         ret_ref |= 1;
19998                 }
19999         }
20000         return ret_ref;
20001 }
20002
20003 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
20004         LDKClosingSigned this_ptr_conv;
20005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20006         this_ptr_conv.is_owned = false;
20007         LDKClosingSignedFeeRange val_conv;
20008         val_conv.inner = (void*)(val & (~1));
20009         val_conv.is_owned = (val & 1) || (val == 0);
20010         val_conv = ClosingSignedFeeRange_clone(&val_conv);
20011         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
20012 }
20013
20014 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) {
20015         LDKThirtyTwoBytes channel_id_arg_ref;
20016         CHECK(*((uint32_t*)channel_id_arg) == 32);
20017         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
20018         LDKSignature signature_arg_ref;
20019         CHECK(*((uint32_t*)signature_arg) == 64);
20020         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
20021         LDKClosingSignedFeeRange fee_range_arg_conv;
20022         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
20023         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
20024         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
20025         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
20026         uint64_t ret_ref = 0;
20027         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20028         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20029         ret_ref = (uint64_t)ret_var.inner;
20030         if (ret_var.is_owned) {
20031                 ret_ref |= 1;
20032         }
20033         return ret_ref;
20034 }
20035
20036 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
20037         LDKClosingSigned orig_conv;
20038         orig_conv.inner = (void*)(orig & (~1));
20039         orig_conv.is_owned = false;
20040         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
20041         uint64_t ret_ref = 0;
20042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20044         ret_ref = (uint64_t)ret_var.inner;
20045         if (ret_var.is_owned) {
20046                 ret_ref |= 1;
20047         }
20048         return ret_ref;
20049 }
20050
20051 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
20052         LDKUpdateAddHTLC this_obj_conv;
20053         this_obj_conv.inner = (void*)(this_obj & (~1));
20054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20055         UpdateAddHTLC_free(this_obj_conv);
20056 }
20057
20058 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
20059         LDKUpdateAddHTLC this_ptr_conv;
20060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20061         this_ptr_conv.is_owned = false;
20062         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20063         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
20064         return ret_arr;
20065 }
20066
20067 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
20068         LDKUpdateAddHTLC this_ptr_conv;
20069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20070         this_ptr_conv.is_owned = false;
20071         LDKThirtyTwoBytes val_ref;
20072         CHECK(*((uint32_t*)val) == 32);
20073         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20074         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
20075 }
20076
20077 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
20078         LDKUpdateAddHTLC this_ptr_conv;
20079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20080         this_ptr_conv.is_owned = false;
20081         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
20082         return ret_val;
20083 }
20084
20085 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
20086         LDKUpdateAddHTLC this_ptr_conv;
20087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20088         this_ptr_conv.is_owned = false;
20089         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
20090 }
20091
20092 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
20093         LDKUpdateAddHTLC this_ptr_conv;
20094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20095         this_ptr_conv.is_owned = false;
20096         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
20097         return ret_val;
20098 }
20099
20100 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
20101         LDKUpdateAddHTLC this_ptr_conv;
20102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20103         this_ptr_conv.is_owned = false;
20104         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
20105 }
20106
20107 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
20108         LDKUpdateAddHTLC this_ptr_conv;
20109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20110         this_ptr_conv.is_owned = false;
20111         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20112         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
20113         return ret_arr;
20114 }
20115
20116 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
20117         LDKUpdateAddHTLC this_ptr_conv;
20118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20119         this_ptr_conv.is_owned = false;
20120         LDKThirtyTwoBytes val_ref;
20121         CHECK(*((uint32_t*)val) == 32);
20122         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20123         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
20124 }
20125
20126 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
20127         LDKUpdateAddHTLC this_ptr_conv;
20128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20129         this_ptr_conv.is_owned = false;
20130         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
20131         return ret_val;
20132 }
20133
20134 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
20135         LDKUpdateAddHTLC this_ptr_conv;
20136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20137         this_ptr_conv.is_owned = false;
20138         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
20139 }
20140
20141 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
20142         LDKUpdateAddHTLC orig_conv;
20143         orig_conv.inner = (void*)(orig & (~1));
20144         orig_conv.is_owned = false;
20145         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
20146         uint64_t ret_ref = 0;
20147         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20148         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20149         ret_ref = (uint64_t)ret_var.inner;
20150         if (ret_var.is_owned) {
20151                 ret_ref |= 1;
20152         }
20153         return ret_ref;
20154 }
20155
20156 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
20157         LDKUpdateFulfillHTLC this_obj_conv;
20158         this_obj_conv.inner = (void*)(this_obj & (~1));
20159         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20160         UpdateFulfillHTLC_free(this_obj_conv);
20161 }
20162
20163 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
20164         LDKUpdateFulfillHTLC this_ptr_conv;
20165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20166         this_ptr_conv.is_owned = false;
20167         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20168         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
20169         return ret_arr;
20170 }
20171
20172 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
20173         LDKUpdateFulfillHTLC this_ptr_conv;
20174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20175         this_ptr_conv.is_owned = false;
20176         LDKThirtyTwoBytes val_ref;
20177         CHECK(*((uint32_t*)val) == 32);
20178         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20179         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
20180 }
20181
20182 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
20183         LDKUpdateFulfillHTLC this_ptr_conv;
20184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20185         this_ptr_conv.is_owned = false;
20186         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
20187         return ret_val;
20188 }
20189
20190 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
20191         LDKUpdateFulfillHTLC this_ptr_conv;
20192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20193         this_ptr_conv.is_owned = false;
20194         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
20195 }
20196
20197 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
20198         LDKUpdateFulfillHTLC this_ptr_conv;
20199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20200         this_ptr_conv.is_owned = false;
20201         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20202         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
20203         return ret_arr;
20204 }
20205
20206 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
20207         LDKUpdateFulfillHTLC this_ptr_conv;
20208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20209         this_ptr_conv.is_owned = false;
20210         LDKThirtyTwoBytes val_ref;
20211         CHECK(*((uint32_t*)val) == 32);
20212         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20213         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
20214 }
20215
20216 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
20217         LDKThirtyTwoBytes channel_id_arg_ref;
20218         CHECK(*((uint32_t*)channel_id_arg) == 32);
20219         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
20220         LDKThirtyTwoBytes payment_preimage_arg_ref;
20221         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
20222         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
20223         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
20224         uint64_t ret_ref = 0;
20225         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20226         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20227         ret_ref = (uint64_t)ret_var.inner;
20228         if (ret_var.is_owned) {
20229                 ret_ref |= 1;
20230         }
20231         return ret_ref;
20232 }
20233
20234 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
20235         LDKUpdateFulfillHTLC orig_conv;
20236         orig_conv.inner = (void*)(orig & (~1));
20237         orig_conv.is_owned = false;
20238         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
20239         uint64_t ret_ref = 0;
20240         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20241         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20242         ret_ref = (uint64_t)ret_var.inner;
20243         if (ret_var.is_owned) {
20244                 ret_ref |= 1;
20245         }
20246         return ret_ref;
20247 }
20248
20249 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
20250         LDKUpdateFailHTLC this_obj_conv;
20251         this_obj_conv.inner = (void*)(this_obj & (~1));
20252         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20253         UpdateFailHTLC_free(this_obj_conv);
20254 }
20255
20256 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
20257         LDKUpdateFailHTLC this_ptr_conv;
20258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20259         this_ptr_conv.is_owned = false;
20260         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20261         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
20262         return ret_arr;
20263 }
20264
20265 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
20266         LDKUpdateFailHTLC this_ptr_conv;
20267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20268         this_ptr_conv.is_owned = false;
20269         LDKThirtyTwoBytes val_ref;
20270         CHECK(*((uint32_t*)val) == 32);
20271         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20272         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
20273 }
20274
20275 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
20276         LDKUpdateFailHTLC this_ptr_conv;
20277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20278         this_ptr_conv.is_owned = false;
20279         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
20280         return ret_val;
20281 }
20282
20283 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
20284         LDKUpdateFailHTLC this_ptr_conv;
20285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20286         this_ptr_conv.is_owned = false;
20287         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
20288 }
20289
20290 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
20291         LDKUpdateFailHTLC orig_conv;
20292         orig_conv.inner = (void*)(orig & (~1));
20293         orig_conv.is_owned = false;
20294         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
20295         uint64_t ret_ref = 0;
20296         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20297         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20298         ret_ref = (uint64_t)ret_var.inner;
20299         if (ret_var.is_owned) {
20300                 ret_ref |= 1;
20301         }
20302         return ret_ref;
20303 }
20304
20305 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
20306         LDKUpdateFailMalformedHTLC this_obj_conv;
20307         this_obj_conv.inner = (void*)(this_obj & (~1));
20308         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20309         UpdateFailMalformedHTLC_free(this_obj_conv);
20310 }
20311
20312 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
20313         LDKUpdateFailMalformedHTLC this_ptr_conv;
20314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20315         this_ptr_conv.is_owned = false;
20316         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20317         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
20318         return ret_arr;
20319 }
20320
20321 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
20322         LDKUpdateFailMalformedHTLC this_ptr_conv;
20323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20324         this_ptr_conv.is_owned = false;
20325         LDKThirtyTwoBytes val_ref;
20326         CHECK(*((uint32_t*)val) == 32);
20327         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20328         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
20329 }
20330
20331 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
20332         LDKUpdateFailMalformedHTLC this_ptr_conv;
20333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20334         this_ptr_conv.is_owned = false;
20335         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
20336         return ret_val;
20337 }
20338
20339 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
20340         LDKUpdateFailMalformedHTLC this_ptr_conv;
20341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20342         this_ptr_conv.is_owned = false;
20343         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
20344 }
20345
20346 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
20347         LDKUpdateFailMalformedHTLC this_ptr_conv;
20348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20349         this_ptr_conv.is_owned = false;
20350         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
20351         return ret_val;
20352 }
20353
20354 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
20355         LDKUpdateFailMalformedHTLC this_ptr_conv;
20356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20357         this_ptr_conv.is_owned = false;
20358         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
20359 }
20360
20361 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
20362         LDKUpdateFailMalformedHTLC orig_conv;
20363         orig_conv.inner = (void*)(orig & (~1));
20364         orig_conv.is_owned = false;
20365         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
20366         uint64_t ret_ref = 0;
20367         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20368         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20369         ret_ref = (uint64_t)ret_var.inner;
20370         if (ret_var.is_owned) {
20371                 ret_ref |= 1;
20372         }
20373         return ret_ref;
20374 }
20375
20376 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
20377         LDKCommitmentSigned this_obj_conv;
20378         this_obj_conv.inner = (void*)(this_obj & (~1));
20379         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20380         CommitmentSigned_free(this_obj_conv);
20381 }
20382
20383 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
20384         LDKCommitmentSigned this_ptr_conv;
20385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20386         this_ptr_conv.is_owned = false;
20387         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20388         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
20389         return ret_arr;
20390 }
20391
20392 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
20393         LDKCommitmentSigned this_ptr_conv;
20394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20395         this_ptr_conv.is_owned = false;
20396         LDKThirtyTwoBytes val_ref;
20397         CHECK(*((uint32_t*)val) == 32);
20398         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20399         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
20400 }
20401
20402 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
20403         LDKCommitmentSigned this_ptr_conv;
20404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20405         this_ptr_conv.is_owned = false;
20406         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
20407         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
20408         return ret_arr;
20409 }
20410
20411 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
20412         LDKCommitmentSigned this_ptr_conv;
20413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20414         this_ptr_conv.is_owned = false;
20415         LDKSignature val_ref;
20416         CHECK(*((uint32_t*)val) == 64);
20417         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
20418         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
20419 }
20420
20421 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
20422         LDKCommitmentSigned this_ptr_conv;
20423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20424         this_ptr_conv.is_owned = false;
20425         LDKCVec_SignatureZ val_constr;
20426         val_constr.datalen = *((uint32_t*)val);
20427         if (val_constr.datalen > 0)
20428                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
20429         else
20430                 val_constr.data = NULL;
20431         int8_tArray* val_vals = (int8_tArray*)(val + 4);
20432         for (size_t m = 0; m < val_constr.datalen; m++) {
20433                 int8_tArray val_conv_12 = val_vals[m];
20434                 LDKSignature val_conv_12_ref;
20435                 CHECK(*((uint32_t*)val_conv_12) == 64);
20436                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
20437                 val_constr.data[m] = val_conv_12_ref;
20438         }
20439         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
20440 }
20441
20442 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
20443         LDKThirtyTwoBytes channel_id_arg_ref;
20444         CHECK(*((uint32_t*)channel_id_arg) == 32);
20445         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
20446         LDKSignature signature_arg_ref;
20447         CHECK(*((uint32_t*)signature_arg) == 64);
20448         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
20449         LDKCVec_SignatureZ htlc_signatures_arg_constr;
20450         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
20451         if (htlc_signatures_arg_constr.datalen > 0)
20452                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
20453         else
20454                 htlc_signatures_arg_constr.data = NULL;
20455         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
20456         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
20457                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
20458                 LDKSignature htlc_signatures_arg_conv_12_ref;
20459                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
20460                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
20461                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
20462         }
20463         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
20464         uint64_t ret_ref = 0;
20465         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20466         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20467         ret_ref = (uint64_t)ret_var.inner;
20468         if (ret_var.is_owned) {
20469                 ret_ref |= 1;
20470         }
20471         return ret_ref;
20472 }
20473
20474 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
20475         LDKCommitmentSigned orig_conv;
20476         orig_conv.inner = (void*)(orig & (~1));
20477         orig_conv.is_owned = false;
20478         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
20479         uint64_t ret_ref = 0;
20480         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20481         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20482         ret_ref = (uint64_t)ret_var.inner;
20483         if (ret_var.is_owned) {
20484                 ret_ref |= 1;
20485         }
20486         return ret_ref;
20487 }
20488
20489 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
20490         LDKRevokeAndACK this_obj_conv;
20491         this_obj_conv.inner = (void*)(this_obj & (~1));
20492         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20493         RevokeAndACK_free(this_obj_conv);
20494 }
20495
20496 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
20497         LDKRevokeAndACK this_ptr_conv;
20498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20499         this_ptr_conv.is_owned = false;
20500         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20501         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
20502         return ret_arr;
20503 }
20504
20505 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
20506         LDKRevokeAndACK this_ptr_conv;
20507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20508         this_ptr_conv.is_owned = false;
20509         LDKThirtyTwoBytes val_ref;
20510         CHECK(*((uint32_t*)val) == 32);
20511         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20512         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
20513 }
20514
20515 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
20516         LDKRevokeAndACK this_ptr_conv;
20517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20518         this_ptr_conv.is_owned = false;
20519         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20520         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
20521         return ret_arr;
20522 }
20523
20524 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
20525         LDKRevokeAndACK this_ptr_conv;
20526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20527         this_ptr_conv.is_owned = false;
20528         LDKThirtyTwoBytes val_ref;
20529         CHECK(*((uint32_t*)val) == 32);
20530         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20531         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
20532 }
20533
20534 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
20535         LDKRevokeAndACK this_ptr_conv;
20536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20537         this_ptr_conv.is_owned = false;
20538         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20539         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
20540         return ret_arr;
20541 }
20542
20543 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
20544         LDKRevokeAndACK this_ptr_conv;
20545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20546         this_ptr_conv.is_owned = false;
20547         LDKPublicKey val_ref;
20548         CHECK(*((uint32_t*)val) == 33);
20549         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20550         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
20551 }
20552
20553 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) {
20554         LDKThirtyTwoBytes channel_id_arg_ref;
20555         CHECK(*((uint32_t*)channel_id_arg) == 32);
20556         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
20557         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
20558         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
20559         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
20560         LDKPublicKey next_per_commitment_point_arg_ref;
20561         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
20562         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
20563         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
20564         uint64_t ret_ref = 0;
20565         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20566         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20567         ret_ref = (uint64_t)ret_var.inner;
20568         if (ret_var.is_owned) {
20569                 ret_ref |= 1;
20570         }
20571         return ret_ref;
20572 }
20573
20574 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
20575         LDKRevokeAndACK orig_conv;
20576         orig_conv.inner = (void*)(orig & (~1));
20577         orig_conv.is_owned = false;
20578         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
20579         uint64_t ret_ref = 0;
20580         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20581         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20582         ret_ref = (uint64_t)ret_var.inner;
20583         if (ret_var.is_owned) {
20584                 ret_ref |= 1;
20585         }
20586         return ret_ref;
20587 }
20588
20589 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
20590         LDKUpdateFee this_obj_conv;
20591         this_obj_conv.inner = (void*)(this_obj & (~1));
20592         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20593         UpdateFee_free(this_obj_conv);
20594 }
20595
20596 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
20597         LDKUpdateFee this_ptr_conv;
20598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20599         this_ptr_conv.is_owned = false;
20600         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20601         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
20602         return ret_arr;
20603 }
20604
20605 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
20606         LDKUpdateFee this_ptr_conv;
20607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20608         this_ptr_conv.is_owned = false;
20609         LDKThirtyTwoBytes val_ref;
20610         CHECK(*((uint32_t*)val) == 32);
20611         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20612         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
20613 }
20614
20615 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
20616         LDKUpdateFee this_ptr_conv;
20617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20618         this_ptr_conv.is_owned = false;
20619         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
20620         return ret_val;
20621 }
20622
20623 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
20624         LDKUpdateFee this_ptr_conv;
20625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20626         this_ptr_conv.is_owned = false;
20627         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
20628 }
20629
20630 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
20631         LDKThirtyTwoBytes channel_id_arg_ref;
20632         CHECK(*((uint32_t*)channel_id_arg) == 32);
20633         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
20634         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
20635         uint64_t ret_ref = 0;
20636         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20637         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20638         ret_ref = (uint64_t)ret_var.inner;
20639         if (ret_var.is_owned) {
20640                 ret_ref |= 1;
20641         }
20642         return ret_ref;
20643 }
20644
20645 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
20646         LDKUpdateFee orig_conv;
20647         orig_conv.inner = (void*)(orig & (~1));
20648         orig_conv.is_owned = false;
20649         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
20650         uint64_t ret_ref = 0;
20651         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20652         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20653         ret_ref = (uint64_t)ret_var.inner;
20654         if (ret_var.is_owned) {
20655                 ret_ref |= 1;
20656         }
20657         return ret_ref;
20658 }
20659
20660 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
20661         LDKDataLossProtect this_obj_conv;
20662         this_obj_conv.inner = (void*)(this_obj & (~1));
20663         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20664         DataLossProtect_free(this_obj_conv);
20665 }
20666
20667 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
20668         LDKDataLossProtect this_ptr_conv;
20669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20670         this_ptr_conv.is_owned = false;
20671         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20672         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
20673         return ret_arr;
20674 }
20675
20676 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
20677         LDKDataLossProtect this_ptr_conv;
20678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20679         this_ptr_conv.is_owned = false;
20680         LDKThirtyTwoBytes val_ref;
20681         CHECK(*((uint32_t*)val) == 32);
20682         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20683         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
20684 }
20685
20686 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
20687         LDKDataLossProtect this_ptr_conv;
20688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20689         this_ptr_conv.is_owned = false;
20690         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20691         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
20692         return ret_arr;
20693 }
20694
20695 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
20696         LDKDataLossProtect this_ptr_conv;
20697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20698         this_ptr_conv.is_owned = false;
20699         LDKPublicKey val_ref;
20700         CHECK(*((uint32_t*)val) == 33);
20701         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20702         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
20703 }
20704
20705 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
20706         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
20707         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
20708         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
20709         LDKPublicKey my_current_per_commitment_point_arg_ref;
20710         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
20711         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
20712         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
20713         uint64_t ret_ref = 0;
20714         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20715         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20716         ret_ref = (uint64_t)ret_var.inner;
20717         if (ret_var.is_owned) {
20718                 ret_ref |= 1;
20719         }
20720         return ret_ref;
20721 }
20722
20723 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
20724         LDKDataLossProtect orig_conv;
20725         orig_conv.inner = (void*)(orig & (~1));
20726         orig_conv.is_owned = false;
20727         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
20728         uint64_t ret_ref = 0;
20729         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20730         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20731         ret_ref = (uint64_t)ret_var.inner;
20732         if (ret_var.is_owned) {
20733                 ret_ref |= 1;
20734         }
20735         return ret_ref;
20736 }
20737
20738 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
20739         LDKChannelReestablish this_obj_conv;
20740         this_obj_conv.inner = (void*)(this_obj & (~1));
20741         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20742         ChannelReestablish_free(this_obj_conv);
20743 }
20744
20745 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
20746         LDKChannelReestablish this_ptr_conv;
20747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20748         this_ptr_conv.is_owned = false;
20749         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20750         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
20751         return ret_arr;
20752 }
20753
20754 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
20755         LDKChannelReestablish this_ptr_conv;
20756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20757         this_ptr_conv.is_owned = false;
20758         LDKThirtyTwoBytes val_ref;
20759         CHECK(*((uint32_t*)val) == 32);
20760         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20761         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
20762 }
20763
20764 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
20765         LDKChannelReestablish this_ptr_conv;
20766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20767         this_ptr_conv.is_owned = false;
20768         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
20769         return ret_val;
20770 }
20771
20772 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
20773         LDKChannelReestablish this_ptr_conv;
20774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20775         this_ptr_conv.is_owned = false;
20776         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
20777 }
20778
20779 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
20780         LDKChannelReestablish this_ptr_conv;
20781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20782         this_ptr_conv.is_owned = false;
20783         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
20784         return ret_val;
20785 }
20786
20787 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
20788         LDKChannelReestablish this_ptr_conv;
20789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20790         this_ptr_conv.is_owned = false;
20791         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
20792 }
20793
20794 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
20795         LDKChannelReestablish orig_conv;
20796         orig_conv.inner = (void*)(orig & (~1));
20797         orig_conv.is_owned = false;
20798         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
20799         uint64_t ret_ref = 0;
20800         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20801         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20802         ret_ref = (uint64_t)ret_var.inner;
20803         if (ret_var.is_owned) {
20804                 ret_ref |= 1;
20805         }
20806         return ret_ref;
20807 }
20808
20809 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
20810         LDKAnnouncementSignatures this_obj_conv;
20811         this_obj_conv.inner = (void*)(this_obj & (~1));
20812         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20813         AnnouncementSignatures_free(this_obj_conv);
20814 }
20815
20816 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
20817         LDKAnnouncementSignatures this_ptr_conv;
20818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20819         this_ptr_conv.is_owned = false;
20820         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20821         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
20822         return ret_arr;
20823 }
20824
20825 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
20826         LDKAnnouncementSignatures this_ptr_conv;
20827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20828         this_ptr_conv.is_owned = false;
20829         LDKThirtyTwoBytes val_ref;
20830         CHECK(*((uint32_t*)val) == 32);
20831         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20832         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
20833 }
20834
20835 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
20836         LDKAnnouncementSignatures this_ptr_conv;
20837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20838         this_ptr_conv.is_owned = false;
20839         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
20840         return ret_val;
20841 }
20842
20843 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
20844         LDKAnnouncementSignatures this_ptr_conv;
20845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20846         this_ptr_conv.is_owned = false;
20847         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
20848 }
20849
20850 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
20851         LDKAnnouncementSignatures this_ptr_conv;
20852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20853         this_ptr_conv.is_owned = false;
20854         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
20855         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
20856         return ret_arr;
20857 }
20858
20859 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
20860         LDKAnnouncementSignatures this_ptr_conv;
20861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20862         this_ptr_conv.is_owned = false;
20863         LDKSignature val_ref;
20864         CHECK(*((uint32_t*)val) == 64);
20865         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
20866         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
20867 }
20868
20869 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
20870         LDKAnnouncementSignatures this_ptr_conv;
20871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20872         this_ptr_conv.is_owned = false;
20873         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
20874         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
20875         return ret_arr;
20876 }
20877
20878 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
20879         LDKAnnouncementSignatures this_ptr_conv;
20880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20881         this_ptr_conv.is_owned = false;
20882         LDKSignature val_ref;
20883         CHECK(*((uint32_t*)val) == 64);
20884         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
20885         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
20886 }
20887
20888 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) {
20889         LDKThirtyTwoBytes channel_id_arg_ref;
20890         CHECK(*((uint32_t*)channel_id_arg) == 32);
20891         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
20892         LDKSignature node_signature_arg_ref;
20893         CHECK(*((uint32_t*)node_signature_arg) == 64);
20894         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
20895         LDKSignature bitcoin_signature_arg_ref;
20896         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
20897         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
20898         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
20899         uint64_t ret_ref = 0;
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         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 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
20910         LDKAnnouncementSignatures orig_conv;
20911         orig_conv.inner = (void*)(orig & (~1));
20912         orig_conv.is_owned = false;
20913         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
20914         uint64_t ret_ref = 0;
20915         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20916         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20917         ret_ref = (uint64_t)ret_var.inner;
20918         if (ret_var.is_owned) {
20919                 ret_ref |= 1;
20920         }
20921         return ret_ref;
20922 }
20923
20924 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
20925         if ((this_ptr & 1) != 0) return;
20926         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20927         CHECK_ACCESS(this_ptr_ptr);
20928         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
20929         FREE((void*)this_ptr);
20930         NetAddress_free(this_ptr_conv);
20931 }
20932
20933 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
20934         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
20935         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
20936         *ret_copy = NetAddress_clone(orig_conv);
20937         uint64_t ret_ref = (uint64_t)ret_copy;
20938         return ret_ref;
20939 }
20940
20941 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
20942         LDKFourBytes addr_ref;
20943         CHECK(*((uint32_t*)addr) == 4);
20944         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 4);
20945         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
20946         *ret_copy = NetAddress_ipv4(addr_ref, port);
20947         uint64_t ret_ref = (uint64_t)ret_copy;
20948         return ret_ref;
20949 }
20950
20951 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
20952         LDKSixteenBytes addr_ref;
20953         CHECK(*((uint32_t*)addr) == 16);
20954         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 16);
20955         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
20956         *ret_copy = NetAddress_ipv6(addr_ref, port);
20957         uint64_t ret_ref = (uint64_t)ret_copy;
20958         return ret_ref;
20959 }
20960
20961 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v2(int8_tArray addr, int16_t port) {
20962         LDKTenBytes addr_ref;
20963         CHECK(*((uint32_t*)addr) == 10);
20964         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 10);
20965         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
20966         *ret_copy = NetAddress_onion_v2(addr_ref, port);
20967         uint64_t ret_ref = (uint64_t)ret_copy;
20968         return ret_ref;
20969 }
20970
20971 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v3(int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
20972         LDKThirtyTwoBytes ed25519_pubkey_ref;
20973         CHECK(*((uint32_t*)ed25519_pubkey) == 32);
20974         memcpy(ed25519_pubkey_ref.data, (uint8_t*)(ed25519_pubkey + 4), 32);
20975         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
20976         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
20977         uint64_t ret_ref = (uint64_t)ret_copy;
20978         return ret_ref;
20979 }
20980
20981 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
20982         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
20983         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
20984         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20985         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20986         CVec_u8Z_free(ret_var);
20987         return ret_arr;
20988 }
20989
20990 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
20991         LDKu8slice ser_ref;
20992         ser_ref.datalen = *((uint32_t*)ser);
20993         ser_ref.data = (int8_t*)(ser + 4);
20994         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20995         *ret_conv = NetAddress_read(ser_ref);
20996         return (uint64_t)ret_conv;
20997 }
20998
20999 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
21000         LDKUnsignedNodeAnnouncement this_obj_conv;
21001         this_obj_conv.inner = (void*)(this_obj & (~1));
21002         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21003         UnsignedNodeAnnouncement_free(this_obj_conv);
21004 }
21005
21006 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
21007         LDKUnsignedNodeAnnouncement this_ptr_conv;
21008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21009         this_ptr_conv.is_owned = false;
21010         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
21011         uint64_t ret_ref = 0;
21012         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21013         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21014         ret_ref = (uint64_t)ret_var.inner;
21015         if (ret_var.is_owned) {
21016                 ret_ref |= 1;
21017         }
21018         return ret_ref;
21019 }
21020
21021 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
21022         LDKUnsignedNodeAnnouncement this_ptr_conv;
21023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21024         this_ptr_conv.is_owned = false;
21025         LDKNodeFeatures val_conv;
21026         val_conv.inner = (void*)(val & (~1));
21027         val_conv.is_owned = (val & 1) || (val == 0);
21028         val_conv = NodeFeatures_clone(&val_conv);
21029         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
21030 }
21031
21032 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
21033         LDKUnsignedNodeAnnouncement this_ptr_conv;
21034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21035         this_ptr_conv.is_owned = false;
21036         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
21037         return ret_val;
21038 }
21039
21040 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
21041         LDKUnsignedNodeAnnouncement this_ptr_conv;
21042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21043         this_ptr_conv.is_owned = false;
21044         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
21045 }
21046
21047 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
21048         LDKUnsignedNodeAnnouncement this_ptr_conv;
21049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21050         this_ptr_conv.is_owned = false;
21051         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21052         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
21053         return ret_arr;
21054 }
21055
21056 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
21057         LDKUnsignedNodeAnnouncement this_ptr_conv;
21058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21059         this_ptr_conv.is_owned = false;
21060         LDKPublicKey val_ref;
21061         CHECK(*((uint32_t*)val) == 33);
21062         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21063         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
21064 }
21065
21066 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
21067         LDKUnsignedNodeAnnouncement this_ptr_conv;
21068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21069         this_ptr_conv.is_owned = false;
21070         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
21071         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
21072         return ret_arr;
21073 }
21074
21075 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
21076         LDKUnsignedNodeAnnouncement this_ptr_conv;
21077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21078         this_ptr_conv.is_owned = false;
21079         LDKThreeBytes val_ref;
21080         CHECK(*((uint32_t*)val) == 3);
21081         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
21082         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
21083 }
21084
21085 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
21086         LDKUnsignedNodeAnnouncement this_ptr_conv;
21087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21088         this_ptr_conv.is_owned = false;
21089         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21090         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
21091         return ret_arr;
21092 }
21093
21094 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
21095         LDKUnsignedNodeAnnouncement this_ptr_conv;
21096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21097         this_ptr_conv.is_owned = false;
21098         LDKThirtyTwoBytes val_ref;
21099         CHECK(*((uint32_t*)val) == 32);
21100         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
21101         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
21102 }
21103
21104 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
21105         LDKUnsignedNodeAnnouncement this_ptr_conv;
21106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21107         this_ptr_conv.is_owned = false;
21108         LDKCVec_NetAddressZ val_constr;
21109         val_constr.datalen = *((uint32_t*)val);
21110         if (val_constr.datalen > 0)
21111                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21112         else
21113                 val_constr.data = NULL;
21114         uint32_t* val_vals = (uint32_t*)(val + 4);
21115         for (size_t m = 0; m < val_constr.datalen; m++) {
21116                 uint32_t val_conv_12 = val_vals[m];
21117                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
21118                 CHECK_ACCESS(val_conv_12_ptr);
21119                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
21120                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
21121                 val_constr.data[m] = val_conv_12_conv;
21122         }
21123         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
21124 }
21125
21126 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
21127         LDKUnsignedNodeAnnouncement orig_conv;
21128         orig_conv.inner = (void*)(orig & (~1));
21129         orig_conv.is_owned = false;
21130         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
21131         uint64_t ret_ref = 0;
21132         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21133         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21134         ret_ref = (uint64_t)ret_var.inner;
21135         if (ret_var.is_owned) {
21136                 ret_ref |= 1;
21137         }
21138         return ret_ref;
21139 }
21140
21141 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
21142         LDKNodeAnnouncement this_obj_conv;
21143         this_obj_conv.inner = (void*)(this_obj & (~1));
21144         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21145         NodeAnnouncement_free(this_obj_conv);
21146 }
21147
21148 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
21149         LDKNodeAnnouncement 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(64, sizeof(uint8_t), "Native int8_tArray Bytes");
21153         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
21154         return ret_arr;
21155 }
21156
21157 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
21158         LDKNodeAnnouncement this_ptr_conv;
21159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21160         this_ptr_conv.is_owned = false;
21161         LDKSignature val_ref;
21162         CHECK(*((uint32_t*)val) == 64);
21163         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
21164         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
21165 }
21166
21167 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
21168         LDKNodeAnnouncement this_ptr_conv;
21169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21170         this_ptr_conv.is_owned = false;
21171         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
21172         uint64_t ret_ref = 0;
21173         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21174         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21175         ret_ref = (uint64_t)ret_var.inner;
21176         if (ret_var.is_owned) {
21177                 ret_ref |= 1;
21178         }
21179         return ret_ref;
21180 }
21181
21182 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
21183         LDKNodeAnnouncement this_ptr_conv;
21184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21185         this_ptr_conv.is_owned = false;
21186         LDKUnsignedNodeAnnouncement val_conv;
21187         val_conv.inner = (void*)(val & (~1));
21188         val_conv.is_owned = (val & 1) || (val == 0);
21189         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
21190         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
21191 }
21192
21193 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
21194         LDKSignature signature_arg_ref;
21195         CHECK(*((uint32_t*)signature_arg) == 64);
21196         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
21197         LDKUnsignedNodeAnnouncement contents_arg_conv;
21198         contents_arg_conv.inner = (void*)(contents_arg & (~1));
21199         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
21200         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
21201         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
21202         uint64_t ret_ref = 0;
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         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_NodeAnnouncement_clone(uint32_t orig) {
21213         LDKNodeAnnouncement orig_conv;
21214         orig_conv.inner = (void*)(orig & (~1));
21215         orig_conv.is_owned = false;
21216         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
21217         uint64_t ret_ref = 0;
21218         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21219         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21220         ret_ref = (uint64_t)ret_var.inner;
21221         if (ret_var.is_owned) {
21222                 ret_ref |= 1;
21223         }
21224         return ret_ref;
21225 }
21226
21227 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
21228         LDKUnsignedChannelAnnouncement this_obj_conv;
21229         this_obj_conv.inner = (void*)(this_obj & (~1));
21230         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21231         UnsignedChannelAnnouncement_free(this_obj_conv);
21232 }
21233
21234 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
21235         LDKUnsignedChannelAnnouncement this_ptr_conv;
21236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21237         this_ptr_conv.is_owned = false;
21238         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
21239         uint64_t ret_ref = 0;
21240         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21241         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21242         ret_ref = (uint64_t)ret_var.inner;
21243         if (ret_var.is_owned) {
21244                 ret_ref |= 1;
21245         }
21246         return ret_ref;
21247 }
21248
21249 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
21250         LDKUnsignedChannelAnnouncement this_ptr_conv;
21251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21252         this_ptr_conv.is_owned = false;
21253         LDKChannelFeatures val_conv;
21254         val_conv.inner = (void*)(val & (~1));
21255         val_conv.is_owned = (val & 1) || (val == 0);
21256         val_conv = ChannelFeatures_clone(&val_conv);
21257         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
21258 }
21259
21260 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
21261         LDKUnsignedChannelAnnouncement this_ptr_conv;
21262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21263         this_ptr_conv.is_owned = false;
21264         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21265         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
21266         return ret_arr;
21267 }
21268
21269 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
21270         LDKUnsignedChannelAnnouncement this_ptr_conv;
21271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21272         this_ptr_conv.is_owned = false;
21273         LDKThirtyTwoBytes val_ref;
21274         CHECK(*((uint32_t*)val) == 32);
21275         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
21276         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
21277 }
21278
21279 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
21280         LDKUnsignedChannelAnnouncement this_ptr_conv;
21281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21282         this_ptr_conv.is_owned = false;
21283         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
21284         return ret_val;
21285 }
21286
21287 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
21288         LDKUnsignedChannelAnnouncement this_ptr_conv;
21289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21290         this_ptr_conv.is_owned = false;
21291         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
21292 }
21293
21294 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
21295         LDKUnsignedChannelAnnouncement this_ptr_conv;
21296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21297         this_ptr_conv.is_owned = false;
21298         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21299         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
21300         return ret_arr;
21301 }
21302
21303 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
21304         LDKUnsignedChannelAnnouncement this_ptr_conv;
21305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21306         this_ptr_conv.is_owned = false;
21307         LDKPublicKey val_ref;
21308         CHECK(*((uint32_t*)val) == 33);
21309         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21310         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
21311 }
21312
21313 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
21314         LDKUnsignedChannelAnnouncement this_ptr_conv;
21315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21316         this_ptr_conv.is_owned = false;
21317         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21318         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
21319         return ret_arr;
21320 }
21321
21322 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
21323         LDKUnsignedChannelAnnouncement this_ptr_conv;
21324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21325         this_ptr_conv.is_owned = false;
21326         LDKPublicKey val_ref;
21327         CHECK(*((uint32_t*)val) == 33);
21328         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21329         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
21330 }
21331
21332 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
21333         LDKUnsignedChannelAnnouncement this_ptr_conv;
21334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21335         this_ptr_conv.is_owned = false;
21336         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21337         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
21338         return ret_arr;
21339 }
21340
21341 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
21342         LDKUnsignedChannelAnnouncement this_ptr_conv;
21343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21344         this_ptr_conv.is_owned = false;
21345         LDKPublicKey val_ref;
21346         CHECK(*((uint32_t*)val) == 33);
21347         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21348         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
21349 }
21350
21351 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
21352         LDKUnsignedChannelAnnouncement this_ptr_conv;
21353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21354         this_ptr_conv.is_owned = false;
21355         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21356         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
21357         return ret_arr;
21358 }
21359
21360 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
21361         LDKUnsignedChannelAnnouncement this_ptr_conv;
21362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21363         this_ptr_conv.is_owned = false;
21364         LDKPublicKey val_ref;
21365         CHECK(*((uint32_t*)val) == 33);
21366         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21367         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
21368 }
21369
21370 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
21371         LDKUnsignedChannelAnnouncement orig_conv;
21372         orig_conv.inner = (void*)(orig & (~1));
21373         orig_conv.is_owned = false;
21374         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
21375         uint64_t ret_ref = 0;
21376         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21377         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21378         ret_ref = (uint64_t)ret_var.inner;
21379         if (ret_var.is_owned) {
21380                 ret_ref |= 1;
21381         }
21382         return ret_ref;
21383 }
21384
21385 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
21386         LDKChannelAnnouncement this_obj_conv;
21387         this_obj_conv.inner = (void*)(this_obj & (~1));
21388         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21389         ChannelAnnouncement_free(this_obj_conv);
21390 }
21391
21392 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
21393         LDKChannelAnnouncement this_ptr_conv;
21394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21395         this_ptr_conv.is_owned = false;
21396         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
21397         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
21398         return ret_arr;
21399 }
21400
21401 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
21402         LDKChannelAnnouncement this_ptr_conv;
21403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21404         this_ptr_conv.is_owned = false;
21405         LDKSignature val_ref;
21406         CHECK(*((uint32_t*)val) == 64);
21407         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
21408         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
21409 }
21410
21411 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
21412         LDKChannelAnnouncement this_ptr_conv;
21413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21414         this_ptr_conv.is_owned = false;
21415         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
21416         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
21417         return ret_arr;
21418 }
21419
21420 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
21421         LDKChannelAnnouncement this_ptr_conv;
21422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21423         this_ptr_conv.is_owned = false;
21424         LDKSignature val_ref;
21425         CHECK(*((uint32_t*)val) == 64);
21426         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
21427         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
21428 }
21429
21430 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
21431         LDKChannelAnnouncement this_ptr_conv;
21432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21433         this_ptr_conv.is_owned = false;
21434         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
21435         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
21436         return ret_arr;
21437 }
21438
21439 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
21440         LDKChannelAnnouncement this_ptr_conv;
21441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21442         this_ptr_conv.is_owned = false;
21443         LDKSignature val_ref;
21444         CHECK(*((uint32_t*)val) == 64);
21445         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
21446         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
21447 }
21448
21449 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
21450         LDKChannelAnnouncement this_ptr_conv;
21451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21452         this_ptr_conv.is_owned = false;
21453         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
21454         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
21455         return ret_arr;
21456 }
21457
21458 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
21459         LDKChannelAnnouncement this_ptr_conv;
21460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21461         this_ptr_conv.is_owned = false;
21462         LDKSignature val_ref;
21463         CHECK(*((uint32_t*)val) == 64);
21464         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
21465         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
21466 }
21467
21468 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
21469         LDKChannelAnnouncement this_ptr_conv;
21470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21471         this_ptr_conv.is_owned = false;
21472         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
21473         uint64_t ret_ref = 0;
21474         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21475         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21476         ret_ref = (uint64_t)ret_var.inner;
21477         if (ret_var.is_owned) {
21478                 ret_ref |= 1;
21479         }
21480         return ret_ref;
21481 }
21482
21483 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
21484         LDKChannelAnnouncement this_ptr_conv;
21485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21486         this_ptr_conv.is_owned = false;
21487         LDKUnsignedChannelAnnouncement val_conv;
21488         val_conv.inner = (void*)(val & (~1));
21489         val_conv.is_owned = (val & 1) || (val == 0);
21490         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
21491         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
21492 }
21493
21494 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) {
21495         LDKSignature node_signature_1_arg_ref;
21496         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
21497         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
21498         LDKSignature node_signature_2_arg_ref;
21499         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
21500         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
21501         LDKSignature bitcoin_signature_1_arg_ref;
21502         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
21503         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
21504         LDKSignature bitcoin_signature_2_arg_ref;
21505         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
21506         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
21507         LDKUnsignedChannelAnnouncement contents_arg_conv;
21508         contents_arg_conv.inner = (void*)(contents_arg & (~1));
21509         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
21510         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
21511         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);
21512         uint64_t ret_ref = 0;
21513         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21514         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21515         ret_ref = (uint64_t)ret_var.inner;
21516         if (ret_var.is_owned) {
21517                 ret_ref |= 1;
21518         }
21519         return ret_ref;
21520 }
21521
21522 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
21523         LDKChannelAnnouncement orig_conv;
21524         orig_conv.inner = (void*)(orig & (~1));
21525         orig_conv.is_owned = false;
21526         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
21527         uint64_t ret_ref = 0;
21528         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21529         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21530         ret_ref = (uint64_t)ret_var.inner;
21531         if (ret_var.is_owned) {
21532                 ret_ref |= 1;
21533         }
21534         return ret_ref;
21535 }
21536
21537 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
21538         LDKUnsignedChannelUpdate this_obj_conv;
21539         this_obj_conv.inner = (void*)(this_obj & (~1));
21540         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21541         UnsignedChannelUpdate_free(this_obj_conv);
21542 }
21543
21544 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
21545         LDKUnsignedChannelUpdate this_ptr_conv;
21546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21547         this_ptr_conv.is_owned = false;
21548         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21549         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
21550         return ret_arr;
21551 }
21552
21553 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
21554         LDKUnsignedChannelUpdate this_ptr_conv;
21555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21556         this_ptr_conv.is_owned = false;
21557         LDKThirtyTwoBytes val_ref;
21558         CHECK(*((uint32_t*)val) == 32);
21559         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
21560         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
21561 }
21562
21563 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
21564         LDKUnsignedChannelUpdate this_ptr_conv;
21565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21566         this_ptr_conv.is_owned = false;
21567         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
21568         return ret_val;
21569 }
21570
21571 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
21572         LDKUnsignedChannelUpdate this_ptr_conv;
21573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21574         this_ptr_conv.is_owned = false;
21575         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
21576 }
21577
21578 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
21579         LDKUnsignedChannelUpdate this_ptr_conv;
21580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21581         this_ptr_conv.is_owned = false;
21582         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
21583         return ret_val;
21584 }
21585
21586 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
21587         LDKUnsignedChannelUpdate this_ptr_conv;
21588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21589         this_ptr_conv.is_owned = false;
21590         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
21591 }
21592
21593 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
21594         LDKUnsignedChannelUpdate this_ptr_conv;
21595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21596         this_ptr_conv.is_owned = false;
21597         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
21598         return ret_val;
21599 }
21600
21601 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
21602         LDKUnsignedChannelUpdate this_ptr_conv;
21603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21604         this_ptr_conv.is_owned = false;
21605         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
21606 }
21607
21608 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
21609         LDKUnsignedChannelUpdate this_ptr_conv;
21610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21611         this_ptr_conv.is_owned = false;
21612         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
21613         return ret_val;
21614 }
21615
21616 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
21617         LDKUnsignedChannelUpdate this_ptr_conv;
21618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21619         this_ptr_conv.is_owned = false;
21620         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
21621 }
21622
21623 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
21624         LDKUnsignedChannelUpdate this_ptr_conv;
21625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21626         this_ptr_conv.is_owned = false;
21627         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
21628         return ret_val;
21629 }
21630
21631 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
21632         LDKUnsignedChannelUpdate this_ptr_conv;
21633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21634         this_ptr_conv.is_owned = false;
21635         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
21636 }
21637
21638 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
21639         LDKUnsignedChannelUpdate this_ptr_conv;
21640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21641         this_ptr_conv.is_owned = false;
21642         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
21643         return ret_val;
21644 }
21645
21646 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
21647         LDKUnsignedChannelUpdate this_ptr_conv;
21648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21649         this_ptr_conv.is_owned = false;
21650         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
21651 }
21652
21653 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
21654         LDKUnsignedChannelUpdate this_ptr_conv;
21655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21656         this_ptr_conv.is_owned = false;
21657         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
21658         return ret_val;
21659 }
21660
21661 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
21662         LDKUnsignedChannelUpdate this_ptr_conv;
21663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21664         this_ptr_conv.is_owned = false;
21665         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
21666 }
21667
21668 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
21669         LDKUnsignedChannelUpdate orig_conv;
21670         orig_conv.inner = (void*)(orig & (~1));
21671         orig_conv.is_owned = false;
21672         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
21673         uint64_t ret_ref = 0;
21674         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21675         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21676         ret_ref = (uint64_t)ret_var.inner;
21677         if (ret_var.is_owned) {
21678                 ret_ref |= 1;
21679         }
21680         return ret_ref;
21681 }
21682
21683 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
21684         LDKChannelUpdate this_obj_conv;
21685         this_obj_conv.inner = (void*)(this_obj & (~1));
21686         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21687         ChannelUpdate_free(this_obj_conv);
21688 }
21689
21690 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
21691         LDKChannelUpdate this_ptr_conv;
21692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21693         this_ptr_conv.is_owned = false;
21694         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
21695         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
21696         return ret_arr;
21697 }
21698
21699 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
21700         LDKChannelUpdate this_ptr_conv;
21701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21702         this_ptr_conv.is_owned = false;
21703         LDKSignature val_ref;
21704         CHECK(*((uint32_t*)val) == 64);
21705         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
21706         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
21707 }
21708
21709 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
21710         LDKChannelUpdate this_ptr_conv;
21711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21712         this_ptr_conv.is_owned = false;
21713         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
21714         uint64_t ret_ref = 0;
21715         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21716         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21717         ret_ref = (uint64_t)ret_var.inner;
21718         if (ret_var.is_owned) {
21719                 ret_ref |= 1;
21720         }
21721         return ret_ref;
21722 }
21723
21724 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
21725         LDKChannelUpdate this_ptr_conv;
21726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21727         this_ptr_conv.is_owned = false;
21728         LDKUnsignedChannelUpdate val_conv;
21729         val_conv.inner = (void*)(val & (~1));
21730         val_conv.is_owned = (val & 1) || (val == 0);
21731         val_conv = UnsignedChannelUpdate_clone(&val_conv);
21732         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
21733 }
21734
21735 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
21736         LDKSignature signature_arg_ref;
21737         CHECK(*((uint32_t*)signature_arg) == 64);
21738         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
21739         LDKUnsignedChannelUpdate contents_arg_conv;
21740         contents_arg_conv.inner = (void*)(contents_arg & (~1));
21741         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
21742         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
21743         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
21744         uint64_t ret_ref = 0;
21745         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21746         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21747         ret_ref = (uint64_t)ret_var.inner;
21748         if (ret_var.is_owned) {
21749                 ret_ref |= 1;
21750         }
21751         return ret_ref;
21752 }
21753
21754 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
21755         LDKChannelUpdate orig_conv;
21756         orig_conv.inner = (void*)(orig & (~1));
21757         orig_conv.is_owned = false;
21758         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
21759         uint64_t ret_ref = 0;
21760         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21761         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21762         ret_ref = (uint64_t)ret_var.inner;
21763         if (ret_var.is_owned) {
21764                 ret_ref |= 1;
21765         }
21766         return ret_ref;
21767 }
21768
21769 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
21770         LDKQueryChannelRange this_obj_conv;
21771         this_obj_conv.inner = (void*)(this_obj & (~1));
21772         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21773         QueryChannelRange_free(this_obj_conv);
21774 }
21775
21776 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
21777         LDKQueryChannelRange this_ptr_conv;
21778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21779         this_ptr_conv.is_owned = false;
21780         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21781         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
21782         return ret_arr;
21783 }
21784
21785 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
21786         LDKQueryChannelRange this_ptr_conv;
21787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21788         this_ptr_conv.is_owned = false;
21789         LDKThirtyTwoBytes val_ref;
21790         CHECK(*((uint32_t*)val) == 32);
21791         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
21792         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
21793 }
21794
21795 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
21796         LDKQueryChannelRange this_ptr_conv;
21797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21798         this_ptr_conv.is_owned = false;
21799         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
21800         return ret_val;
21801 }
21802
21803 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
21804         LDKQueryChannelRange this_ptr_conv;
21805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21806         this_ptr_conv.is_owned = false;
21807         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
21808 }
21809
21810 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
21811         LDKQueryChannelRange this_ptr_conv;
21812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21813         this_ptr_conv.is_owned = false;
21814         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
21815         return ret_val;
21816 }
21817
21818 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
21819         LDKQueryChannelRange this_ptr_conv;
21820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21821         this_ptr_conv.is_owned = false;
21822         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
21823 }
21824
21825 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
21826         LDKThirtyTwoBytes chain_hash_arg_ref;
21827         CHECK(*((uint32_t*)chain_hash_arg) == 32);
21828         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
21829         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
21830         uint64_t ret_ref = 0;
21831         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21832         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21833         ret_ref = (uint64_t)ret_var.inner;
21834         if (ret_var.is_owned) {
21835                 ret_ref |= 1;
21836         }
21837         return ret_ref;
21838 }
21839
21840 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
21841         LDKQueryChannelRange orig_conv;
21842         orig_conv.inner = (void*)(orig & (~1));
21843         orig_conv.is_owned = false;
21844         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
21845         uint64_t ret_ref = 0;
21846         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21847         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21848         ret_ref = (uint64_t)ret_var.inner;
21849         if (ret_var.is_owned) {
21850                 ret_ref |= 1;
21851         }
21852         return ret_ref;
21853 }
21854
21855 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
21856         LDKReplyChannelRange this_obj_conv;
21857         this_obj_conv.inner = (void*)(this_obj & (~1));
21858         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21859         ReplyChannelRange_free(this_obj_conv);
21860 }
21861
21862 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
21863         LDKReplyChannelRange this_ptr_conv;
21864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21865         this_ptr_conv.is_owned = false;
21866         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21867         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
21868         return ret_arr;
21869 }
21870
21871 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
21872         LDKReplyChannelRange this_ptr_conv;
21873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21874         this_ptr_conv.is_owned = false;
21875         LDKThirtyTwoBytes val_ref;
21876         CHECK(*((uint32_t*)val) == 32);
21877         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
21878         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
21879 }
21880
21881 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
21882         LDKReplyChannelRange this_ptr_conv;
21883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21884         this_ptr_conv.is_owned = false;
21885         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
21886         return ret_val;
21887 }
21888
21889 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
21890         LDKReplyChannelRange this_ptr_conv;
21891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21892         this_ptr_conv.is_owned = false;
21893         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
21894 }
21895
21896 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
21897         LDKReplyChannelRange this_ptr_conv;
21898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21899         this_ptr_conv.is_owned = false;
21900         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
21901         return ret_val;
21902 }
21903
21904 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
21905         LDKReplyChannelRange this_ptr_conv;
21906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21907         this_ptr_conv.is_owned = false;
21908         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
21909 }
21910
21911 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
21912         LDKReplyChannelRange this_ptr_conv;
21913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21914         this_ptr_conv.is_owned = false;
21915         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
21916         return ret_val;
21917 }
21918
21919 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
21920         LDKReplyChannelRange this_ptr_conv;
21921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21922         this_ptr_conv.is_owned = false;
21923         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
21924 }
21925
21926 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
21927         LDKReplyChannelRange this_ptr_conv;
21928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21929         this_ptr_conv.is_owned = false;
21930         LDKCVec_u64Z val_constr;
21931         val_constr.datalen = *((uint32_t*)val);
21932         if (val_constr.datalen > 0)
21933                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21934         else
21935                 val_constr.data = NULL;
21936         int64_t* val_vals = (int64_t*)(val + 4);
21937         for (size_t i = 0; i < val_constr.datalen; i++) {
21938                 int64_t val_conv_8 = val_vals[i];
21939                 val_constr.data[i] = val_conv_8;
21940         }
21941         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
21942 }
21943
21944 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) {
21945         LDKThirtyTwoBytes chain_hash_arg_ref;
21946         CHECK(*((uint32_t*)chain_hash_arg) == 32);
21947         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
21948         LDKCVec_u64Z short_channel_ids_arg_constr;
21949         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
21950         if (short_channel_ids_arg_constr.datalen > 0)
21951                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21952         else
21953                 short_channel_ids_arg_constr.data = NULL;
21954         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
21955         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
21956                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
21957                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
21958         }
21959         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
21960         uint64_t ret_ref = 0;
21961         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21962         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21963         ret_ref = (uint64_t)ret_var.inner;
21964         if (ret_var.is_owned) {
21965                 ret_ref |= 1;
21966         }
21967         return ret_ref;
21968 }
21969
21970 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
21971         LDKReplyChannelRange orig_conv;
21972         orig_conv.inner = (void*)(orig & (~1));
21973         orig_conv.is_owned = false;
21974         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
21975         uint64_t ret_ref = 0;
21976         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21977         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21978         ret_ref = (uint64_t)ret_var.inner;
21979         if (ret_var.is_owned) {
21980                 ret_ref |= 1;
21981         }
21982         return ret_ref;
21983 }
21984
21985 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
21986         LDKQueryShortChannelIds this_obj_conv;
21987         this_obj_conv.inner = (void*)(this_obj & (~1));
21988         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21989         QueryShortChannelIds_free(this_obj_conv);
21990 }
21991
21992 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
21993         LDKQueryShortChannelIds this_ptr_conv;
21994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21995         this_ptr_conv.is_owned = false;
21996         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21997         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
21998         return ret_arr;
21999 }
22000
22001 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
22002         LDKQueryShortChannelIds this_ptr_conv;
22003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22004         this_ptr_conv.is_owned = false;
22005         LDKThirtyTwoBytes val_ref;
22006         CHECK(*((uint32_t*)val) == 32);
22007         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22008         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
22009 }
22010
22011 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
22012         LDKQueryShortChannelIds this_ptr_conv;
22013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22014         this_ptr_conv.is_owned = false;
22015         LDKCVec_u64Z val_constr;
22016         val_constr.datalen = *((uint32_t*)val);
22017         if (val_constr.datalen > 0)
22018                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
22019         else
22020                 val_constr.data = NULL;
22021         int64_t* val_vals = (int64_t*)(val + 4);
22022         for (size_t i = 0; i < val_constr.datalen; i++) {
22023                 int64_t val_conv_8 = val_vals[i];
22024                 val_constr.data[i] = val_conv_8;
22025         }
22026         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
22027 }
22028
22029 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
22030         LDKThirtyTwoBytes chain_hash_arg_ref;
22031         CHECK(*((uint32_t*)chain_hash_arg) == 32);
22032         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
22033         LDKCVec_u64Z short_channel_ids_arg_constr;
22034         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
22035         if (short_channel_ids_arg_constr.datalen > 0)
22036                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
22037         else
22038                 short_channel_ids_arg_constr.data = NULL;
22039         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
22040         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
22041                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
22042                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
22043         }
22044         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
22045         uint64_t ret_ref = 0;
22046         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22047         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22048         ret_ref = (uint64_t)ret_var.inner;
22049         if (ret_var.is_owned) {
22050                 ret_ref |= 1;
22051         }
22052         return ret_ref;
22053 }
22054
22055 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
22056         LDKQueryShortChannelIds orig_conv;
22057         orig_conv.inner = (void*)(orig & (~1));
22058         orig_conv.is_owned = false;
22059         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
22060         uint64_t ret_ref = 0;
22061         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22062         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22063         ret_ref = (uint64_t)ret_var.inner;
22064         if (ret_var.is_owned) {
22065                 ret_ref |= 1;
22066         }
22067         return ret_ref;
22068 }
22069
22070 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
22071         LDKReplyShortChannelIdsEnd this_obj_conv;
22072         this_obj_conv.inner = (void*)(this_obj & (~1));
22073         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22074         ReplyShortChannelIdsEnd_free(this_obj_conv);
22075 }
22076
22077 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
22078         LDKReplyShortChannelIdsEnd this_ptr_conv;
22079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22080         this_ptr_conv.is_owned = false;
22081         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22082         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
22083         return ret_arr;
22084 }
22085
22086 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
22087         LDKReplyShortChannelIdsEnd this_ptr_conv;
22088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22089         this_ptr_conv.is_owned = false;
22090         LDKThirtyTwoBytes val_ref;
22091         CHECK(*((uint32_t*)val) == 32);
22092         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22093         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
22094 }
22095
22096 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
22097         LDKReplyShortChannelIdsEnd this_ptr_conv;
22098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22099         this_ptr_conv.is_owned = false;
22100         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
22101         return ret_val;
22102 }
22103
22104 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
22105         LDKReplyShortChannelIdsEnd this_ptr_conv;
22106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22107         this_ptr_conv.is_owned = false;
22108         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
22109 }
22110
22111 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
22112         LDKThirtyTwoBytes chain_hash_arg_ref;
22113         CHECK(*((uint32_t*)chain_hash_arg) == 32);
22114         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
22115         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
22116         uint64_t ret_ref = 0;
22117         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22118         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22119         ret_ref = (uint64_t)ret_var.inner;
22120         if (ret_var.is_owned) {
22121                 ret_ref |= 1;
22122         }
22123         return ret_ref;
22124 }
22125
22126 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
22127         LDKReplyShortChannelIdsEnd orig_conv;
22128         orig_conv.inner = (void*)(orig & (~1));
22129         orig_conv.is_owned = false;
22130         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
22131         uint64_t ret_ref = 0;
22132         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22133         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22134         ret_ref = (uint64_t)ret_var.inner;
22135         if (ret_var.is_owned) {
22136                 ret_ref |= 1;
22137         }
22138         return ret_ref;
22139 }
22140
22141 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
22142         LDKGossipTimestampFilter this_obj_conv;
22143         this_obj_conv.inner = (void*)(this_obj & (~1));
22144         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22145         GossipTimestampFilter_free(this_obj_conv);
22146 }
22147
22148 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
22149         LDKGossipTimestampFilter this_ptr_conv;
22150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22151         this_ptr_conv.is_owned = false;
22152         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22153         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
22154         return ret_arr;
22155 }
22156
22157 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
22158         LDKGossipTimestampFilter this_ptr_conv;
22159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22160         this_ptr_conv.is_owned = false;
22161         LDKThirtyTwoBytes val_ref;
22162         CHECK(*((uint32_t*)val) == 32);
22163         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22164         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
22165 }
22166
22167 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
22168         LDKGossipTimestampFilter this_ptr_conv;
22169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22170         this_ptr_conv.is_owned = false;
22171         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
22172         return ret_val;
22173 }
22174
22175 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
22176         LDKGossipTimestampFilter this_ptr_conv;
22177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22178         this_ptr_conv.is_owned = false;
22179         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
22180 }
22181
22182 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
22183         LDKGossipTimestampFilter this_ptr_conv;
22184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22185         this_ptr_conv.is_owned = false;
22186         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
22187         return ret_val;
22188 }
22189
22190 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
22191         LDKGossipTimestampFilter this_ptr_conv;
22192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22193         this_ptr_conv.is_owned = false;
22194         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
22195 }
22196
22197 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
22198         LDKThirtyTwoBytes chain_hash_arg_ref;
22199         CHECK(*((uint32_t*)chain_hash_arg) == 32);
22200         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
22201         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
22202         uint64_t ret_ref = 0;
22203         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22204         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22205         ret_ref = (uint64_t)ret_var.inner;
22206         if (ret_var.is_owned) {
22207                 ret_ref |= 1;
22208         }
22209         return ret_ref;
22210 }
22211
22212 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
22213         LDKGossipTimestampFilter orig_conv;
22214         orig_conv.inner = (void*)(orig & (~1));
22215         orig_conv.is_owned = false;
22216         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
22217         uint64_t ret_ref = 0;
22218         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22219         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22220         ret_ref = (uint64_t)ret_var.inner;
22221         if (ret_var.is_owned) {
22222                 ret_ref |= 1;
22223         }
22224         return ret_ref;
22225 }
22226
22227 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
22228         if ((this_ptr & 1) != 0) return;
22229         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
22230         CHECK_ACCESS(this_ptr_ptr);
22231         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
22232         FREE((void*)this_ptr);
22233         ErrorAction_free(this_ptr_conv);
22234 }
22235
22236 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
22237         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
22238         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
22239         *ret_copy = ErrorAction_clone(orig_conv);
22240         uint64_t ret_ref = (uint64_t)ret_copy;
22241         return ret_ref;
22242 }
22243
22244 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
22245         LDKErrorMessage msg_conv;
22246         msg_conv.inner = (void*)(msg & (~1));
22247         msg_conv.is_owned = (msg & 1) || (msg == 0);
22248         msg_conv = ErrorMessage_clone(&msg_conv);
22249         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
22250         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
22251         uint64_t ret_ref = (uint64_t)ret_copy;
22252         return ret_ref;
22253 }
22254
22255 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_error() {
22256         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
22257         *ret_copy = ErrorAction_ignore_error();
22258         uint64_t ret_ref = (uint64_t)ret_copy;
22259         return ret_ref;
22260 }
22261
22262 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
22263         LDKLevel a_conv = LDKLevel_from_js(a);
22264         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
22265         *ret_copy = ErrorAction_ignore_and_log(a_conv);
22266         uint64_t ret_ref = (uint64_t)ret_copy;
22267         return ret_ref;
22268 }
22269
22270 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_send_error_message(uint32_t msg) {
22271         LDKErrorMessage msg_conv;
22272         msg_conv.inner = (void*)(msg & (~1));
22273         msg_conv.is_owned = (msg & 1) || (msg == 0);
22274         msg_conv = ErrorMessage_clone(&msg_conv);
22275         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
22276         *ret_copy = ErrorAction_send_error_message(msg_conv);
22277         uint64_t ret_ref = (uint64_t)ret_copy;
22278         return ret_ref;
22279 }
22280
22281 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
22282         LDKLightningError this_obj_conv;
22283         this_obj_conv.inner = (void*)(this_obj & (~1));
22284         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22285         LightningError_free(this_obj_conv);
22286 }
22287
22288 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
22289         LDKLightningError this_ptr_conv;
22290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22291         this_ptr_conv.is_owned = false;
22292         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
22293         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22294         Str_free(ret_str);
22295         return ret_conv;
22296 }
22297
22298 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
22299         LDKLightningError this_ptr_conv;
22300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22301         this_ptr_conv.is_owned = false;
22302         LDKStr val_conv = str_ref_to_owned_c(val);
22303         LightningError_set_err(&this_ptr_conv, val_conv);
22304 }
22305
22306 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
22307         LDKLightningError this_ptr_conv;
22308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22309         this_ptr_conv.is_owned = false;
22310         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
22311         *ret_copy = LightningError_get_action(&this_ptr_conv);
22312         uint64_t ret_ref = (uint64_t)ret_copy;
22313         return ret_ref;
22314 }
22315
22316 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
22317         LDKLightningError this_ptr_conv;
22318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22319         this_ptr_conv.is_owned = false;
22320         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22321         CHECK_ACCESS(val_ptr);
22322         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
22323         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
22324         LightningError_set_action(&this_ptr_conv, val_conv);
22325 }
22326
22327 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
22328         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
22329         void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
22330         CHECK_ACCESS(action_arg_ptr);
22331         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
22332         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
22333         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
22334         uint64_t ret_ref = 0;
22335         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22336         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22337         ret_ref = (uint64_t)ret_var.inner;
22338         if (ret_var.is_owned) {
22339                 ret_ref |= 1;
22340         }
22341         return ret_ref;
22342 }
22343
22344 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
22345         LDKLightningError orig_conv;
22346         orig_conv.inner = (void*)(orig & (~1));
22347         orig_conv.is_owned = false;
22348         LDKLightningError ret_var = LightningError_clone(&orig_conv);
22349         uint64_t ret_ref = 0;
22350         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22351         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22352         ret_ref = (uint64_t)ret_var.inner;
22353         if (ret_var.is_owned) {
22354                 ret_ref |= 1;
22355         }
22356         return ret_ref;
22357 }
22358
22359 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
22360         LDKCommitmentUpdate this_obj_conv;
22361         this_obj_conv.inner = (void*)(this_obj & (~1));
22362         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22363         CommitmentUpdate_free(this_obj_conv);
22364 }
22365
22366 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
22367         LDKCommitmentUpdate this_ptr_conv;
22368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22369         this_ptr_conv.is_owned = false;
22370         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
22371         uint32_tArray ret_arr = NULL;
22372         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
22373         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
22374         for (size_t p = 0; p < ret_var.datalen; p++) {
22375                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
22376                 uint64_t ret_conv_15_ref = 0;
22377                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22378                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22379                 ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
22380                 if (ret_conv_15_var.is_owned) {
22381                         ret_conv_15_ref |= 1;
22382                 }
22383                 ret_arr_ptr[p] = ret_conv_15_ref;
22384         }
22385         
22386         FREE(ret_var.data);
22387         return ret_arr;
22388 }
22389
22390 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
22391         LDKCommitmentUpdate this_ptr_conv;
22392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22393         this_ptr_conv.is_owned = false;
22394         LDKCVec_UpdateAddHTLCZ val_constr;
22395         val_constr.datalen = *((uint32_t*)val);
22396         if (val_constr.datalen > 0)
22397                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
22398         else
22399                 val_constr.data = NULL;
22400         uint32_t* val_vals = (uint32_t*)(val + 4);
22401         for (size_t p = 0; p < val_constr.datalen; p++) {
22402                 uint32_t val_conv_15 = val_vals[p];
22403                 LDKUpdateAddHTLC val_conv_15_conv;
22404                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
22405                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
22406                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
22407                 val_constr.data[p] = val_conv_15_conv;
22408         }
22409         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
22410 }
22411
22412 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
22413         LDKCommitmentUpdate this_ptr_conv;
22414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22415         this_ptr_conv.is_owned = false;
22416         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
22417         uint32_tArray ret_arr = NULL;
22418         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
22419         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
22420         for (size_t t = 0; t < ret_var.datalen; t++) {
22421                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
22422                 uint64_t ret_conv_19_ref = 0;
22423                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22424                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22425                 ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
22426                 if (ret_conv_19_var.is_owned) {
22427                         ret_conv_19_ref |= 1;
22428                 }
22429                 ret_arr_ptr[t] = ret_conv_19_ref;
22430         }
22431         
22432         FREE(ret_var.data);
22433         return ret_arr;
22434 }
22435
22436 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
22437         LDKCommitmentUpdate this_ptr_conv;
22438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22439         this_ptr_conv.is_owned = false;
22440         LDKCVec_UpdateFulfillHTLCZ val_constr;
22441         val_constr.datalen = *((uint32_t*)val);
22442         if (val_constr.datalen > 0)
22443                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
22444         else
22445                 val_constr.data = NULL;
22446         uint32_t* val_vals = (uint32_t*)(val + 4);
22447         for (size_t t = 0; t < val_constr.datalen; t++) {
22448                 uint32_t val_conv_19 = val_vals[t];
22449                 LDKUpdateFulfillHTLC val_conv_19_conv;
22450                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
22451                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
22452                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
22453                 val_constr.data[t] = val_conv_19_conv;
22454         }
22455         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
22456 }
22457
22458 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
22459         LDKCommitmentUpdate this_ptr_conv;
22460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22461         this_ptr_conv.is_owned = false;
22462         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
22463         uint32_tArray ret_arr = NULL;
22464         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
22465         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
22466         for (size_t q = 0; q < ret_var.datalen; q++) {
22467                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
22468                 uint64_t ret_conv_16_ref = 0;
22469                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22470                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22471                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
22472                 if (ret_conv_16_var.is_owned) {
22473                         ret_conv_16_ref |= 1;
22474                 }
22475                 ret_arr_ptr[q] = ret_conv_16_ref;
22476         }
22477         
22478         FREE(ret_var.data);
22479         return ret_arr;
22480 }
22481
22482 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
22483         LDKCommitmentUpdate this_ptr_conv;
22484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22485         this_ptr_conv.is_owned = false;
22486         LDKCVec_UpdateFailHTLCZ val_constr;
22487         val_constr.datalen = *((uint32_t*)val);
22488         if (val_constr.datalen > 0)
22489                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
22490         else
22491                 val_constr.data = NULL;
22492         uint32_t* val_vals = (uint32_t*)(val + 4);
22493         for (size_t q = 0; q < val_constr.datalen; q++) {
22494                 uint32_t val_conv_16 = val_vals[q];
22495                 LDKUpdateFailHTLC val_conv_16_conv;
22496                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
22497                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
22498                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
22499                 val_constr.data[q] = val_conv_16_conv;
22500         }
22501         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
22502 }
22503
22504 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
22505         LDKCommitmentUpdate this_ptr_conv;
22506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22507         this_ptr_conv.is_owned = false;
22508         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
22509         uint32_tArray ret_arr = NULL;
22510         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
22511         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
22512         for (size_t z = 0; z < ret_var.datalen; z++) {
22513                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
22514                 uint64_t ret_conv_25_ref = 0;
22515                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22516                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22517                 ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
22518                 if (ret_conv_25_var.is_owned) {
22519                         ret_conv_25_ref |= 1;
22520                 }
22521                 ret_arr_ptr[z] = ret_conv_25_ref;
22522         }
22523         
22524         FREE(ret_var.data);
22525         return ret_arr;
22526 }
22527
22528 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
22529         LDKCommitmentUpdate this_ptr_conv;
22530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22531         this_ptr_conv.is_owned = false;
22532         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
22533         val_constr.datalen = *((uint32_t*)val);
22534         if (val_constr.datalen > 0)
22535                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
22536         else
22537                 val_constr.data = NULL;
22538         uint32_t* val_vals = (uint32_t*)(val + 4);
22539         for (size_t z = 0; z < val_constr.datalen; z++) {
22540                 uint32_t val_conv_25 = val_vals[z];
22541                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
22542                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
22543                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
22544                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
22545                 val_constr.data[z] = val_conv_25_conv;
22546         }
22547         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
22548 }
22549
22550 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
22551         LDKCommitmentUpdate this_ptr_conv;
22552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22553         this_ptr_conv.is_owned = false;
22554         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
22555         uint64_t ret_ref = 0;
22556         if ((uint64_t)ret_var.inner > 4096) {
22557                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22558                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22559                 ret_ref = (uint64_t)ret_var.inner;
22560                 if (ret_var.is_owned) {
22561                         ret_ref |= 1;
22562                 }
22563         }
22564         return ret_ref;
22565 }
22566
22567 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
22568         LDKCommitmentUpdate this_ptr_conv;
22569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22570         this_ptr_conv.is_owned = false;
22571         LDKUpdateFee val_conv;
22572         val_conv.inner = (void*)(val & (~1));
22573         val_conv.is_owned = (val & 1) || (val == 0);
22574         val_conv = UpdateFee_clone(&val_conv);
22575         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
22576 }
22577
22578 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
22579         LDKCommitmentUpdate this_ptr_conv;
22580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22581         this_ptr_conv.is_owned = false;
22582         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
22583         uint64_t ret_ref = 0;
22584         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22585         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22586         ret_ref = (uint64_t)ret_var.inner;
22587         if (ret_var.is_owned) {
22588                 ret_ref |= 1;
22589         }
22590         return ret_ref;
22591 }
22592
22593 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
22594         LDKCommitmentUpdate this_ptr_conv;
22595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22596         this_ptr_conv.is_owned = false;
22597         LDKCommitmentSigned val_conv;
22598         val_conv.inner = (void*)(val & (~1));
22599         val_conv.is_owned = (val & 1) || (val == 0);
22600         val_conv = CommitmentSigned_clone(&val_conv);
22601         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
22602 }
22603
22604 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) {
22605         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
22606         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
22607         if (update_add_htlcs_arg_constr.datalen > 0)
22608                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
22609         else
22610                 update_add_htlcs_arg_constr.data = NULL;
22611         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
22612         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
22613                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
22614                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
22615                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
22616                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
22617                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
22618                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
22619         }
22620         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
22621         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
22622         if (update_fulfill_htlcs_arg_constr.datalen > 0)
22623                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
22624         else
22625                 update_fulfill_htlcs_arg_constr.data = NULL;
22626         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
22627         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
22628                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
22629                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
22630                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
22631                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
22632                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
22633                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
22634         }
22635         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
22636         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
22637         if (update_fail_htlcs_arg_constr.datalen > 0)
22638                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
22639         else
22640                 update_fail_htlcs_arg_constr.data = NULL;
22641         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
22642         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
22643                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
22644                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
22645                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
22646                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
22647                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
22648                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
22649         }
22650         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
22651         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
22652         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
22653                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
22654         else
22655                 update_fail_malformed_htlcs_arg_constr.data = NULL;
22656         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
22657         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
22658                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
22659                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
22660                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
22661                 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);
22662                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
22663                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
22664         }
22665         LDKUpdateFee update_fee_arg_conv;
22666         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
22667         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
22668         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
22669         LDKCommitmentSigned commitment_signed_arg_conv;
22670         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
22671         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
22672         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
22673         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);
22674         uint64_t ret_ref = 0;
22675         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22676         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22677         ret_ref = (uint64_t)ret_var.inner;
22678         if (ret_var.is_owned) {
22679                 ret_ref |= 1;
22680         }
22681         return ret_ref;
22682 }
22683
22684 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
22685         LDKCommitmentUpdate orig_conv;
22686         orig_conv.inner = (void*)(orig & (~1));
22687         orig_conv.is_owned = false;
22688         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
22689         uint64_t ret_ref = 0;
22690         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22691         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22692         ret_ref = (uint64_t)ret_var.inner;
22693         if (ret_var.is_owned) {
22694                 ret_ref |= 1;
22695         }
22696         return ret_ref;
22697 }
22698
22699 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
22700         if ((this_ptr & 1) != 0) return;
22701         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
22702         CHECK_ACCESS(this_ptr_ptr);
22703         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
22704         FREE((void*)this_ptr);
22705         ChannelMessageHandler_free(this_ptr_conv);
22706 }
22707
22708 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
22709         if ((this_ptr & 1) != 0) return;
22710         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
22711         CHECK_ACCESS(this_ptr_ptr);
22712         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
22713         FREE((void*)this_ptr);
22714         RoutingMessageHandler_free(this_ptr_conv);
22715 }
22716
22717 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
22718         LDKAcceptChannel obj_conv;
22719         obj_conv.inner = (void*)(obj & (~1));
22720         obj_conv.is_owned = false;
22721         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
22722         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22723         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22724         CVec_u8Z_free(ret_var);
22725         return ret_arr;
22726 }
22727
22728 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
22729         LDKu8slice ser_ref;
22730         ser_ref.datalen = *((uint32_t*)ser);
22731         ser_ref.data = (int8_t*)(ser + 4);
22732         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22733         *ret_conv = AcceptChannel_read(ser_ref);
22734         return (uint64_t)ret_conv;
22735 }
22736
22737 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
22738         LDKAnnouncementSignatures obj_conv;
22739         obj_conv.inner = (void*)(obj & (~1));
22740         obj_conv.is_owned = false;
22741         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
22742         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22743         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22744         CVec_u8Z_free(ret_var);
22745         return ret_arr;
22746 }
22747
22748 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
22749         LDKu8slice ser_ref;
22750         ser_ref.datalen = *((uint32_t*)ser);
22751         ser_ref.data = (int8_t*)(ser + 4);
22752         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22753         *ret_conv = AnnouncementSignatures_read(ser_ref);
22754         return (uint64_t)ret_conv;
22755 }
22756
22757 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
22758         LDKChannelReestablish obj_conv;
22759         obj_conv.inner = (void*)(obj & (~1));
22760         obj_conv.is_owned = false;
22761         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
22762         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22763         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22764         CVec_u8Z_free(ret_var);
22765         return ret_arr;
22766 }
22767
22768 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
22769         LDKu8slice ser_ref;
22770         ser_ref.datalen = *((uint32_t*)ser);
22771         ser_ref.data = (int8_t*)(ser + 4);
22772         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22773         *ret_conv = ChannelReestablish_read(ser_ref);
22774         return (uint64_t)ret_conv;
22775 }
22776
22777 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
22778         LDKClosingSigned obj_conv;
22779         obj_conv.inner = (void*)(obj & (~1));
22780         obj_conv.is_owned = false;
22781         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
22782         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22783         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22784         CVec_u8Z_free(ret_var);
22785         return ret_arr;
22786 }
22787
22788 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
22789         LDKu8slice ser_ref;
22790         ser_ref.datalen = *((uint32_t*)ser);
22791         ser_ref.data = (int8_t*)(ser + 4);
22792         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22793         *ret_conv = ClosingSigned_read(ser_ref);
22794         return (uint64_t)ret_conv;
22795 }
22796
22797 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
22798         LDKClosingSignedFeeRange obj_conv;
22799         obj_conv.inner = (void*)(obj & (~1));
22800         obj_conv.is_owned = false;
22801         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
22802         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22803         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22804         CVec_u8Z_free(ret_var);
22805         return ret_arr;
22806 }
22807
22808 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
22809         LDKu8slice ser_ref;
22810         ser_ref.datalen = *((uint32_t*)ser);
22811         ser_ref.data = (int8_t*)(ser + 4);
22812         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22813         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
22814         return (uint64_t)ret_conv;
22815 }
22816
22817 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
22818         LDKCommitmentSigned obj_conv;
22819         obj_conv.inner = (void*)(obj & (~1));
22820         obj_conv.is_owned = false;
22821         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
22822         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22823         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22824         CVec_u8Z_free(ret_var);
22825         return ret_arr;
22826 }
22827
22828 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
22829         LDKu8slice ser_ref;
22830         ser_ref.datalen = *((uint32_t*)ser);
22831         ser_ref.data = (int8_t*)(ser + 4);
22832         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22833         *ret_conv = CommitmentSigned_read(ser_ref);
22834         return (uint64_t)ret_conv;
22835 }
22836
22837 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
22838         LDKFundingCreated obj_conv;
22839         obj_conv.inner = (void*)(obj & (~1));
22840         obj_conv.is_owned = false;
22841         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
22842         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22843         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22844         CVec_u8Z_free(ret_var);
22845         return ret_arr;
22846 }
22847
22848 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
22849         LDKu8slice ser_ref;
22850         ser_ref.datalen = *((uint32_t*)ser);
22851         ser_ref.data = (int8_t*)(ser + 4);
22852         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22853         *ret_conv = FundingCreated_read(ser_ref);
22854         return (uint64_t)ret_conv;
22855 }
22856
22857 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
22858         LDKFundingSigned obj_conv;
22859         obj_conv.inner = (void*)(obj & (~1));
22860         obj_conv.is_owned = false;
22861         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
22862         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22863         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22864         CVec_u8Z_free(ret_var);
22865         return ret_arr;
22866 }
22867
22868 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
22869         LDKu8slice ser_ref;
22870         ser_ref.datalen = *((uint32_t*)ser);
22871         ser_ref.data = (int8_t*)(ser + 4);
22872         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22873         *ret_conv = FundingSigned_read(ser_ref);
22874         return (uint64_t)ret_conv;
22875 }
22876
22877 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
22878         LDKFundingLocked obj_conv;
22879         obj_conv.inner = (void*)(obj & (~1));
22880         obj_conv.is_owned = false;
22881         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
22882         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22883         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22884         CVec_u8Z_free(ret_var);
22885         return ret_arr;
22886 }
22887
22888 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
22889         LDKu8slice ser_ref;
22890         ser_ref.datalen = *((uint32_t*)ser);
22891         ser_ref.data = (int8_t*)(ser + 4);
22892         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
22893         *ret_conv = FundingLocked_read(ser_ref);
22894         return (uint64_t)ret_conv;
22895 }
22896
22897 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
22898         LDKInit obj_conv;
22899         obj_conv.inner = (void*)(obj & (~1));
22900         obj_conv.is_owned = false;
22901         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
22902         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22903         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22904         CVec_u8Z_free(ret_var);
22905         return ret_arr;
22906 }
22907
22908 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
22909         LDKu8slice ser_ref;
22910         ser_ref.datalen = *((uint32_t*)ser);
22911         ser_ref.data = (int8_t*)(ser + 4);
22912         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22913         *ret_conv = Init_read(ser_ref);
22914         return (uint64_t)ret_conv;
22915 }
22916
22917 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
22918         LDKOpenChannel obj_conv;
22919         obj_conv.inner = (void*)(obj & (~1));
22920         obj_conv.is_owned = false;
22921         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
22922         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22923         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22924         CVec_u8Z_free(ret_var);
22925         return ret_arr;
22926 }
22927
22928 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
22929         LDKu8slice ser_ref;
22930         ser_ref.datalen = *((uint32_t*)ser);
22931         ser_ref.data = (int8_t*)(ser + 4);
22932         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22933         *ret_conv = OpenChannel_read(ser_ref);
22934         return (uint64_t)ret_conv;
22935 }
22936
22937 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
22938         LDKRevokeAndACK obj_conv;
22939         obj_conv.inner = (void*)(obj & (~1));
22940         obj_conv.is_owned = false;
22941         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
22942         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22943         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22944         CVec_u8Z_free(ret_var);
22945         return ret_arr;
22946 }
22947
22948 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
22949         LDKu8slice ser_ref;
22950         ser_ref.datalen = *((uint32_t*)ser);
22951         ser_ref.data = (int8_t*)(ser + 4);
22952         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22953         *ret_conv = RevokeAndACK_read(ser_ref);
22954         return (uint64_t)ret_conv;
22955 }
22956
22957 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
22958         LDKShutdown obj_conv;
22959         obj_conv.inner = (void*)(obj & (~1));
22960         obj_conv.is_owned = false;
22961         LDKCVec_u8Z ret_var = Shutdown_write(&obj_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         CVec_u8Z_free(ret_var);
22965         return ret_arr;
22966 }
22967
22968 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
22969         LDKu8slice ser_ref;
22970         ser_ref.datalen = *((uint32_t*)ser);
22971         ser_ref.data = (int8_t*)(ser + 4);
22972         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22973         *ret_conv = Shutdown_read(ser_ref);
22974         return (uint64_t)ret_conv;
22975 }
22976
22977 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
22978         LDKUpdateFailHTLC obj_conv;
22979         obj_conv.inner = (void*)(obj & (~1));
22980         obj_conv.is_owned = false;
22981         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
22982         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22983         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22984         CVec_u8Z_free(ret_var);
22985         return ret_arr;
22986 }
22987
22988 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
22989         LDKu8slice ser_ref;
22990         ser_ref.datalen = *((uint32_t*)ser);
22991         ser_ref.data = (int8_t*)(ser + 4);
22992         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22993         *ret_conv = UpdateFailHTLC_read(ser_ref);
22994         return (uint64_t)ret_conv;
22995 }
22996
22997 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
22998         LDKUpdateFailMalformedHTLC obj_conv;
22999         obj_conv.inner = (void*)(obj & (~1));
23000         obj_conv.is_owned = false;
23001         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
23002         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23003         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23004         CVec_u8Z_free(ret_var);
23005         return ret_arr;
23006 }
23007
23008 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
23009         LDKu8slice ser_ref;
23010         ser_ref.datalen = *((uint32_t*)ser);
23011         ser_ref.data = (int8_t*)(ser + 4);
23012         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23013         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
23014         return (uint64_t)ret_conv;
23015 }
23016
23017 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
23018         LDKUpdateFee obj_conv;
23019         obj_conv.inner = (void*)(obj & (~1));
23020         obj_conv.is_owned = false;
23021         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
23022         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23023         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23024         CVec_u8Z_free(ret_var);
23025         return ret_arr;
23026 }
23027
23028 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
23029         LDKu8slice ser_ref;
23030         ser_ref.datalen = *((uint32_t*)ser);
23031         ser_ref.data = (int8_t*)(ser + 4);
23032         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23033         *ret_conv = UpdateFee_read(ser_ref);
23034         return (uint64_t)ret_conv;
23035 }
23036
23037 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
23038         LDKUpdateFulfillHTLC obj_conv;
23039         obj_conv.inner = (void*)(obj & (~1));
23040         obj_conv.is_owned = false;
23041         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
23042         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23043         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23044         CVec_u8Z_free(ret_var);
23045         return ret_arr;
23046 }
23047
23048 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
23049         LDKu8slice ser_ref;
23050         ser_ref.datalen = *((uint32_t*)ser);
23051         ser_ref.data = (int8_t*)(ser + 4);
23052         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23053         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
23054         return (uint64_t)ret_conv;
23055 }
23056
23057 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
23058         LDKUpdateAddHTLC obj_conv;
23059         obj_conv.inner = (void*)(obj & (~1));
23060         obj_conv.is_owned = false;
23061         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
23062         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23063         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23064         CVec_u8Z_free(ret_var);
23065         return ret_arr;
23066 }
23067
23068 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
23069         LDKu8slice ser_ref;
23070         ser_ref.datalen = *((uint32_t*)ser);
23071         ser_ref.data = (int8_t*)(ser + 4);
23072         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23073         *ret_conv = UpdateAddHTLC_read(ser_ref);
23074         return (uint64_t)ret_conv;
23075 }
23076
23077 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
23078         LDKPing obj_conv;
23079         obj_conv.inner = (void*)(obj & (~1));
23080         obj_conv.is_owned = false;
23081         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
23082         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23083         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23084         CVec_u8Z_free(ret_var);
23085         return ret_arr;
23086 }
23087
23088 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
23089         LDKu8slice ser_ref;
23090         ser_ref.datalen = *((uint32_t*)ser);
23091         ser_ref.data = (int8_t*)(ser + 4);
23092         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23093         *ret_conv = Ping_read(ser_ref);
23094         return (uint64_t)ret_conv;
23095 }
23096
23097 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
23098         LDKPong obj_conv;
23099         obj_conv.inner = (void*)(obj & (~1));
23100         obj_conv.is_owned = false;
23101         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
23102         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23103         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23104         CVec_u8Z_free(ret_var);
23105         return ret_arr;
23106 }
23107
23108 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
23109         LDKu8slice ser_ref;
23110         ser_ref.datalen = *((uint32_t*)ser);
23111         ser_ref.data = (int8_t*)(ser + 4);
23112         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23113         *ret_conv = Pong_read(ser_ref);
23114         return (uint64_t)ret_conv;
23115 }
23116
23117 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
23118         LDKUnsignedChannelAnnouncement obj_conv;
23119         obj_conv.inner = (void*)(obj & (~1));
23120         obj_conv.is_owned = false;
23121         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
23122         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23123         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23124         CVec_u8Z_free(ret_var);
23125         return ret_arr;
23126 }
23127
23128 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
23129         LDKu8slice ser_ref;
23130         ser_ref.datalen = *((uint32_t*)ser);
23131         ser_ref.data = (int8_t*)(ser + 4);
23132         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23133         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
23134         return (uint64_t)ret_conv;
23135 }
23136
23137 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
23138         LDKChannelAnnouncement obj_conv;
23139         obj_conv.inner = (void*)(obj & (~1));
23140         obj_conv.is_owned = false;
23141         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
23142         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23143         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23144         CVec_u8Z_free(ret_var);
23145         return ret_arr;
23146 }
23147
23148 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
23149         LDKu8slice ser_ref;
23150         ser_ref.datalen = *((uint32_t*)ser);
23151         ser_ref.data = (int8_t*)(ser + 4);
23152         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23153         *ret_conv = ChannelAnnouncement_read(ser_ref);
23154         return (uint64_t)ret_conv;
23155 }
23156
23157 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
23158         LDKUnsignedChannelUpdate obj_conv;
23159         obj_conv.inner = (void*)(obj & (~1));
23160         obj_conv.is_owned = false;
23161         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
23162         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23163         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23164         CVec_u8Z_free(ret_var);
23165         return ret_arr;
23166 }
23167
23168 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
23169         LDKu8slice ser_ref;
23170         ser_ref.datalen = *((uint32_t*)ser);
23171         ser_ref.data = (int8_t*)(ser + 4);
23172         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23173         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
23174         return (uint64_t)ret_conv;
23175 }
23176
23177 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
23178         LDKChannelUpdate obj_conv;
23179         obj_conv.inner = (void*)(obj & (~1));
23180         obj_conv.is_owned = false;
23181         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
23182         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23183         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23184         CVec_u8Z_free(ret_var);
23185         return ret_arr;
23186 }
23187
23188 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
23189         LDKu8slice ser_ref;
23190         ser_ref.datalen = *((uint32_t*)ser);
23191         ser_ref.data = (int8_t*)(ser + 4);
23192         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23193         *ret_conv = ChannelUpdate_read(ser_ref);
23194         return (uint64_t)ret_conv;
23195 }
23196
23197 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
23198         LDKErrorMessage obj_conv;
23199         obj_conv.inner = (void*)(obj & (~1));
23200         obj_conv.is_owned = false;
23201         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
23202         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23203         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23204         CVec_u8Z_free(ret_var);
23205         return ret_arr;
23206 }
23207
23208 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
23209         LDKu8slice ser_ref;
23210         ser_ref.datalen = *((uint32_t*)ser);
23211         ser_ref.data = (int8_t*)(ser + 4);
23212         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23213         *ret_conv = ErrorMessage_read(ser_ref);
23214         return (uint64_t)ret_conv;
23215 }
23216
23217 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
23218         LDKUnsignedNodeAnnouncement obj_conv;
23219         obj_conv.inner = (void*)(obj & (~1));
23220         obj_conv.is_owned = false;
23221         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
23222         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23223         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23224         CVec_u8Z_free(ret_var);
23225         return ret_arr;
23226 }
23227
23228 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
23229         LDKu8slice ser_ref;
23230         ser_ref.datalen = *((uint32_t*)ser);
23231         ser_ref.data = (int8_t*)(ser + 4);
23232         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23233         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
23234         return (uint64_t)ret_conv;
23235 }
23236
23237 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
23238         LDKNodeAnnouncement obj_conv;
23239         obj_conv.inner = (void*)(obj & (~1));
23240         obj_conv.is_owned = false;
23241         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
23242         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23243         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23244         CVec_u8Z_free(ret_var);
23245         return ret_arr;
23246 }
23247
23248 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
23249         LDKu8slice ser_ref;
23250         ser_ref.datalen = *((uint32_t*)ser);
23251         ser_ref.data = (int8_t*)(ser + 4);
23252         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23253         *ret_conv = NodeAnnouncement_read(ser_ref);
23254         return (uint64_t)ret_conv;
23255 }
23256
23257 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
23258         LDKu8slice ser_ref;
23259         ser_ref.datalen = *((uint32_t*)ser);
23260         ser_ref.data = (int8_t*)(ser + 4);
23261         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23262         *ret_conv = QueryShortChannelIds_read(ser_ref);
23263         return (uint64_t)ret_conv;
23264 }
23265
23266 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
23267         LDKQueryShortChannelIds obj_conv;
23268         obj_conv.inner = (void*)(obj & (~1));
23269         obj_conv.is_owned = false;
23270         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
23271         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23272         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23273         CVec_u8Z_free(ret_var);
23274         return ret_arr;
23275 }
23276
23277 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
23278         LDKReplyShortChannelIdsEnd obj_conv;
23279         obj_conv.inner = (void*)(obj & (~1));
23280         obj_conv.is_owned = false;
23281         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
23282         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23283         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23284         CVec_u8Z_free(ret_var);
23285         return ret_arr;
23286 }
23287
23288 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
23289         LDKu8slice ser_ref;
23290         ser_ref.datalen = *((uint32_t*)ser);
23291         ser_ref.data = (int8_t*)(ser + 4);
23292         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23293         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
23294         return (uint64_t)ret_conv;
23295 }
23296
23297 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
23298         LDKQueryChannelRange this_arg_conv;
23299         this_arg_conv.inner = (void*)(this_arg & (~1));
23300         this_arg_conv.is_owned = false;
23301         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
23302         return ret_val;
23303 }
23304
23305 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
23306         LDKQueryChannelRange obj_conv;
23307         obj_conv.inner = (void*)(obj & (~1));
23308         obj_conv.is_owned = false;
23309         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
23310         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23311         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23312         CVec_u8Z_free(ret_var);
23313         return ret_arr;
23314 }
23315
23316 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
23317         LDKu8slice ser_ref;
23318         ser_ref.datalen = *((uint32_t*)ser);
23319         ser_ref.data = (int8_t*)(ser + 4);
23320         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23321         *ret_conv = QueryChannelRange_read(ser_ref);
23322         return (uint64_t)ret_conv;
23323 }
23324
23325 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
23326         LDKu8slice ser_ref;
23327         ser_ref.datalen = *((uint32_t*)ser);
23328         ser_ref.data = (int8_t*)(ser + 4);
23329         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23330         *ret_conv = ReplyChannelRange_read(ser_ref);
23331         return (uint64_t)ret_conv;
23332 }
23333
23334 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
23335         LDKReplyChannelRange obj_conv;
23336         obj_conv.inner = (void*)(obj & (~1));
23337         obj_conv.is_owned = false;
23338         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
23339         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23340         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23341         CVec_u8Z_free(ret_var);
23342         return ret_arr;
23343 }
23344
23345 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
23346         LDKGossipTimestampFilter obj_conv;
23347         obj_conv.inner = (void*)(obj & (~1));
23348         obj_conv.is_owned = false;
23349         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
23350         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23351         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23352         CVec_u8Z_free(ret_var);
23353         return ret_arr;
23354 }
23355
23356 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
23357         LDKu8slice ser_ref;
23358         ser_ref.datalen = *((uint32_t*)ser);
23359         ser_ref.data = (int8_t*)(ser + 4);
23360         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23361         *ret_conv = GossipTimestampFilter_read(ser_ref);
23362         return (uint64_t)ret_conv;
23363 }
23364
23365 void  __attribute__((visibility("default"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
23366         if ((this_ptr & 1) != 0) return;
23367         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23368         CHECK_ACCESS(this_ptr_ptr);
23369         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
23370         FREE((void*)this_ptr);
23371         CustomMessageHandler_free(this_ptr_conv);
23372 }
23373
23374 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
23375         LDKIgnoringMessageHandler this_obj_conv;
23376         this_obj_conv.inner = (void*)(this_obj & (~1));
23377         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23378         IgnoringMessageHandler_free(this_obj_conv);
23379 }
23380
23381 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
23382         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
23383         uint64_t ret_ref = 0;
23384         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23385         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23386         ret_ref = (uint64_t)ret_var.inner;
23387         if (ret_var.is_owned) {
23388                 ret_ref |= 1;
23389         }
23390         return ret_ref;
23391 }
23392
23393 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
23394         LDKIgnoringMessageHandler this_arg_conv;
23395         this_arg_conv.inner = (void*)(this_arg & (~1));
23396         this_arg_conv.is_owned = false;
23397         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
23398         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
23399         return (uint64_t)ret_ret;
23400 }
23401
23402 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
23403         LDKIgnoringMessageHandler this_arg_conv;
23404         this_arg_conv.inner = (void*)(this_arg & (~1));
23405         this_arg_conv.is_owned = false;
23406         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
23407         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
23408         return (uint64_t)ret_ret;
23409 }
23410
23411 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
23412         LDKIgnoringMessageHandler this_arg_conv;
23413         this_arg_conv.inner = (void*)(this_arg & (~1));
23414         this_arg_conv.is_owned = false;
23415         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
23416         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
23417         return (uint64_t)ret_ret;
23418 }
23419
23420 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
23421         LDKIgnoringMessageHandler this_arg_conv;
23422         this_arg_conv.inner = (void*)(this_arg & (~1));
23423         this_arg_conv.is_owned = false;
23424         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
23425         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
23426         return (uint64_t)ret_ret;
23427 }
23428
23429 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
23430         LDKErroringMessageHandler this_obj_conv;
23431         this_obj_conv.inner = (void*)(this_obj & (~1));
23432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23433         ErroringMessageHandler_free(this_obj_conv);
23434 }
23435
23436 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
23437         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
23438         uint64_t ret_ref = 0;
23439         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23440         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23441         ret_ref = (uint64_t)ret_var.inner;
23442         if (ret_var.is_owned) {
23443                 ret_ref |= 1;
23444         }
23445         return ret_ref;
23446 }
23447
23448 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
23449         LDKErroringMessageHandler this_arg_conv;
23450         this_arg_conv.inner = (void*)(this_arg & (~1));
23451         this_arg_conv.is_owned = false;
23452         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
23453         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
23454         return (uint64_t)ret_ret;
23455 }
23456
23457 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
23458         LDKErroringMessageHandler this_arg_conv;
23459         this_arg_conv.inner = (void*)(this_arg & (~1));
23460         this_arg_conv.is_owned = false;
23461         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
23462         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
23463         return (uint64_t)ret_ret;
23464 }
23465
23466 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
23467         LDKMessageHandler this_obj_conv;
23468         this_obj_conv.inner = (void*)(this_obj & (~1));
23469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23470         MessageHandler_free(this_obj_conv);
23471 }
23472
23473 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
23474         LDKMessageHandler this_ptr_conv;
23475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23476         this_ptr_conv.is_owned = false;
23477         // WARNING: This object doesn't live past this scope, needs clone!
23478         uint64_t ret_ret = ((uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
23479         return ret_ret;
23480 }
23481
23482 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
23483         LDKMessageHandler this_ptr_conv;
23484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23485         this_ptr_conv.is_owned = false;
23486         void* val_ptr = (void*)(((uint64_t)val) & ~1);
23487         CHECK_ACCESS(val_ptr);
23488         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
23489         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
23490 }
23491
23492 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
23493         LDKMessageHandler this_ptr_conv;
23494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23495         this_ptr_conv.is_owned = false;
23496         // WARNING: This object doesn't live past this scope, needs clone!
23497         uint64_t ret_ret = ((uint64_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
23498         return ret_ret;
23499 }
23500
23501 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
23502         LDKMessageHandler this_ptr_conv;
23503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23504         this_ptr_conv.is_owned = false;
23505         void* val_ptr = (void*)(((uint64_t)val) & ~1);
23506         CHECK_ACCESS(val_ptr);
23507         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
23508         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
23509 }
23510
23511 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
23512         void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
23513         CHECK_ACCESS(chan_handler_arg_ptr);
23514         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
23515         void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
23516         CHECK_ACCESS(route_handler_arg_ptr);
23517         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
23518         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
23519         uint64_t ret_ref = 0;
23520         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23521         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23522         ret_ref = (uint64_t)ret_var.inner;
23523         if (ret_var.is_owned) {
23524                 ret_ref |= 1;
23525         }
23526         return ret_ref;
23527 }
23528
23529 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
23530         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
23531         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
23532         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
23533         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
23534         *ret_ret = SocketDescriptor_clone(orig_conv);
23535         return (uint64_t)ret_ret;
23536 }
23537
23538 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
23539         if ((this_ptr & 1) != 0) return;
23540         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23541         CHECK_ACCESS(this_ptr_ptr);
23542         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
23543         FREE((void*)this_ptr);
23544         SocketDescriptor_free(this_ptr_conv);
23545 }
23546
23547 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
23548         LDKPeerHandleError this_obj_conv;
23549         this_obj_conv.inner = (void*)(this_obj & (~1));
23550         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23551         PeerHandleError_free(this_obj_conv);
23552 }
23553
23554 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
23555         LDKPeerHandleError this_ptr_conv;
23556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23557         this_ptr_conv.is_owned = false;
23558         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
23559         return ret_val;
23560 }
23561
23562 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
23563         LDKPeerHandleError this_ptr_conv;
23564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23565         this_ptr_conv.is_owned = false;
23566         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
23567 }
23568
23569 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
23570         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
23571         uint64_t ret_ref = 0;
23572         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23573         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23574         ret_ref = (uint64_t)ret_var.inner;
23575         if (ret_var.is_owned) {
23576                 ret_ref |= 1;
23577         }
23578         return ret_ref;
23579 }
23580
23581 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
23582         LDKPeerHandleError orig_conv;
23583         orig_conv.inner = (void*)(orig & (~1));
23584         orig_conv.is_owned = false;
23585         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
23586         uint64_t ret_ref = 0;
23587         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23588         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23589         ret_ref = (uint64_t)ret_var.inner;
23590         if (ret_var.is_owned) {
23591                 ret_ref |= 1;
23592         }
23593         return ret_ref;
23594 }
23595
23596 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
23597         LDKPeerManager this_obj_conv;
23598         this_obj_conv.inner = (void*)(this_obj & (~1));
23599         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23600         PeerManager_free(this_obj_conv);
23601 }
23602
23603 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) {
23604         LDKMessageHandler message_handler_conv;
23605         message_handler_conv.inner = (void*)(message_handler & (~1));
23606         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
23607         // Warning: we need a move here but no clone is available for LDKMessageHandler
23608         LDKSecretKey our_node_secret_ref;
23609         CHECK(*((uint32_t*)our_node_secret) == 32);
23610         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
23611         unsigned char ephemeral_random_data_arr[32];
23612         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
23613         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
23614         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
23615         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
23616         CHECK_ACCESS(logger_ptr);
23617         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23618         void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
23619         CHECK_ACCESS(custom_message_handler_ptr);
23620         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
23621         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
23622         uint64_t ret_ref = 0;
23623         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23624         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23625         ret_ref = (uint64_t)ret_var.inner;
23626         if (ret_var.is_owned) {
23627                 ret_ref |= 1;
23628         }
23629         return ret_ref;
23630 }
23631
23632 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
23633         LDKPeerManager this_arg_conv;
23634         this_arg_conv.inner = (void*)(this_arg & (~1));
23635         this_arg_conv.is_owned = false;
23636         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
23637         ptrArray ret_arr = NULL;
23638         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
23639         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
23640         for (size_t m = 0; m < ret_var.datalen; m++) {
23641                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23642                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
23643                 ret_arr_ptr[m] = ret_conv_12_arr;
23644         }
23645         
23646         FREE(ret_var.data);
23647         return ret_arr;
23648 }
23649
23650 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
23651         LDKPeerManager this_arg_conv;
23652         this_arg_conv.inner = (void*)(this_arg & (~1));
23653         this_arg_conv.is_owned = false;
23654         LDKPublicKey their_node_id_ref;
23655         CHECK(*((uint32_t*)their_node_id) == 33);
23656         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
23657         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
23658         CHECK_ACCESS(descriptor_ptr);
23659         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
23660         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23661         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
23662         return (uint64_t)ret_conv;
23663 }
23664
23665 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
23666         LDKPeerManager this_arg_conv;
23667         this_arg_conv.inner = (void*)(this_arg & (~1));
23668         this_arg_conv.is_owned = false;
23669         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
23670         CHECK_ACCESS(descriptor_ptr);
23671         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
23672         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23673         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
23674         return (uint64_t)ret_conv;
23675 }
23676
23677 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
23678         LDKPeerManager this_arg_conv;
23679         this_arg_conv.inner = (void*)(this_arg & (~1));
23680         this_arg_conv.is_owned = false;
23681         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
23682         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
23683         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
23684         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23685         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
23686         return (uint64_t)ret_conv;
23687 }
23688
23689 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
23690         LDKPeerManager this_arg_conv;
23691         this_arg_conv.inner = (void*)(this_arg & (~1));
23692         this_arg_conv.is_owned = false;
23693         void* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
23694         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
23695         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
23696         LDKu8slice data_ref;
23697         data_ref.datalen = *((uint32_t*)data);
23698         data_ref.data = (int8_t*)(data + 4);
23699         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23700         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
23701         return (uint64_t)ret_conv;
23702 }
23703
23704 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
23705         LDKPeerManager this_arg_conv;
23706         this_arg_conv.inner = (void*)(this_arg & (~1));
23707         this_arg_conv.is_owned = false;
23708         PeerManager_process_events(&this_arg_conv);
23709 }
23710
23711 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
23712         LDKPeerManager this_arg_conv;
23713         this_arg_conv.inner = (void*)(this_arg & (~1));
23714         this_arg_conv.is_owned = false;
23715         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
23716         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
23717         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
23718         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
23719 }
23720
23721 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
23722         LDKPeerManager this_arg_conv;
23723         this_arg_conv.inner = (void*)(this_arg & (~1));
23724         this_arg_conv.is_owned = false;
23725         LDKPublicKey node_id_ref;
23726         CHECK(*((uint32_t*)node_id) == 33);
23727         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
23728         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
23729 }
23730
23731 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
23732         LDKPeerManager this_arg_conv;
23733         this_arg_conv.inner = (void*)(this_arg & (~1));
23734         this_arg_conv.is_owned = false;
23735         PeerManager_disconnect_all_peers(&this_arg_conv);
23736 }
23737
23738 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
23739         LDKPeerManager this_arg_conv;
23740         this_arg_conv.inner = (void*)(this_arg & (~1));
23741         this_arg_conv.is_owned = false;
23742         PeerManager_timer_tick_occurred(&this_arg_conv);
23743 }
23744
23745 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
23746         unsigned char commitment_seed_arr[32];
23747         CHECK(*((uint32_t*)commitment_seed) == 32);
23748         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
23749         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
23750         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23751         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
23752         return ret_arr;
23753 }
23754
23755 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) {
23756         LDKCVec_u8Z to_holder_script_ref;
23757         to_holder_script_ref.datalen = *((uint32_t*)to_holder_script);
23758         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
23759         memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen);
23760         LDKCVec_u8Z to_counterparty_script_ref;
23761         to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script);
23762         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
23763         memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen);
23764         LDKOutPoint funding_outpoint_conv;
23765         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
23766         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
23767         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
23768         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);
23769         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23770         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23771         Transaction_free(ret_var);
23772         return ret_arr;
23773 }
23774
23775 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
23776         LDKPublicKey per_commitment_point_ref;
23777         CHECK(*((uint32_t*)per_commitment_point) == 33);
23778         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
23779         unsigned char base_secret_arr[32];
23780         CHECK(*((uint32_t*)base_secret) == 32);
23781         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
23782         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
23783         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
23784         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
23785         return (uint64_t)ret_conv;
23786 }
23787
23788 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
23789         LDKPublicKey per_commitment_point_ref;
23790         CHECK(*((uint32_t*)per_commitment_point) == 33);
23791         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
23792         LDKPublicKey base_point_ref;
23793         CHECK(*((uint32_t*)base_point) == 33);
23794         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
23795         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
23796         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
23797         return (uint64_t)ret_conv;
23798 }
23799
23800 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
23801         unsigned char per_commitment_secret_arr[32];
23802         CHECK(*((uint32_t*)per_commitment_secret) == 32);
23803         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
23804         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
23805         unsigned char countersignatory_revocation_base_secret_arr[32];
23806         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
23807         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
23808         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
23809         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
23810         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
23811         return (uint64_t)ret_conv;
23812 }
23813
23814 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
23815         LDKPublicKey per_commitment_point_ref;
23816         CHECK(*((uint32_t*)per_commitment_point) == 33);
23817         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
23818         LDKPublicKey countersignatory_revocation_base_point_ref;
23819         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
23820         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
23821         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
23822         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
23823         return (uint64_t)ret_conv;
23824 }
23825
23826 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
23827         LDKTxCreationKeys this_obj_conv;
23828         this_obj_conv.inner = (void*)(this_obj & (~1));
23829         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23830         TxCreationKeys_free(this_obj_conv);
23831 }
23832
23833 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
23834         LDKTxCreationKeys this_ptr_conv;
23835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23836         this_ptr_conv.is_owned = false;
23837         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23838         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23839         return ret_arr;
23840 }
23841
23842 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
23843         LDKTxCreationKeys this_ptr_conv;
23844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23845         this_ptr_conv.is_owned = false;
23846         LDKPublicKey val_ref;
23847         CHECK(*((uint32_t*)val) == 33);
23848         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23849         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
23850 }
23851
23852 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
23853         LDKTxCreationKeys this_ptr_conv;
23854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23855         this_ptr_conv.is_owned = false;
23856         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23857         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
23858         return ret_arr;
23859 }
23860
23861 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
23862         LDKTxCreationKeys this_ptr_conv;
23863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23864         this_ptr_conv.is_owned = false;
23865         LDKPublicKey val_ref;
23866         CHECK(*((uint32_t*)val) == 33);
23867         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23868         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
23869 }
23870
23871 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
23872         LDKTxCreationKeys this_ptr_conv;
23873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23874         this_ptr_conv.is_owned = false;
23875         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23876         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
23877         return ret_arr;
23878 }
23879
23880 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
23881         LDKTxCreationKeys this_ptr_conv;
23882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23883         this_ptr_conv.is_owned = false;
23884         LDKPublicKey val_ref;
23885         CHECK(*((uint32_t*)val) == 33);
23886         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23887         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
23888 }
23889
23890 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
23891         LDKTxCreationKeys this_ptr_conv;
23892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23893         this_ptr_conv.is_owned = false;
23894         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23895         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
23896         return ret_arr;
23897 }
23898
23899 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
23900         LDKTxCreationKeys this_ptr_conv;
23901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23902         this_ptr_conv.is_owned = false;
23903         LDKPublicKey val_ref;
23904         CHECK(*((uint32_t*)val) == 33);
23905         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23906         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
23907 }
23908
23909 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
23910         LDKTxCreationKeys this_ptr_conv;
23911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23912         this_ptr_conv.is_owned = false;
23913         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23914         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
23915         return ret_arr;
23916 }
23917
23918 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
23919         LDKTxCreationKeys this_ptr_conv;
23920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23921         this_ptr_conv.is_owned = false;
23922         LDKPublicKey val_ref;
23923         CHECK(*((uint32_t*)val) == 33);
23924         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23925         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
23926 }
23927
23928 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) {
23929         LDKPublicKey per_commitment_point_arg_ref;
23930         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
23931         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
23932         LDKPublicKey revocation_key_arg_ref;
23933         CHECK(*((uint32_t*)revocation_key_arg) == 33);
23934         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
23935         LDKPublicKey broadcaster_htlc_key_arg_ref;
23936         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
23937         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
23938         LDKPublicKey countersignatory_htlc_key_arg_ref;
23939         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
23940         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
23941         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
23942         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
23943         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
23944         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);
23945         uint64_t ret_ref = 0;
23946         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23947         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23948         ret_ref = (uint64_t)ret_var.inner;
23949         if (ret_var.is_owned) {
23950                 ret_ref |= 1;
23951         }
23952         return ret_ref;
23953 }
23954
23955 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
23956         LDKTxCreationKeys orig_conv;
23957         orig_conv.inner = (void*)(orig & (~1));
23958         orig_conv.is_owned = false;
23959         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
23960         uint64_t ret_ref = 0;
23961         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23962         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23963         ret_ref = (uint64_t)ret_var.inner;
23964         if (ret_var.is_owned) {
23965                 ret_ref |= 1;
23966         }
23967         return ret_ref;
23968 }
23969
23970 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
23971         LDKTxCreationKeys obj_conv;
23972         obj_conv.inner = (void*)(obj & (~1));
23973         obj_conv.is_owned = false;
23974         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
23975         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23976         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23977         CVec_u8Z_free(ret_var);
23978         return ret_arr;
23979 }
23980
23981 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
23982         LDKu8slice ser_ref;
23983         ser_ref.datalen = *((uint32_t*)ser);
23984         ser_ref.data = (int8_t*)(ser + 4);
23985         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
23986         *ret_conv = TxCreationKeys_read(ser_ref);
23987         return (uint64_t)ret_conv;
23988 }
23989
23990 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
23991         LDKChannelPublicKeys this_obj_conv;
23992         this_obj_conv.inner = (void*)(this_obj & (~1));
23993         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23994         ChannelPublicKeys_free(this_obj_conv);
23995 }
23996
23997 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
23998         LDKChannelPublicKeys this_ptr_conv;
23999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24000         this_ptr_conv.is_owned = false;
24001         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24002         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
24003         return ret_arr;
24004 }
24005
24006 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
24007         LDKChannelPublicKeys this_ptr_conv;
24008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24009         this_ptr_conv.is_owned = false;
24010         LDKPublicKey val_ref;
24011         CHECK(*((uint32_t*)val) == 33);
24012         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
24013         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
24014 }
24015
24016 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
24017         LDKChannelPublicKeys this_ptr_conv;
24018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24019         this_ptr_conv.is_owned = false;
24020         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24021         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
24022         return ret_arr;
24023 }
24024
24025 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
24026         LDKChannelPublicKeys this_ptr_conv;
24027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24028         this_ptr_conv.is_owned = false;
24029         LDKPublicKey val_ref;
24030         CHECK(*((uint32_t*)val) == 33);
24031         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
24032         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
24033 }
24034
24035 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
24036         LDKChannelPublicKeys this_ptr_conv;
24037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24038         this_ptr_conv.is_owned = false;
24039         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24040         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
24041         return ret_arr;
24042 }
24043
24044 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
24045         LDKChannelPublicKeys this_ptr_conv;
24046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24047         this_ptr_conv.is_owned = false;
24048         LDKPublicKey val_ref;
24049         CHECK(*((uint32_t*)val) == 33);
24050         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
24051         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
24052 }
24053
24054 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
24055         LDKChannelPublicKeys this_ptr_conv;
24056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24057         this_ptr_conv.is_owned = false;
24058         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24059         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
24060         return ret_arr;
24061 }
24062
24063 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
24064         LDKChannelPublicKeys this_ptr_conv;
24065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24066         this_ptr_conv.is_owned = false;
24067         LDKPublicKey val_ref;
24068         CHECK(*((uint32_t*)val) == 33);
24069         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
24070         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
24071 }
24072
24073 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
24074         LDKChannelPublicKeys this_ptr_conv;
24075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24076         this_ptr_conv.is_owned = false;
24077         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24078         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
24079         return ret_arr;
24080 }
24081
24082 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
24083         LDKChannelPublicKeys this_ptr_conv;
24084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24085         this_ptr_conv.is_owned = false;
24086         LDKPublicKey val_ref;
24087         CHECK(*((uint32_t*)val) == 33);
24088         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
24089         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
24090 }
24091
24092 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) {
24093         LDKPublicKey funding_pubkey_arg_ref;
24094         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
24095         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
24096         LDKPublicKey revocation_basepoint_arg_ref;
24097         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
24098         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
24099         LDKPublicKey payment_point_arg_ref;
24100         CHECK(*((uint32_t*)payment_point_arg) == 33);
24101         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
24102         LDKPublicKey delayed_payment_basepoint_arg_ref;
24103         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
24104         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
24105         LDKPublicKey htlc_basepoint_arg_ref;
24106         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
24107         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
24108         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);
24109         uint64_t ret_ref = 0;
24110         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24111         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24112         ret_ref = (uint64_t)ret_var.inner;
24113         if (ret_var.is_owned) {
24114                 ret_ref |= 1;
24115         }
24116         return ret_ref;
24117 }
24118
24119 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
24120         LDKChannelPublicKeys orig_conv;
24121         orig_conv.inner = (void*)(orig & (~1));
24122         orig_conv.is_owned = false;
24123         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
24124         uint64_t ret_ref = 0;
24125         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24126         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24127         ret_ref = (uint64_t)ret_var.inner;
24128         if (ret_var.is_owned) {
24129                 ret_ref |= 1;
24130         }
24131         return ret_ref;
24132 }
24133
24134 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
24135         LDKChannelPublicKeys obj_conv;
24136         obj_conv.inner = (void*)(obj & (~1));
24137         obj_conv.is_owned = false;
24138         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
24139         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24140         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24141         CVec_u8Z_free(ret_var);
24142         return ret_arr;
24143 }
24144
24145 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
24146         LDKu8slice ser_ref;
24147         ser_ref.datalen = *((uint32_t*)ser);
24148         ser_ref.data = (int8_t*)(ser + 4);
24149         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
24150         *ret_conv = ChannelPublicKeys_read(ser_ref);
24151         return (uint64_t)ret_conv;
24152 }
24153
24154 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) {
24155         LDKPublicKey per_commitment_point_ref;
24156         CHECK(*((uint32_t*)per_commitment_point) == 33);
24157         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
24158         LDKPublicKey broadcaster_delayed_payment_base_ref;
24159         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
24160         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
24161         LDKPublicKey broadcaster_htlc_base_ref;
24162         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
24163         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
24164         LDKPublicKey countersignatory_revocation_base_ref;
24165         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
24166         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
24167         LDKPublicKey countersignatory_htlc_base_ref;
24168         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
24169         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
24170         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
24171         *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);
24172         return (uint64_t)ret_conv;
24173 }
24174
24175 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
24176         LDKPublicKey per_commitment_point_ref;
24177         CHECK(*((uint32_t*)per_commitment_point) == 33);
24178         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
24179         LDKChannelPublicKeys broadcaster_keys_conv;
24180         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
24181         broadcaster_keys_conv.is_owned = false;
24182         LDKChannelPublicKeys countersignatory_keys_conv;
24183         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
24184         countersignatory_keys_conv.is_owned = false;
24185         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
24186         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
24187         return (uint64_t)ret_conv;
24188 }
24189
24190 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
24191         LDKPublicKey revocation_key_ref;
24192         CHECK(*((uint32_t*)revocation_key) == 33);
24193         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
24194         LDKPublicKey broadcaster_delayed_payment_key_ref;
24195         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
24196         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
24197         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
24198         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24199         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24200         CVec_u8Z_free(ret_var);
24201         return ret_arr;
24202 }
24203
24204 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
24205         LDKHTLCOutputInCommitment this_obj_conv;
24206         this_obj_conv.inner = (void*)(this_obj & (~1));
24207         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24208         HTLCOutputInCommitment_free(this_obj_conv);
24209 }
24210
24211 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
24212         LDKHTLCOutputInCommitment this_ptr_conv;
24213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24214         this_ptr_conv.is_owned = false;
24215         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
24216         return ret_val;
24217 }
24218
24219 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
24220         LDKHTLCOutputInCommitment this_ptr_conv;
24221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24222         this_ptr_conv.is_owned = false;
24223         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
24224 }
24225
24226 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
24227         LDKHTLCOutputInCommitment this_ptr_conv;
24228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24229         this_ptr_conv.is_owned = false;
24230         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
24231         return ret_val;
24232 }
24233
24234 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
24235         LDKHTLCOutputInCommitment this_ptr_conv;
24236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24237         this_ptr_conv.is_owned = false;
24238         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
24239 }
24240
24241 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
24242         LDKHTLCOutputInCommitment this_ptr_conv;
24243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24244         this_ptr_conv.is_owned = false;
24245         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
24246         return ret_val;
24247 }
24248
24249 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
24250         LDKHTLCOutputInCommitment this_ptr_conv;
24251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24252         this_ptr_conv.is_owned = false;
24253         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
24254 }
24255
24256 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
24257         LDKHTLCOutputInCommitment this_ptr_conv;
24258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24259         this_ptr_conv.is_owned = false;
24260         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24261         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
24262         return ret_arr;
24263 }
24264
24265 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
24266         LDKHTLCOutputInCommitment this_ptr_conv;
24267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24268         this_ptr_conv.is_owned = false;
24269         LDKThirtyTwoBytes val_ref;
24270         CHECK(*((uint32_t*)val) == 32);
24271         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24272         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
24273 }
24274
24275 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
24276         LDKHTLCOutputInCommitment this_ptr_conv;
24277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24278         this_ptr_conv.is_owned = false;
24279         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
24280         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
24281         uint64_t ret_ref = (uint64_t)ret_copy;
24282         return ret_ref;
24283 }
24284
24285 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
24286         LDKHTLCOutputInCommitment this_ptr_conv;
24287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24288         this_ptr_conv.is_owned = false;
24289         void* val_ptr = (void*)(((uint64_t)val) & ~1);
24290         CHECK_ACCESS(val_ptr);
24291         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
24292         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
24293         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
24294 }
24295
24296 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) {
24297         LDKThirtyTwoBytes payment_hash_arg_ref;
24298         CHECK(*((uint32_t*)payment_hash_arg) == 32);
24299         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
24300         void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
24301         CHECK_ACCESS(transaction_output_index_arg_ptr);
24302         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
24303         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
24304         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
24305         uint64_t ret_ref = 0;
24306         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24307         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24308         ret_ref = (uint64_t)ret_var.inner;
24309         if (ret_var.is_owned) {
24310                 ret_ref |= 1;
24311         }
24312         return ret_ref;
24313 }
24314
24315 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
24316         LDKHTLCOutputInCommitment orig_conv;
24317         orig_conv.inner = (void*)(orig & (~1));
24318         orig_conv.is_owned = false;
24319         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
24320         uint64_t ret_ref = 0;
24321         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24322         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24323         ret_ref = (uint64_t)ret_var.inner;
24324         if (ret_var.is_owned) {
24325                 ret_ref |= 1;
24326         }
24327         return ret_ref;
24328 }
24329
24330 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
24331         LDKHTLCOutputInCommitment obj_conv;
24332         obj_conv.inner = (void*)(obj & (~1));
24333         obj_conv.is_owned = false;
24334         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
24335         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24336         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24337         CVec_u8Z_free(ret_var);
24338         return ret_arr;
24339 }
24340
24341 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
24342         LDKu8slice ser_ref;
24343         ser_ref.datalen = *((uint32_t*)ser);
24344         ser_ref.data = (int8_t*)(ser + 4);
24345         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
24346         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
24347         return (uint64_t)ret_conv;
24348 }
24349
24350 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
24351         LDKHTLCOutputInCommitment htlc_conv;
24352         htlc_conv.inner = (void*)(htlc & (~1));
24353         htlc_conv.is_owned = false;
24354         LDKTxCreationKeys keys_conv;
24355         keys_conv.inner = (void*)(keys & (~1));
24356         keys_conv.is_owned = false;
24357         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
24358         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24359         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24360         CVec_u8Z_free(ret_var);
24361         return ret_arr;
24362 }
24363
24364 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
24365         LDKPublicKey broadcaster_ref;
24366         CHECK(*((uint32_t*)broadcaster) == 33);
24367         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
24368         LDKPublicKey countersignatory_ref;
24369         CHECK(*((uint32_t*)countersignatory) == 33);
24370         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
24371         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
24372         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24373         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24374         CVec_u8Z_free(ret_var);
24375         return ret_arr;
24376 }
24377
24378 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) {
24379         unsigned char commitment_txid_arr[32];
24380         CHECK(*((uint32_t*)commitment_txid) == 32);
24381         memcpy(commitment_txid_arr, (uint8_t*)(commitment_txid + 4), 32);
24382         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
24383         LDKHTLCOutputInCommitment htlc_conv;
24384         htlc_conv.inner = (void*)(htlc & (~1));
24385         htlc_conv.is_owned = false;
24386         LDKPublicKey broadcaster_delayed_payment_key_ref;
24387         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
24388         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
24389         LDKPublicKey revocation_key_ref;
24390         CHECK(*((uint32_t*)revocation_key) == 33);
24391         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
24392         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
24393         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24394         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24395         Transaction_free(ret_var);
24396         return ret_arr;
24397 }
24398
24399 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
24400         LDKChannelTransactionParameters this_obj_conv;
24401         this_obj_conv.inner = (void*)(this_obj & (~1));
24402         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24403         ChannelTransactionParameters_free(this_obj_conv);
24404 }
24405
24406 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
24407         LDKChannelTransactionParameters this_ptr_conv;
24408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24409         this_ptr_conv.is_owned = false;
24410         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
24411         uint64_t ret_ref = 0;
24412         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24413         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24414         ret_ref = (uint64_t)ret_var.inner;
24415         if (ret_var.is_owned) {
24416                 ret_ref |= 1;
24417         }
24418         return ret_ref;
24419 }
24420
24421 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
24422         LDKChannelTransactionParameters this_ptr_conv;
24423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24424         this_ptr_conv.is_owned = false;
24425         LDKChannelPublicKeys val_conv;
24426         val_conv.inner = (void*)(val & (~1));
24427         val_conv.is_owned = (val & 1) || (val == 0);
24428         val_conv = ChannelPublicKeys_clone(&val_conv);
24429         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
24430 }
24431
24432 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
24433         LDKChannelTransactionParameters this_ptr_conv;
24434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24435         this_ptr_conv.is_owned = false;
24436         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
24437         return ret_val;
24438 }
24439
24440 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
24441         LDKChannelTransactionParameters this_ptr_conv;
24442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24443         this_ptr_conv.is_owned = false;
24444         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
24445 }
24446
24447 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
24448         LDKChannelTransactionParameters this_ptr_conv;
24449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24450         this_ptr_conv.is_owned = false;
24451         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
24452         return ret_val;
24453 }
24454
24455 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
24456         LDKChannelTransactionParameters this_ptr_conv;
24457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24458         this_ptr_conv.is_owned = false;
24459         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
24460 }
24461
24462 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
24463         LDKChannelTransactionParameters this_ptr_conv;
24464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24465         this_ptr_conv.is_owned = false;
24466         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
24467         uint64_t ret_ref = 0;
24468         if ((uint64_t)ret_var.inner > 4096) {
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                 ret_ref = (uint64_t)ret_var.inner;
24472                 if (ret_var.is_owned) {
24473                         ret_ref |= 1;
24474                 }
24475         }
24476         return ret_ref;
24477 }
24478
24479 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
24480         LDKChannelTransactionParameters this_ptr_conv;
24481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24482         this_ptr_conv.is_owned = false;
24483         LDKCounterpartyChannelTransactionParameters val_conv;
24484         val_conv.inner = (void*)(val & (~1));
24485         val_conv.is_owned = (val & 1) || (val == 0);
24486         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
24487         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
24488 }
24489
24490 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
24491         LDKChannelTransactionParameters this_ptr_conv;
24492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24493         this_ptr_conv.is_owned = false;
24494         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
24495         uint64_t ret_ref = 0;
24496         if ((uint64_t)ret_var.inner > 4096) {
24497                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24498                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24499                 ret_ref = (uint64_t)ret_var.inner;
24500                 if (ret_var.is_owned) {
24501                         ret_ref |= 1;
24502                 }
24503         }
24504         return ret_ref;
24505 }
24506
24507 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
24508         LDKChannelTransactionParameters this_ptr_conv;
24509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24510         this_ptr_conv.is_owned = false;
24511         LDKOutPoint val_conv;
24512         val_conv.inner = (void*)(val & (~1));
24513         val_conv.is_owned = (val & 1) || (val == 0);
24514         val_conv = OutPoint_clone(&val_conv);
24515         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
24516 }
24517
24518 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) {
24519         LDKChannelPublicKeys holder_pubkeys_arg_conv;
24520         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
24521         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
24522         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
24523         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
24524         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
24525         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
24526         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
24527         LDKOutPoint funding_outpoint_arg_conv;
24528         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
24529         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
24530         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
24531         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);
24532         uint64_t ret_ref = 0;
24533         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24534         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24535         ret_ref = (uint64_t)ret_var.inner;
24536         if (ret_var.is_owned) {
24537                 ret_ref |= 1;
24538         }
24539         return ret_ref;
24540 }
24541
24542 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
24543         LDKChannelTransactionParameters orig_conv;
24544         orig_conv.inner = (void*)(orig & (~1));
24545         orig_conv.is_owned = false;
24546         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
24547         uint64_t ret_ref = 0;
24548         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24549         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24550         ret_ref = (uint64_t)ret_var.inner;
24551         if (ret_var.is_owned) {
24552                 ret_ref |= 1;
24553         }
24554         return ret_ref;
24555 }
24556
24557 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
24558         LDKCounterpartyChannelTransactionParameters this_obj_conv;
24559         this_obj_conv.inner = (void*)(this_obj & (~1));
24560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24561         CounterpartyChannelTransactionParameters_free(this_obj_conv);
24562 }
24563
24564 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
24565         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
24566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24567         this_ptr_conv.is_owned = false;
24568         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
24569         uint64_t ret_ref = 0;
24570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24572         ret_ref = (uint64_t)ret_var.inner;
24573         if (ret_var.is_owned) {
24574                 ret_ref |= 1;
24575         }
24576         return ret_ref;
24577 }
24578
24579 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
24580         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
24581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24582         this_ptr_conv.is_owned = false;
24583         LDKChannelPublicKeys val_conv;
24584         val_conv.inner = (void*)(val & (~1));
24585         val_conv.is_owned = (val & 1) || (val == 0);
24586         val_conv = ChannelPublicKeys_clone(&val_conv);
24587         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
24588 }
24589
24590 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
24591         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
24592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24593         this_ptr_conv.is_owned = false;
24594         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
24595         return ret_val;
24596 }
24597
24598 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
24599         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
24600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24601         this_ptr_conv.is_owned = false;
24602         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
24603 }
24604
24605 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
24606         LDKChannelPublicKeys pubkeys_arg_conv;
24607         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
24608         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
24609         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
24610         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
24611         uint64_t ret_ref = 0;
24612         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24613         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24614         ret_ref = (uint64_t)ret_var.inner;
24615         if (ret_var.is_owned) {
24616                 ret_ref |= 1;
24617         }
24618         return ret_ref;
24619 }
24620
24621 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
24622         LDKCounterpartyChannelTransactionParameters orig_conv;
24623         orig_conv.inner = (void*)(orig & (~1));
24624         orig_conv.is_owned = false;
24625         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
24626         uint64_t ret_ref = 0;
24627         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24628         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24629         ret_ref = (uint64_t)ret_var.inner;
24630         if (ret_var.is_owned) {
24631                 ret_ref |= 1;
24632         }
24633         return ret_ref;
24634 }
24635
24636 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
24637         LDKChannelTransactionParameters this_arg_conv;
24638         this_arg_conv.inner = (void*)(this_arg & (~1));
24639         this_arg_conv.is_owned = false;
24640         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
24641         return ret_val;
24642 }
24643
24644 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
24645         LDKChannelTransactionParameters this_arg_conv;
24646         this_arg_conv.inner = (void*)(this_arg & (~1));
24647         this_arg_conv.is_owned = false;
24648         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
24649         uint64_t ret_ref = 0;
24650         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24651         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24652         ret_ref = (uint64_t)ret_var.inner;
24653         if (ret_var.is_owned) {
24654                 ret_ref |= 1;
24655         }
24656         return ret_ref;
24657 }
24658
24659 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
24660         LDKChannelTransactionParameters this_arg_conv;
24661         this_arg_conv.inner = (void*)(this_arg & (~1));
24662         this_arg_conv.is_owned = false;
24663         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
24664         uint64_t ret_ref = 0;
24665         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24666         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24667         ret_ref = (uint64_t)ret_var.inner;
24668         if (ret_var.is_owned) {
24669                 ret_ref |= 1;
24670         }
24671         return ret_ref;
24672 }
24673
24674 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
24675         LDKCounterpartyChannelTransactionParameters obj_conv;
24676         obj_conv.inner = (void*)(obj & (~1));
24677         obj_conv.is_owned = false;
24678         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
24679         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24680         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24681         CVec_u8Z_free(ret_var);
24682         return ret_arr;
24683 }
24684
24685 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
24686         LDKu8slice ser_ref;
24687         ser_ref.datalen = *((uint32_t*)ser);
24688         ser_ref.data = (int8_t*)(ser + 4);
24689         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
24690         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
24691         return (uint64_t)ret_conv;
24692 }
24693
24694 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
24695         LDKChannelTransactionParameters obj_conv;
24696         obj_conv.inner = (void*)(obj & (~1));
24697         obj_conv.is_owned = false;
24698         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
24699         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24700         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24701         CVec_u8Z_free(ret_var);
24702         return ret_arr;
24703 }
24704
24705 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
24706         LDKu8slice ser_ref;
24707         ser_ref.datalen = *((uint32_t*)ser);
24708         ser_ref.data = (int8_t*)(ser + 4);
24709         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
24710         *ret_conv = ChannelTransactionParameters_read(ser_ref);
24711         return (uint64_t)ret_conv;
24712 }
24713
24714 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
24715         LDKDirectedChannelTransactionParameters this_obj_conv;
24716         this_obj_conv.inner = (void*)(this_obj & (~1));
24717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24718         DirectedChannelTransactionParameters_free(this_obj_conv);
24719 }
24720
24721 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
24722         LDKDirectedChannelTransactionParameters this_arg_conv;
24723         this_arg_conv.inner = (void*)(this_arg & (~1));
24724         this_arg_conv.is_owned = false;
24725         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
24726         uint64_t ret_ref = 0;
24727         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24728         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24729         ret_ref = (uint64_t)ret_var.inner;
24730         if (ret_var.is_owned) {
24731                 ret_ref |= 1;
24732         }
24733         return ret_ref;
24734 }
24735
24736 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
24737         LDKDirectedChannelTransactionParameters this_arg_conv;
24738         this_arg_conv.inner = (void*)(this_arg & (~1));
24739         this_arg_conv.is_owned = false;
24740         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
24741         uint64_t ret_ref = 0;
24742         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24743         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24744         ret_ref = (uint64_t)ret_var.inner;
24745         if (ret_var.is_owned) {
24746                 ret_ref |= 1;
24747         }
24748         return ret_ref;
24749 }
24750
24751 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
24752         LDKDirectedChannelTransactionParameters this_arg_conv;
24753         this_arg_conv.inner = (void*)(this_arg & (~1));
24754         this_arg_conv.is_owned = false;
24755         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
24756         return ret_val;
24757 }
24758
24759 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
24760         LDKDirectedChannelTransactionParameters this_arg_conv;
24761         this_arg_conv.inner = (void*)(this_arg & (~1));
24762         this_arg_conv.is_owned = false;
24763         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
24764         return ret_val;
24765 }
24766
24767 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
24768         LDKDirectedChannelTransactionParameters this_arg_conv;
24769         this_arg_conv.inner = (void*)(this_arg & (~1));
24770         this_arg_conv.is_owned = false;
24771         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
24772         uint64_t ret_ref = 0;
24773         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24774         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24775         ret_ref = (uint64_t)ret_var.inner;
24776         if (ret_var.is_owned) {
24777                 ret_ref |= 1;
24778         }
24779         return ret_ref;
24780 }
24781
24782 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
24783         LDKHolderCommitmentTransaction this_obj_conv;
24784         this_obj_conv.inner = (void*)(this_obj & (~1));
24785         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24786         HolderCommitmentTransaction_free(this_obj_conv);
24787 }
24788
24789 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
24790         LDKHolderCommitmentTransaction this_ptr_conv;
24791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24792         this_ptr_conv.is_owned = false;
24793         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
24794         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
24795         return ret_arr;
24796 }
24797
24798 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
24799         LDKHolderCommitmentTransaction this_ptr_conv;
24800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24801         this_ptr_conv.is_owned = false;
24802         LDKSignature val_ref;
24803         CHECK(*((uint32_t*)val) == 64);
24804         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
24805         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
24806 }
24807
24808 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
24809         LDKHolderCommitmentTransaction this_ptr_conv;
24810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24811         this_ptr_conv.is_owned = false;
24812         LDKCVec_SignatureZ val_constr;
24813         val_constr.datalen = *((uint32_t*)val);
24814         if (val_constr.datalen > 0)
24815                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
24816         else
24817                 val_constr.data = NULL;
24818         int8_tArray* val_vals = (int8_tArray*)(val + 4);
24819         for (size_t m = 0; m < val_constr.datalen; m++) {
24820                 int8_tArray val_conv_12 = val_vals[m];
24821                 LDKSignature val_conv_12_ref;
24822                 CHECK(*((uint32_t*)val_conv_12) == 64);
24823                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
24824                 val_constr.data[m] = val_conv_12_ref;
24825         }
24826         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
24827 }
24828
24829 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
24830         LDKHolderCommitmentTransaction orig_conv;
24831         orig_conv.inner = (void*)(orig & (~1));
24832         orig_conv.is_owned = false;
24833         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
24834         uint64_t ret_ref = 0;
24835         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24836         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24837         ret_ref = (uint64_t)ret_var.inner;
24838         if (ret_var.is_owned) {
24839                 ret_ref |= 1;
24840         }
24841         return ret_ref;
24842 }
24843
24844 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
24845         LDKHolderCommitmentTransaction obj_conv;
24846         obj_conv.inner = (void*)(obj & (~1));
24847         obj_conv.is_owned = false;
24848         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
24849         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24850         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24851         CVec_u8Z_free(ret_var);
24852         return ret_arr;
24853 }
24854
24855 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
24856         LDKu8slice ser_ref;
24857         ser_ref.datalen = *((uint32_t*)ser);
24858         ser_ref.data = (int8_t*)(ser + 4);
24859         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
24860         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
24861         return (uint64_t)ret_conv;
24862 }
24863
24864 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) {
24865         LDKCommitmentTransaction commitment_tx_conv;
24866         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
24867         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
24868         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
24869         LDKSignature counterparty_sig_ref;
24870         CHECK(*((uint32_t*)counterparty_sig) == 64);
24871         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
24872         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
24873         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
24874         if (counterparty_htlc_sigs_constr.datalen > 0)
24875                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
24876         else
24877                 counterparty_htlc_sigs_constr.data = NULL;
24878         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
24879         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
24880                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
24881                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
24882                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
24883                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
24884                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
24885         }
24886         LDKPublicKey holder_funding_key_ref;
24887         CHECK(*((uint32_t*)holder_funding_key) == 33);
24888         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
24889         LDKPublicKey counterparty_funding_key_ref;
24890         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
24891         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
24892         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
24893         uint64_t ret_ref = 0;
24894         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24895         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24896         ret_ref = (uint64_t)ret_var.inner;
24897         if (ret_var.is_owned) {
24898                 ret_ref |= 1;
24899         }
24900         return ret_ref;
24901 }
24902
24903 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
24904         LDKBuiltCommitmentTransaction this_obj_conv;
24905         this_obj_conv.inner = (void*)(this_obj & (~1));
24906         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24907         BuiltCommitmentTransaction_free(this_obj_conv);
24908 }
24909
24910 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
24911         LDKBuiltCommitmentTransaction this_ptr_conv;
24912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24913         this_ptr_conv.is_owned = false;
24914         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
24915         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24916         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24917         Transaction_free(ret_var);
24918         return ret_arr;
24919 }
24920
24921 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
24922         LDKBuiltCommitmentTransaction this_ptr_conv;
24923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24924         this_ptr_conv.is_owned = false;
24925         LDKTransaction val_ref;
24926         val_ref.datalen = *((uint32_t*)val);
24927         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
24928         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
24929         val_ref.data_is_owned = true;
24930         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
24931 }
24932
24933 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
24934         LDKBuiltCommitmentTransaction this_ptr_conv;
24935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24936         this_ptr_conv.is_owned = false;
24937         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24938         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
24939         return ret_arr;
24940 }
24941
24942 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
24943         LDKBuiltCommitmentTransaction this_ptr_conv;
24944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24945         this_ptr_conv.is_owned = false;
24946         LDKThirtyTwoBytes val_ref;
24947         CHECK(*((uint32_t*)val) == 32);
24948         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24949         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
24950 }
24951
24952 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
24953         LDKTransaction transaction_arg_ref;
24954         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
24955         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
24956         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
24957         transaction_arg_ref.data_is_owned = true;
24958         LDKThirtyTwoBytes txid_arg_ref;
24959         CHECK(*((uint32_t*)txid_arg) == 32);
24960         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
24961         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
24962         uint64_t ret_ref = 0;
24963         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24964         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24965         ret_ref = (uint64_t)ret_var.inner;
24966         if (ret_var.is_owned) {
24967                 ret_ref |= 1;
24968         }
24969         return ret_ref;
24970 }
24971
24972 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
24973         LDKBuiltCommitmentTransaction orig_conv;
24974         orig_conv.inner = (void*)(orig & (~1));
24975         orig_conv.is_owned = false;
24976         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
24977         uint64_t ret_ref = 0;
24978         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24979         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24980         ret_ref = (uint64_t)ret_var.inner;
24981         if (ret_var.is_owned) {
24982                 ret_ref |= 1;
24983         }
24984         return ret_ref;
24985 }
24986
24987 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
24988         LDKBuiltCommitmentTransaction obj_conv;
24989         obj_conv.inner = (void*)(obj & (~1));
24990         obj_conv.is_owned = false;
24991         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
24992         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24993         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24994         CVec_u8Z_free(ret_var);
24995         return ret_arr;
24996 }
24997
24998 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
24999         LDKu8slice ser_ref;
25000         ser_ref.datalen = *((uint32_t*)ser);
25001         ser_ref.data = (int8_t*)(ser + 4);
25002         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
25003         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
25004         return (uint64_t)ret_conv;
25005 }
25006
25007 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
25008         LDKBuiltCommitmentTransaction this_arg_conv;
25009         this_arg_conv.inner = (void*)(this_arg & (~1));
25010         this_arg_conv.is_owned = false;
25011         LDKu8slice funding_redeemscript_ref;
25012         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
25013         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
25014         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25015         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
25016         return ret_arr;
25017 }
25018
25019 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) {
25020         LDKBuiltCommitmentTransaction this_arg_conv;
25021         this_arg_conv.inner = (void*)(this_arg & (~1));
25022         this_arg_conv.is_owned = false;
25023         unsigned char funding_key_arr[32];
25024         CHECK(*((uint32_t*)funding_key) == 32);
25025         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
25026         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
25027         LDKu8slice funding_redeemscript_ref;
25028         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
25029         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
25030         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
25031         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
25032         return ret_arr;
25033 }
25034
25035 void  __attribute__((visibility("default"))) TS_ClosingTransaction_free(uint32_t this_obj) {
25036         LDKClosingTransaction this_obj_conv;
25037         this_obj_conv.inner = (void*)(this_obj & (~1));
25038         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25039         ClosingTransaction_free(this_obj_conv);
25040 }
25041
25042 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_clone(uint32_t orig) {
25043         LDKClosingTransaction orig_conv;
25044         orig_conv.inner = (void*)(orig & (~1));
25045         orig_conv.is_owned = false;
25046         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
25047         uint64_t ret_ref = 0;
25048         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25049         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25050         ret_ref = (uint64_t)ret_var.inner;
25051         if (ret_var.is_owned) {
25052                 ret_ref |= 1;
25053         }
25054         return ret_ref;
25055 }
25056
25057 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_hash(uint32_t o) {
25058         LDKClosingTransaction o_conv;
25059         o_conv.inner = (void*)(o & (~1));
25060         o_conv.is_owned = false;
25061         int64_t ret_val = ClosingTransaction_hash(&o_conv);
25062         return ret_val;
25063 }
25064
25065 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) {
25066         LDKCVec_u8Z to_holder_script_ref;
25067         to_holder_script_ref.datalen = *((uint32_t*)to_holder_script);
25068         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
25069         memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen);
25070         LDKCVec_u8Z to_counterparty_script_ref;
25071         to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script);
25072         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
25073         memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen);
25074         LDKOutPoint funding_outpoint_conv;
25075         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
25076         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
25077         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
25078         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
25079         uint64_t ret_ref = 0;
25080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25082         ret_ref = (uint64_t)ret_var.inner;
25083         if (ret_var.is_owned) {
25084                 ret_ref |= 1;
25085         }
25086         return ret_ref;
25087 }
25088
25089 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
25090         LDKClosingTransaction this_arg_conv;
25091         this_arg_conv.inner = (void*)(this_arg & (~1));
25092         this_arg_conv.is_owned = false;
25093         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
25094         uint64_t ret_ref = 0;
25095         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25096         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25097         ret_ref = (uint64_t)ret_var.inner;
25098         if (ret_var.is_owned) {
25099                 ret_ref |= 1;
25100         }
25101         return ret_ref;
25102 }
25103
25104 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
25105         LDKClosingTransaction this_arg_conv;
25106         this_arg_conv.inner = (void*)(this_arg & (~1));
25107         this_arg_conv.is_owned = false;
25108         LDKOutPoint funding_outpoint_conv;
25109         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
25110         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
25111         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
25112         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
25113         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
25114         return (uint64_t)ret_conv;
25115 }
25116
25117 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
25118         LDKClosingTransaction this_arg_conv;
25119         this_arg_conv.inner = (void*)(this_arg & (~1));
25120         this_arg_conv.is_owned = false;
25121         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
25122         return ret_val;
25123 }
25124
25125 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
25126         LDKClosingTransaction this_arg_conv;
25127         this_arg_conv.inner = (void*)(this_arg & (~1));
25128         this_arg_conv.is_owned = false;
25129         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
25130         return ret_val;
25131 }
25132
25133 int8_tArray  __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
25134         LDKClosingTransaction this_arg_conv;
25135         this_arg_conv.inner = (void*)(this_arg & (~1));
25136         this_arg_conv.is_owned = false;
25137         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
25138         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25139         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25140         return ret_arr;
25141 }
25142
25143 int8_tArray  __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
25144         LDKClosingTransaction this_arg_conv;
25145         this_arg_conv.inner = (void*)(this_arg & (~1));
25146         this_arg_conv.is_owned = false;
25147         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
25148         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25149         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25150         return ret_arr;
25151 }
25152
25153 void  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
25154         LDKTrustedClosingTransaction this_obj_conv;
25155         this_obj_conv.inner = (void*)(this_obj & (~1));
25156         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25157         TrustedClosingTransaction_free(this_obj_conv);
25158 }
25159
25160 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
25161         LDKTrustedClosingTransaction this_arg_conv;
25162         this_arg_conv.inner = (void*)(this_arg & (~1));
25163         this_arg_conv.is_owned = false;
25164         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
25165         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25166         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25167         Transaction_free(ret_var);
25168         return ret_arr;
25169 }
25170
25171 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
25172         LDKTrustedClosingTransaction this_arg_conv;
25173         this_arg_conv.inner = (void*)(this_arg & (~1));
25174         this_arg_conv.is_owned = false;
25175         LDKu8slice funding_redeemscript_ref;
25176         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
25177         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
25178         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25179         memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
25180         return ret_arr;
25181 }
25182
25183 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) {
25184         LDKTrustedClosingTransaction this_arg_conv;
25185         this_arg_conv.inner = (void*)(this_arg & (~1));
25186         this_arg_conv.is_owned = false;
25187         unsigned char funding_key_arr[32];
25188         CHECK(*((uint32_t*)funding_key) == 32);
25189         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
25190         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
25191         LDKu8slice funding_redeemscript_ref;
25192         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
25193         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
25194         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
25195         memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
25196         return ret_arr;
25197 }
25198
25199 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
25200         LDKCommitmentTransaction this_obj_conv;
25201         this_obj_conv.inner = (void*)(this_obj & (~1));
25202         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25203         CommitmentTransaction_free(this_obj_conv);
25204 }
25205
25206 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
25207         LDKCommitmentTransaction orig_conv;
25208         orig_conv.inner = (void*)(orig & (~1));
25209         orig_conv.is_owned = false;
25210         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
25211         uint64_t ret_ref = 0;
25212         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25213         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25214         ret_ref = (uint64_t)ret_var.inner;
25215         if (ret_var.is_owned) {
25216                 ret_ref |= 1;
25217         }
25218         return ret_ref;
25219 }
25220
25221 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
25222         LDKCommitmentTransaction obj_conv;
25223         obj_conv.inner = (void*)(obj & (~1));
25224         obj_conv.is_owned = false;
25225         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
25226         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25227         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25228         CVec_u8Z_free(ret_var);
25229         return ret_arr;
25230 }
25231
25232 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
25233         LDKu8slice ser_ref;
25234         ser_ref.datalen = *((uint32_t*)ser);
25235         ser_ref.data = (int8_t*)(ser + 4);
25236         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
25237         *ret_conv = CommitmentTransaction_read(ser_ref);
25238         return (uint64_t)ret_conv;
25239 }
25240
25241 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
25242         LDKCommitmentTransaction this_arg_conv;
25243         this_arg_conv.inner = (void*)(this_arg & (~1));
25244         this_arg_conv.is_owned = false;
25245         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
25246         return ret_val;
25247 }
25248
25249 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
25250         LDKCommitmentTransaction this_arg_conv;
25251         this_arg_conv.inner = (void*)(this_arg & (~1));
25252         this_arg_conv.is_owned = false;
25253         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
25254         return ret_val;
25255 }
25256
25257 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
25258         LDKCommitmentTransaction this_arg_conv;
25259         this_arg_conv.inner = (void*)(this_arg & (~1));
25260         this_arg_conv.is_owned = false;
25261         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
25262         return ret_val;
25263 }
25264
25265 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
25266         LDKCommitmentTransaction this_arg_conv;
25267         this_arg_conv.inner = (void*)(this_arg & (~1));
25268         this_arg_conv.is_owned = false;
25269         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
25270         return ret_val;
25271 }
25272
25273 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
25274         LDKCommitmentTransaction this_arg_conv;
25275         this_arg_conv.inner = (void*)(this_arg & (~1));
25276         this_arg_conv.is_owned = false;
25277         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
25278         uint64_t ret_ref = 0;
25279         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25280         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25281         ret_ref = (uint64_t)ret_var.inner;
25282         if (ret_var.is_owned) {
25283                 ret_ref |= 1;
25284         }
25285         return ret_ref;
25286 }
25287
25288 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
25289         LDKCommitmentTransaction this_arg_conv;
25290         this_arg_conv.inner = (void*)(this_arg & (~1));
25291         this_arg_conv.is_owned = false;
25292         LDKDirectedChannelTransactionParameters channel_parameters_conv;
25293         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
25294         channel_parameters_conv.is_owned = false;
25295         LDKChannelPublicKeys broadcaster_keys_conv;
25296         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
25297         broadcaster_keys_conv.is_owned = false;
25298         LDKChannelPublicKeys countersignatory_keys_conv;
25299         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
25300         countersignatory_keys_conv.is_owned = false;
25301         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
25302         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
25303         return (uint64_t)ret_conv;
25304 }
25305
25306 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
25307         LDKTrustedCommitmentTransaction this_obj_conv;
25308         this_obj_conv.inner = (void*)(this_obj & (~1));
25309         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25310         TrustedCommitmentTransaction_free(this_obj_conv);
25311 }
25312
25313 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
25314         LDKTrustedCommitmentTransaction this_arg_conv;
25315         this_arg_conv.inner = (void*)(this_arg & (~1));
25316         this_arg_conv.is_owned = false;
25317         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25318         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
25319         return ret_arr;
25320 }
25321
25322 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
25323         LDKTrustedCommitmentTransaction this_arg_conv;
25324         this_arg_conv.inner = (void*)(this_arg & (~1));
25325         this_arg_conv.is_owned = false;
25326         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
25327         uint64_t ret_ref = 0;
25328         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25329         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25330         ret_ref = (uint64_t)ret_var.inner;
25331         if (ret_var.is_owned) {
25332                 ret_ref |= 1;
25333         }
25334         return ret_ref;
25335 }
25336
25337 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
25338         LDKTrustedCommitmentTransaction this_arg_conv;
25339         this_arg_conv.inner = (void*)(this_arg & (~1));
25340         this_arg_conv.is_owned = false;
25341         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
25342         uint64_t ret_ref = 0;
25343         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25344         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25345         ret_ref = (uint64_t)ret_var.inner;
25346         if (ret_var.is_owned) {
25347                 ret_ref |= 1;
25348         }
25349         return ret_ref;
25350 }
25351
25352 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
25353         LDKTrustedCommitmentTransaction this_arg_conv;
25354         this_arg_conv.inner = (void*)(this_arg & (~1));
25355         this_arg_conv.is_owned = false;
25356         unsigned char htlc_base_key_arr[32];
25357         CHECK(*((uint32_t*)htlc_base_key) == 32);
25358         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
25359         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
25360         LDKDirectedChannelTransactionParameters channel_parameters_conv;
25361         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
25362         channel_parameters_conv.is_owned = false;
25363         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
25364         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
25365         return (uint64_t)ret_conv;
25366 }
25367
25368 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) {
25369         LDKPublicKey broadcaster_payment_basepoint_ref;
25370         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
25371         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
25372         LDKPublicKey countersignatory_payment_basepoint_ref;
25373         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
25374         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
25375         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
25376         return ret_val;
25377 }
25378
25379 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
25380         LDKInitFeatures a_conv;
25381         a_conv.inner = (void*)(a & (~1));
25382         a_conv.is_owned = false;
25383         LDKInitFeatures b_conv;
25384         b_conv.inner = (void*)(b & (~1));
25385         b_conv.is_owned = false;
25386         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
25387         return ret_val;
25388 }
25389
25390 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
25391         LDKNodeFeatures a_conv;
25392         a_conv.inner = (void*)(a & (~1));
25393         a_conv.is_owned = false;
25394         LDKNodeFeatures b_conv;
25395         b_conv.inner = (void*)(b & (~1));
25396         b_conv.is_owned = false;
25397         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
25398         return ret_val;
25399 }
25400
25401 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
25402         LDKChannelFeatures a_conv;
25403         a_conv.inner = (void*)(a & (~1));
25404         a_conv.is_owned = false;
25405         LDKChannelFeatures b_conv;
25406         b_conv.inner = (void*)(b & (~1));
25407         b_conv.is_owned = false;
25408         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
25409         return ret_val;
25410 }
25411
25412 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
25413         LDKInvoiceFeatures a_conv;
25414         a_conv.inner = (void*)(a & (~1));
25415         a_conv.is_owned = false;
25416         LDKInvoiceFeatures b_conv;
25417         b_conv.inner = (void*)(b & (~1));
25418         b_conv.is_owned = false;
25419         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
25420         return ret_val;
25421 }
25422
25423 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
25424         LDKInitFeatures orig_conv;
25425         orig_conv.inner = (void*)(orig & (~1));
25426         orig_conv.is_owned = false;
25427         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
25428         uint64_t ret_ref = 0;
25429         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25430         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25431         ret_ref = (uint64_t)ret_var.inner;
25432         if (ret_var.is_owned) {
25433                 ret_ref |= 1;
25434         }
25435         return ret_ref;
25436 }
25437
25438 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
25439         LDKNodeFeatures orig_conv;
25440         orig_conv.inner = (void*)(orig & (~1));
25441         orig_conv.is_owned = false;
25442         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
25443         uint64_t ret_ref = 0;
25444         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25445         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25446         ret_ref = (uint64_t)ret_var.inner;
25447         if (ret_var.is_owned) {
25448                 ret_ref |= 1;
25449         }
25450         return ret_ref;
25451 }
25452
25453 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
25454         LDKChannelFeatures orig_conv;
25455         orig_conv.inner = (void*)(orig & (~1));
25456         orig_conv.is_owned = false;
25457         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
25458         uint64_t ret_ref = 0;
25459         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25460         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25461         ret_ref = (uint64_t)ret_var.inner;
25462         if (ret_var.is_owned) {
25463                 ret_ref |= 1;
25464         }
25465         return ret_ref;
25466 }
25467
25468 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
25469         LDKInvoiceFeatures orig_conv;
25470         orig_conv.inner = (void*)(orig & (~1));
25471         orig_conv.is_owned = false;
25472         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
25473         uint64_t ret_ref = 0;
25474         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25475         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25476         ret_ref = (uint64_t)ret_var.inner;
25477         if (ret_var.is_owned) {
25478                 ret_ref |= 1;
25479         }
25480         return ret_ref;
25481 }
25482
25483 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
25484         LDKInitFeatures this_obj_conv;
25485         this_obj_conv.inner = (void*)(this_obj & (~1));
25486         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25487         InitFeatures_free(this_obj_conv);
25488 }
25489
25490 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
25491         LDKNodeFeatures this_obj_conv;
25492         this_obj_conv.inner = (void*)(this_obj & (~1));
25493         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25494         NodeFeatures_free(this_obj_conv);
25495 }
25496
25497 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
25498         LDKChannelFeatures this_obj_conv;
25499         this_obj_conv.inner = (void*)(this_obj & (~1));
25500         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25501         ChannelFeatures_free(this_obj_conv);
25502 }
25503
25504 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
25505         LDKInvoiceFeatures this_obj_conv;
25506         this_obj_conv.inner = (void*)(this_obj & (~1));
25507         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25508         InvoiceFeatures_free(this_obj_conv);
25509 }
25510
25511 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
25512         LDKInitFeatures ret_var = InitFeatures_empty();
25513         uint64_t ret_ref = 0;
25514         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25515         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25516         ret_ref = (uint64_t)ret_var.inner;
25517         if (ret_var.is_owned) {
25518                 ret_ref |= 1;
25519         }
25520         return ret_ref;
25521 }
25522
25523 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
25524         LDKInitFeatures ret_var = InitFeatures_known();
25525         uint64_t ret_ref = 0;
25526         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25527         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25528         ret_ref = (uint64_t)ret_var.inner;
25529         if (ret_var.is_owned) {
25530                 ret_ref |= 1;
25531         }
25532         return ret_ref;
25533 }
25534
25535 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
25536         LDKInitFeatures this_arg_conv;
25537         this_arg_conv.inner = (void*)(this_arg & (~1));
25538         this_arg_conv.is_owned = false;
25539         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
25540         return ret_val;
25541 }
25542
25543 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
25544         LDKNodeFeatures ret_var = NodeFeatures_empty();
25545         uint64_t ret_ref = 0;
25546         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25547         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25548         ret_ref = (uint64_t)ret_var.inner;
25549         if (ret_var.is_owned) {
25550                 ret_ref |= 1;
25551         }
25552         return ret_ref;
25553 }
25554
25555 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
25556         LDKNodeFeatures ret_var = NodeFeatures_known();
25557         uint64_t ret_ref = 0;
25558         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25559         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25560         ret_ref = (uint64_t)ret_var.inner;
25561         if (ret_var.is_owned) {
25562                 ret_ref |= 1;
25563         }
25564         return ret_ref;
25565 }
25566
25567 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
25568         LDKNodeFeatures this_arg_conv;
25569         this_arg_conv.inner = (void*)(this_arg & (~1));
25570         this_arg_conv.is_owned = false;
25571         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
25572         return ret_val;
25573 }
25574
25575 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
25576         LDKChannelFeatures ret_var = ChannelFeatures_empty();
25577         uint64_t ret_ref = 0;
25578         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25579         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25580         ret_ref = (uint64_t)ret_var.inner;
25581         if (ret_var.is_owned) {
25582                 ret_ref |= 1;
25583         }
25584         return ret_ref;
25585 }
25586
25587 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
25588         LDKChannelFeatures ret_var = ChannelFeatures_known();
25589         uint64_t ret_ref = 0;
25590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25592         ret_ref = (uint64_t)ret_var.inner;
25593         if (ret_var.is_owned) {
25594                 ret_ref |= 1;
25595         }
25596         return ret_ref;
25597 }
25598
25599 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
25600         LDKChannelFeatures this_arg_conv;
25601         this_arg_conv.inner = (void*)(this_arg & (~1));
25602         this_arg_conv.is_owned = false;
25603         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
25604         return ret_val;
25605 }
25606
25607 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
25608         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
25609         uint64_t ret_ref = 0;
25610         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25611         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25612         ret_ref = (uint64_t)ret_var.inner;
25613         if (ret_var.is_owned) {
25614                 ret_ref |= 1;
25615         }
25616         return ret_ref;
25617 }
25618
25619 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
25620         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
25621         uint64_t ret_ref = 0;
25622         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25623         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25624         ret_ref = (uint64_t)ret_var.inner;
25625         if (ret_var.is_owned) {
25626                 ret_ref |= 1;
25627         }
25628         return ret_ref;
25629 }
25630
25631 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
25632         LDKInvoiceFeatures this_arg_conv;
25633         this_arg_conv.inner = (void*)(this_arg & (~1));
25634         this_arg_conv.is_owned = false;
25635         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
25636         return ret_val;
25637 }
25638
25639 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
25640         LDKInitFeatures this_arg_conv;
25641         this_arg_conv.inner = (void*)(this_arg & (~1));
25642         this_arg_conv.is_owned = false;
25643         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
25644         return ret_val;
25645 }
25646
25647 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
25648         LDKNodeFeatures this_arg_conv;
25649         this_arg_conv.inner = (void*)(this_arg & (~1));
25650         this_arg_conv.is_owned = false;
25651         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
25652         return ret_val;
25653 }
25654
25655 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
25656         LDKInvoiceFeatures this_arg_conv;
25657         this_arg_conv.inner = (void*)(this_arg & (~1));
25658         this_arg_conv.is_owned = false;
25659         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
25660         return ret_val;
25661 }
25662
25663 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
25664         LDKInitFeatures obj_conv;
25665         obj_conv.inner = (void*)(obj & (~1));
25666         obj_conv.is_owned = false;
25667         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
25668         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25669         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25670         CVec_u8Z_free(ret_var);
25671         return ret_arr;
25672 }
25673
25674 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
25675         LDKNodeFeatures obj_conv;
25676         obj_conv.inner = (void*)(obj & (~1));
25677         obj_conv.is_owned = false;
25678         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
25679         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25680         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25681         CVec_u8Z_free(ret_var);
25682         return ret_arr;
25683 }
25684
25685 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
25686         LDKChannelFeatures obj_conv;
25687         obj_conv.inner = (void*)(obj & (~1));
25688         obj_conv.is_owned = false;
25689         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
25690         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25691         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25692         CVec_u8Z_free(ret_var);
25693         return ret_arr;
25694 }
25695
25696 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
25697         LDKInvoiceFeatures obj_conv;
25698         obj_conv.inner = (void*)(obj & (~1));
25699         obj_conv.is_owned = false;
25700         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
25701         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25702         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25703         CVec_u8Z_free(ret_var);
25704         return ret_arr;
25705 }
25706
25707 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
25708         LDKu8slice ser_ref;
25709         ser_ref.datalen = *((uint32_t*)ser);
25710         ser_ref.data = (int8_t*)(ser + 4);
25711         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
25712         *ret_conv = InitFeatures_read(ser_ref);
25713         return (uint64_t)ret_conv;
25714 }
25715
25716 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
25717         LDKu8slice ser_ref;
25718         ser_ref.datalen = *((uint32_t*)ser);
25719         ser_ref.data = (int8_t*)(ser + 4);
25720         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
25721         *ret_conv = NodeFeatures_read(ser_ref);
25722         return (uint64_t)ret_conv;
25723 }
25724
25725 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
25726         LDKu8slice ser_ref;
25727         ser_ref.datalen = *((uint32_t*)ser);
25728         ser_ref.data = (int8_t*)(ser + 4);
25729         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
25730         *ret_conv = ChannelFeatures_read(ser_ref);
25731         return (uint64_t)ret_conv;
25732 }
25733
25734 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
25735         LDKu8slice ser_ref;
25736         ser_ref.datalen = *((uint32_t*)ser);
25737         ser_ref.data = (int8_t*)(ser + 4);
25738         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
25739         *ret_conv = InvoiceFeatures_read(ser_ref);
25740         return (uint64_t)ret_conv;
25741 }
25742
25743 void  __attribute__((visibility("default"))) TS_ShutdownScript_free(uint32_t this_obj) {
25744         LDKShutdownScript this_obj_conv;
25745         this_obj_conv.inner = (void*)(this_obj & (~1));
25746         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25747         ShutdownScript_free(this_obj_conv);
25748 }
25749
25750 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_clone(uint32_t orig) {
25751         LDKShutdownScript orig_conv;
25752         orig_conv.inner = (void*)(orig & (~1));
25753         orig_conv.is_owned = false;
25754         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
25755         uint64_t ret_ref = 0;
25756         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25757         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25758         ret_ref = (uint64_t)ret_var.inner;
25759         if (ret_var.is_owned) {
25760                 ret_ref |= 1;
25761         }
25762         return ret_ref;
25763 }
25764
25765 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
25766         LDKInvalidShutdownScript this_obj_conv;
25767         this_obj_conv.inner = (void*)(this_obj & (~1));
25768         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25769         InvalidShutdownScript_free(this_obj_conv);
25770 }
25771
25772 int8_tArray  __attribute__((visibility("default"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
25773         LDKInvalidShutdownScript this_ptr_conv;
25774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25775         this_ptr_conv.is_owned = false;
25776         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
25777         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25778         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25779         return ret_arr;
25780 }
25781
25782 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
25783         LDKInvalidShutdownScript this_ptr_conv;
25784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25785         this_ptr_conv.is_owned = false;
25786         LDKCVec_u8Z val_ref;
25787         val_ref.datalen = *((uint32_t*)val);
25788         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
25789         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
25790         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
25791 }
25792
25793 uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
25794         LDKCVec_u8Z script_arg_ref;
25795         script_arg_ref.datalen = *((uint32_t*)script_arg);
25796         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
25797         memcpy(script_arg_ref.data, (uint8_t*)(script_arg + 4), script_arg_ref.datalen);
25798         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
25799         uint64_t ret_ref = 0;
25800         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25801         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25802         ret_ref = (uint64_t)ret_var.inner;
25803         if (ret_var.is_owned) {
25804                 ret_ref |= 1;
25805         }
25806         return ret_ref;
25807 }
25808
25809 uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
25810         LDKInvalidShutdownScript orig_conv;
25811         orig_conv.inner = (void*)(orig & (~1));
25812         orig_conv.is_owned = false;
25813         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
25814         uint64_t ret_ref = 0;
25815         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25816         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25817         ret_ref = (uint64_t)ret_var.inner;
25818         if (ret_var.is_owned) {
25819                 ret_ref |= 1;
25820         }
25821         return ret_ref;
25822 }
25823
25824 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_write(uint32_t obj) {
25825         LDKShutdownScript obj_conv;
25826         obj_conv.inner = (void*)(obj & (~1));
25827         obj_conv.is_owned = false;
25828         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
25829         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25830         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25831         CVec_u8Z_free(ret_var);
25832         return ret_arr;
25833 }
25834
25835 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_read(int8_tArray ser) {
25836         LDKu8slice ser_ref;
25837         ser_ref.datalen = *((uint32_t*)ser);
25838         ser_ref.data = (int8_t*)(ser + 4);
25839         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
25840         *ret_conv = ShutdownScript_read(ser_ref);
25841         return (uint64_t)ret_conv;
25842 }
25843
25844 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
25845         unsigned char pubkey_hash_arr[20];
25846         CHECK(*((uint32_t*)pubkey_hash) == 20);
25847         memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20);
25848         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
25849         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
25850         uint64_t ret_ref = 0;
25851         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25852         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25853         ret_ref = (uint64_t)ret_var.inner;
25854         if (ret_var.is_owned) {
25855                 ret_ref |= 1;
25856         }
25857         return ret_ref;
25858 }
25859
25860 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
25861         unsigned char script_hash_arr[32];
25862         CHECK(*((uint32_t*)script_hash) == 32);
25863         memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 32);
25864         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
25865         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
25866         uint64_t ret_ref = 0;
25867         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25868         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25869         ret_ref = (uint64_t)ret_var.inner;
25870         if (ret_var.is_owned) {
25871                 ret_ref |= 1;
25872         }
25873         return ret_ref;
25874 }
25875
25876 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
25877         LDKu8slice program_ref;
25878         program_ref.datalen = *((uint32_t*)program);
25879         program_ref.data = (int8_t*)(program + 4);
25880         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
25881         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
25882         return (uint64_t)ret_conv;
25883 }
25884
25885 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
25886         LDKShutdownScript this_arg_conv;
25887         this_arg_conv.inner = (void*)(this_arg & (~1));
25888         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25889         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
25890         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
25891         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25892         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25893         CVec_u8Z_free(ret_var);
25894         return ret_arr;
25895 }
25896
25897 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
25898         LDKShutdownScript 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(33, sizeof(uint8_t), "Native int8_tArray Bytes");
25902         memcpy((uint8_t*)(ret_arr + 4), ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
25903         return ret_arr;
25904 }
25905
25906 jboolean  __attribute__((visibility("default"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
25907         LDKShutdownScript this_arg_conv;
25908         this_arg_conv.inner = (void*)(this_arg & (~1));
25909         this_arg_conv.is_owned = false;
25910         LDKInitFeatures features_conv;
25911         features_conv.inner = (void*)(features & (~1));
25912         features_conv.is_owned = false;
25913         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
25914         return ret_val;
25915 }
25916
25917 void  __attribute__((visibility("default"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
25918         if ((this_ptr & 1) != 0) return;
25919         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
25920         CHECK_ACCESS(this_ptr_ptr);
25921         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
25922         FREE((void*)this_ptr);
25923         CustomMessageReader_free(this_ptr_conv);
25924 }
25925
25926 uint32_t  __attribute__((visibility("default"))) TS_Type_clone(uint32_t orig) {
25927         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
25928         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
25929         LDKType* orig_conv = (LDKType*)orig_ptr;
25930         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
25931         *ret_ret = Type_clone(orig_conv);
25932         return (uint64_t)ret_ret;
25933 }
25934
25935 void  __attribute__((visibility("default"))) TS_Type_free(uint32_t this_ptr) {
25936         if ((this_ptr & 1) != 0) return;
25937         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
25938         CHECK_ACCESS(this_ptr_ptr);
25939         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
25940         FREE((void*)this_ptr);
25941         Type_free(this_ptr_conv);
25942 }
25943
25944 void  __attribute__((visibility("default"))) TS_Score_free(uint32_t this_ptr) {
25945         if ((this_ptr & 1) != 0) return;
25946         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
25947         CHECK_ACCESS(this_ptr_ptr);
25948         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
25949         FREE((void*)this_ptr);
25950         Score_free(this_ptr_conv);
25951 }
25952
25953 void  __attribute__((visibility("default"))) TS_LockableScore_free(uint32_t this_obj) {
25954         LDKLockableScore this_obj_conv;
25955         this_obj_conv.inner = (void*)(this_obj & (~1));
25956         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25957         LockableScore_free(this_obj_conv);
25958 }
25959
25960 uint32_t  __attribute__((visibility("default"))) TS_LockableScore_new(uint32_t score) {
25961         void* score_ptr = (void*)(((uint64_t)score) & ~1);
25962         CHECK_ACCESS(score_ptr);
25963         LDKScore score_conv = *(LDKScore*)(score_ptr);
25964         LDKLockableScore ret_var = LockableScore_new(score_conv);
25965         uint64_t ret_ref = 0;
25966         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25967         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25968         ret_ref = (uint64_t)ret_var.inner;
25969         if (ret_var.is_owned) {
25970                 ret_ref |= 1;
25971         }
25972         return ret_ref;
25973 }
25974
25975 int8_tArray  __attribute__((visibility("default"))) TS_LockableScore_write(uint32_t obj) {
25976         LDKLockableScore obj_conv;
25977         obj_conv.inner = (void*)(obj & (~1));
25978         obj_conv.is_owned = false;
25979         LDKCVec_u8Z ret_var = LockableScore_write(&obj_conv);
25980         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25981         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25982         CVec_u8Z_free(ret_var);
25983         return ret_arr;
25984 }
25985
25986 void  __attribute__((visibility("default"))) TS_NodeId_free(uint32_t this_obj) {
25987         LDKNodeId this_obj_conv;
25988         this_obj_conv.inner = (void*)(this_obj & (~1));
25989         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25990         NodeId_free(this_obj_conv);
25991 }
25992
25993 uint32_t  __attribute__((visibility("default"))) TS_NodeId_clone(uint32_t orig) {
25994         LDKNodeId orig_conv;
25995         orig_conv.inner = (void*)(orig & (~1));
25996         orig_conv.is_owned = false;
25997         LDKNodeId ret_var = NodeId_clone(&orig_conv);
25998         uint64_t ret_ref = 0;
25999         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26000         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26001         ret_ref = (uint64_t)ret_var.inner;
26002         if (ret_var.is_owned) {
26003                 ret_ref |= 1;
26004         }
26005         return ret_ref;
26006 }
26007
26008 uint32_t  __attribute__((visibility("default"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
26009         LDKPublicKey pubkey_ref;
26010         CHECK(*((uint32_t*)pubkey) == 33);
26011         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
26012         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
26013         uint64_t ret_ref = 0;
26014         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26015         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26016         ret_ref = (uint64_t)ret_var.inner;
26017         if (ret_var.is_owned) {
26018                 ret_ref |= 1;
26019         }
26020         return ret_ref;
26021 }
26022
26023 int8_tArray  __attribute__((visibility("default"))) TS_NodeId_as_slice(uint32_t this_arg) {
26024         LDKNodeId this_arg_conv;
26025         this_arg_conv.inner = (void*)(this_arg & (~1));
26026         this_arg_conv.is_owned = false;
26027         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
26028         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
26029         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
26030         return ret_arr;
26031 }
26032
26033 int64_t  __attribute__((visibility("default"))) TS_NodeId_hash(uint32_t o) {
26034         LDKNodeId o_conv;
26035         o_conv.inner = (void*)(o & (~1));
26036         o_conv.is_owned = false;
26037         int64_t ret_val = NodeId_hash(&o_conv);
26038         return ret_val;
26039 }
26040
26041 int8_tArray  __attribute__((visibility("default"))) TS_NodeId_write(uint32_t obj) {
26042         LDKNodeId obj_conv;
26043         obj_conv.inner = (void*)(obj & (~1));
26044         obj_conv.is_owned = false;
26045         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
26046         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
26047         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
26048         CVec_u8Z_free(ret_var);
26049         return ret_arr;
26050 }
26051
26052 uint32_t  __attribute__((visibility("default"))) TS_NodeId_read(int8_tArray ser) {
26053         LDKu8slice ser_ref;
26054         ser_ref.datalen = *((uint32_t*)ser);
26055         ser_ref.data = (int8_t*)(ser + 4);
26056         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
26057         *ret_conv = NodeId_read(ser_ref);
26058         return (uint64_t)ret_conv;
26059 }
26060
26061 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
26062         LDKNetworkGraph this_obj_conv;
26063         this_obj_conv.inner = (void*)(this_obj & (~1));
26064         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26065         NetworkGraph_free(this_obj_conv);
26066 }
26067
26068 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
26069         LDKNetworkGraph orig_conv;
26070         orig_conv.inner = (void*)(orig & (~1));
26071         orig_conv.is_owned = false;
26072         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
26073         uint64_t ret_ref = 0;
26074         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26075         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26076         ret_ref = (uint64_t)ret_var.inner;
26077         if (ret_var.is_owned) {
26078                 ret_ref |= 1;
26079         }
26080         return ret_ref;
26081 }
26082
26083 void  __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
26084         LDKReadOnlyNetworkGraph this_obj_conv;
26085         this_obj_conv.inner = (void*)(this_obj & (~1));
26086         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26087         ReadOnlyNetworkGraph_free(this_obj_conv);
26088 }
26089
26090 void  __attribute__((visibility("default"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
26091         if ((this_ptr & 1) != 0) return;
26092         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
26093         CHECK_ACCESS(this_ptr_ptr);
26094         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
26095         FREE((void*)this_ptr);
26096         NetworkUpdate_free(this_ptr_conv);
26097 }
26098
26099 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_clone(uint32_t orig) {
26100         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
26101         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
26102         *ret_copy = NetworkUpdate_clone(orig_conv);
26103         uint64_t ret_ref = (uint64_t)ret_copy;
26104         return ret_ref;
26105 }
26106
26107 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
26108         LDKChannelUpdate msg_conv;
26109         msg_conv.inner = (void*)(msg & (~1));
26110         msg_conv.is_owned = (msg & 1) || (msg == 0);
26111         msg_conv = ChannelUpdate_clone(&msg_conv);
26112         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
26113         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
26114         uint64_t ret_ref = (uint64_t)ret_copy;
26115         return ret_ref;
26116 }
26117
26118 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
26119         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
26120         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
26121         uint64_t ret_ref = (uint64_t)ret_copy;
26122         return ret_ref;
26123 }
26124
26125 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
26126         LDKPublicKey node_id_ref;
26127         CHECK(*((uint32_t*)node_id) == 33);
26128         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
26129         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
26130         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
26131         uint64_t ret_ref = (uint64_t)ret_copy;
26132         return ret_ref;
26133 }
26134
26135 int8_tArray  __attribute__((visibility("default"))) TS_NetworkUpdate_write(uint32_t obj) {
26136         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
26137         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
26138         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
26139         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
26140         CVec_u8Z_free(ret_var);
26141         return ret_arr;
26142 }
26143
26144 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
26145         LDKNetGraphMsgHandler this_arg_conv;
26146         this_arg_conv.inner = (void*)(this_arg & (~1));
26147         this_arg_conv.is_owned = false;
26148         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
26149         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
26150         return (uint64_t)ret_ret;
26151 }
26152
26153 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
26154         LDKNetGraphMsgHandler this_obj_conv;
26155         this_obj_conv.inner = (void*)(this_obj & (~1));
26156         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26157         NetGraphMsgHandler_free(this_obj_conv);
26158 }
26159
26160 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
26161         LDKNetworkGraph network_graph_conv;
26162         network_graph_conv.inner = (void*)(network_graph & (~1));
26163         network_graph_conv.is_owned = false;
26164         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
26165         CHECK_ACCESS(chain_access_ptr);
26166         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
26167         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
26168         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
26169                 // Manually implement clone for Java trait instances
26170         }
26171         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
26172         CHECK_ACCESS(logger_ptr);
26173         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26174         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
26175         uint64_t ret_ref = 0;
26176         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26177         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26178         ret_ref = (uint64_t)ret_var.inner;
26179         if (ret_var.is_owned) {
26180                 ret_ref |= 1;
26181         }
26182         return ret_ref;
26183 }
26184
26185 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
26186         LDKNetGraphMsgHandler this_arg_conv;
26187         this_arg_conv.inner = (void*)(this_arg & (~1));
26188         this_arg_conv.is_owned = false;
26189         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
26190         CHECK_ACCESS(chain_access_ptr);
26191         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
26192         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
26193         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
26194                 // Manually implement clone for Java trait instances
26195         }
26196         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
26197 }
26198
26199 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
26200         LDKNetGraphMsgHandler this_arg_conv;
26201         this_arg_conv.inner = (void*)(this_arg & (~1));
26202         this_arg_conv.is_owned = false;
26203         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
26204         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
26205         return (uint64_t)ret_ret;
26206 }
26207
26208 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
26209         LDKNetGraphMsgHandler this_arg_conv;
26210         this_arg_conv.inner = (void*)(this_arg & (~1));
26211         this_arg_conv.is_owned = false;
26212         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
26213         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
26214         return (uint64_t)ret_ret;
26215 }
26216
26217 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
26218         LDKDirectionalChannelInfo this_obj_conv;
26219         this_obj_conv.inner = (void*)(this_obj & (~1));
26220         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26221         DirectionalChannelInfo_free(this_obj_conv);
26222 }
26223
26224 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
26225         LDKDirectionalChannelInfo this_ptr_conv;
26226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26227         this_ptr_conv.is_owned = false;
26228         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
26229         return ret_val;
26230 }
26231
26232 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
26233         LDKDirectionalChannelInfo this_ptr_conv;
26234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26235         this_ptr_conv.is_owned = false;
26236         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
26237 }
26238
26239 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
26240         LDKDirectionalChannelInfo this_ptr_conv;
26241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26242         this_ptr_conv.is_owned = false;
26243         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
26244         return ret_val;
26245 }
26246
26247 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
26248         LDKDirectionalChannelInfo this_ptr_conv;
26249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26250         this_ptr_conv.is_owned = false;
26251         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
26252 }
26253
26254 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
26255         LDKDirectionalChannelInfo this_ptr_conv;
26256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26257         this_ptr_conv.is_owned = false;
26258         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
26259         return ret_val;
26260 }
26261
26262 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
26263         LDKDirectionalChannelInfo this_ptr_conv;
26264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26265         this_ptr_conv.is_owned = false;
26266         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
26267 }
26268
26269 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
26270         LDKDirectionalChannelInfo this_ptr_conv;
26271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26272         this_ptr_conv.is_owned = false;
26273         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
26274         return ret_val;
26275 }
26276
26277 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26278         LDKDirectionalChannelInfo this_ptr_conv;
26279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26280         this_ptr_conv.is_owned = false;
26281         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
26282 }
26283
26284 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
26285         LDKDirectionalChannelInfo this_ptr_conv;
26286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26287         this_ptr_conv.is_owned = false;
26288         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26289         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
26290         uint64_t ret_ref = (uint64_t)ret_copy;
26291         return ret_ref;
26292 }
26293
26294 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
26295         LDKDirectionalChannelInfo this_ptr_conv;
26296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26297         this_ptr_conv.is_owned = false;
26298         void* val_ptr = (void*)(((uint64_t)val) & ~1);
26299         CHECK_ACCESS(val_ptr);
26300         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26301         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
26302         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
26303 }
26304
26305 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
26306         LDKDirectionalChannelInfo this_ptr_conv;
26307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26308         this_ptr_conv.is_owned = false;
26309         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
26310         uint64_t ret_ref = 0;
26311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26313         ret_ref = (uint64_t)ret_var.inner;
26314         if (ret_var.is_owned) {
26315                 ret_ref |= 1;
26316         }
26317         return ret_ref;
26318 }
26319
26320 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
26321         LDKDirectionalChannelInfo this_ptr_conv;
26322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26323         this_ptr_conv.is_owned = false;
26324         LDKRoutingFees val_conv;
26325         val_conv.inner = (void*)(val & (~1));
26326         val_conv.is_owned = (val & 1) || (val == 0);
26327         val_conv = RoutingFees_clone(&val_conv);
26328         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
26329 }
26330
26331 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
26332         LDKDirectionalChannelInfo this_ptr_conv;
26333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26334         this_ptr_conv.is_owned = false;
26335         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
26336         uint64_t ret_ref = 0;
26337         if ((uint64_t)ret_var.inner > 4096) {
26338                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26339                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26340                 ret_ref = (uint64_t)ret_var.inner;
26341                 if (ret_var.is_owned) {
26342                         ret_ref |= 1;
26343                 }
26344         }
26345         return ret_ref;
26346 }
26347
26348 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
26349         LDKDirectionalChannelInfo this_ptr_conv;
26350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26351         this_ptr_conv.is_owned = false;
26352         LDKChannelUpdate val_conv;
26353         val_conv.inner = (void*)(val & (~1));
26354         val_conv.is_owned = (val & 1) || (val == 0);
26355         val_conv = ChannelUpdate_clone(&val_conv);
26356         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
26357 }
26358
26359 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) {
26360         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
26361         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
26362         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
26363         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
26364         LDKRoutingFees fees_arg_conv;
26365         fees_arg_conv.inner = (void*)(fees_arg & (~1));
26366         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
26367         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
26368         LDKChannelUpdate last_update_message_arg_conv;
26369         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
26370         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
26371         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
26372         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);
26373         uint64_t ret_ref = 0;
26374         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26375         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26376         ret_ref = (uint64_t)ret_var.inner;
26377         if (ret_var.is_owned) {
26378                 ret_ref |= 1;
26379         }
26380         return ret_ref;
26381 }
26382
26383 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
26384         LDKDirectionalChannelInfo orig_conv;
26385         orig_conv.inner = (void*)(orig & (~1));
26386         orig_conv.is_owned = false;
26387         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
26388         uint64_t ret_ref = 0;
26389         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26390         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26391         ret_ref = (uint64_t)ret_var.inner;
26392         if (ret_var.is_owned) {
26393                 ret_ref |= 1;
26394         }
26395         return ret_ref;
26396 }
26397
26398 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
26399         LDKDirectionalChannelInfo obj_conv;
26400         obj_conv.inner = (void*)(obj & (~1));
26401         obj_conv.is_owned = false;
26402         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
26403         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
26404         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
26405         CVec_u8Z_free(ret_var);
26406         return ret_arr;
26407 }
26408
26409 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
26410         LDKu8slice ser_ref;
26411         ser_ref.datalen = *((uint32_t*)ser);
26412         ser_ref.data = (int8_t*)(ser + 4);
26413         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
26414         *ret_conv = DirectionalChannelInfo_read(ser_ref);
26415         return (uint64_t)ret_conv;
26416 }
26417
26418 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
26419         LDKChannelInfo this_obj_conv;
26420         this_obj_conv.inner = (void*)(this_obj & (~1));
26421         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26422         ChannelInfo_free(this_obj_conv);
26423 }
26424
26425 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
26426         LDKChannelInfo this_ptr_conv;
26427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26428         this_ptr_conv.is_owned = false;
26429         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
26430         uint64_t ret_ref = 0;
26431         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26432         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26433         ret_ref = (uint64_t)ret_var.inner;
26434         if (ret_var.is_owned) {
26435                 ret_ref |= 1;
26436         }
26437         return ret_ref;
26438 }
26439
26440 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
26441         LDKChannelInfo this_ptr_conv;
26442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26443         this_ptr_conv.is_owned = false;
26444         LDKChannelFeatures val_conv;
26445         val_conv.inner = (void*)(val & (~1));
26446         val_conv.is_owned = (val & 1) || (val == 0);
26447         val_conv = ChannelFeatures_clone(&val_conv);
26448         ChannelInfo_set_features(&this_ptr_conv, val_conv);
26449 }
26450
26451 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
26452         LDKChannelInfo this_ptr_conv;
26453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26454         this_ptr_conv.is_owned = false;
26455         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
26456         uint64_t ret_ref = 0;
26457         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26458         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26459         ret_ref = (uint64_t)ret_var.inner;
26460         if (ret_var.is_owned) {
26461                 ret_ref |= 1;
26462         }
26463         return ret_ref;
26464 }
26465
26466 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
26467         LDKChannelInfo this_ptr_conv;
26468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26469         this_ptr_conv.is_owned = false;
26470         LDKNodeId val_conv;
26471         val_conv.inner = (void*)(val & (~1));
26472         val_conv.is_owned = (val & 1) || (val == 0);
26473         val_conv = NodeId_clone(&val_conv);
26474         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
26475 }
26476
26477 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
26478         LDKChannelInfo this_ptr_conv;
26479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26480         this_ptr_conv.is_owned = false;
26481         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
26482         uint64_t ret_ref = 0;
26483         if ((uint64_t)ret_var.inner > 4096) {
26484                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26485                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26486                 ret_ref = (uint64_t)ret_var.inner;
26487                 if (ret_var.is_owned) {
26488                         ret_ref |= 1;
26489                 }
26490         }
26491         return ret_ref;
26492 }
26493
26494 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
26495         LDKChannelInfo this_ptr_conv;
26496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26497         this_ptr_conv.is_owned = false;
26498         LDKDirectionalChannelInfo val_conv;
26499         val_conv.inner = (void*)(val & (~1));
26500         val_conv.is_owned = (val & 1) || (val == 0);
26501         val_conv = DirectionalChannelInfo_clone(&val_conv);
26502         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
26503 }
26504
26505 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
26506         LDKChannelInfo this_ptr_conv;
26507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26508         this_ptr_conv.is_owned = false;
26509         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
26510         uint64_t ret_ref = 0;
26511         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26512         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26513         ret_ref = (uint64_t)ret_var.inner;
26514         if (ret_var.is_owned) {
26515                 ret_ref |= 1;
26516         }
26517         return ret_ref;
26518 }
26519
26520 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
26521         LDKChannelInfo this_ptr_conv;
26522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26523         this_ptr_conv.is_owned = false;
26524         LDKNodeId val_conv;
26525         val_conv.inner = (void*)(val & (~1));
26526         val_conv.is_owned = (val & 1) || (val == 0);
26527         val_conv = NodeId_clone(&val_conv);
26528         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
26529 }
26530
26531 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
26532         LDKChannelInfo this_ptr_conv;
26533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26534         this_ptr_conv.is_owned = false;
26535         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
26536         uint64_t ret_ref = 0;
26537         if ((uint64_t)ret_var.inner > 4096) {
26538                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26539                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26540                 ret_ref = (uint64_t)ret_var.inner;
26541                 if (ret_var.is_owned) {
26542                         ret_ref |= 1;
26543                 }
26544         }
26545         return ret_ref;
26546 }
26547
26548 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
26549         LDKChannelInfo this_ptr_conv;
26550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26551         this_ptr_conv.is_owned = false;
26552         LDKDirectionalChannelInfo val_conv;
26553         val_conv.inner = (void*)(val & (~1));
26554         val_conv.is_owned = (val & 1) || (val == 0);
26555         val_conv = DirectionalChannelInfo_clone(&val_conv);
26556         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
26557 }
26558
26559 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
26560         LDKChannelInfo this_ptr_conv;
26561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26562         this_ptr_conv.is_owned = false;
26563         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26564         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
26565         uint64_t ret_ref = (uint64_t)ret_copy;
26566         return ret_ref;
26567 }
26568
26569 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
26570         LDKChannelInfo this_ptr_conv;
26571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26572         this_ptr_conv.is_owned = false;
26573         void* val_ptr = (void*)(((uint64_t)val) & ~1);
26574         CHECK_ACCESS(val_ptr);
26575         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26576         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
26577         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
26578 }
26579
26580 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
26581         LDKChannelInfo this_ptr_conv;
26582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26583         this_ptr_conv.is_owned = false;
26584         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
26585         uint64_t ret_ref = 0;
26586         if ((uint64_t)ret_var.inner > 4096) {
26587                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26588                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26589                 ret_ref = (uint64_t)ret_var.inner;
26590                 if (ret_var.is_owned) {
26591                         ret_ref |= 1;
26592                 }
26593         }
26594         return ret_ref;
26595 }
26596
26597 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
26598         LDKChannelInfo this_ptr_conv;
26599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26600         this_ptr_conv.is_owned = false;
26601         LDKChannelAnnouncement val_conv;
26602         val_conv.inner = (void*)(val & (~1));
26603         val_conv.is_owned = (val & 1) || (val == 0);
26604         val_conv = ChannelAnnouncement_clone(&val_conv);
26605         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
26606 }
26607
26608 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_new(uint32_t features_arg, uint32_t node_one_arg, uint32_t one_to_two_arg, uint32_t node_two_arg, uint32_t two_to_one_arg, uint32_t capacity_sats_arg, uint32_t announcement_message_arg) {
26609         LDKChannelFeatures features_arg_conv;
26610         features_arg_conv.inner = (void*)(features_arg & (~1));
26611         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26612         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
26613         LDKNodeId node_one_arg_conv;
26614         node_one_arg_conv.inner = (void*)(node_one_arg & (~1));
26615         node_one_arg_conv.is_owned = (node_one_arg & 1) || (node_one_arg == 0);
26616         node_one_arg_conv = NodeId_clone(&node_one_arg_conv);
26617         LDKDirectionalChannelInfo one_to_two_arg_conv;
26618         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
26619         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
26620         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
26621         LDKNodeId node_two_arg_conv;
26622         node_two_arg_conv.inner = (void*)(node_two_arg & (~1));
26623         node_two_arg_conv.is_owned = (node_two_arg & 1) || (node_two_arg == 0);
26624         node_two_arg_conv = NodeId_clone(&node_two_arg_conv);
26625         LDKDirectionalChannelInfo two_to_one_arg_conv;
26626         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
26627         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
26628         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
26629         void* capacity_sats_arg_ptr = (void*)(((uint64_t)capacity_sats_arg) & ~1);
26630         CHECK_ACCESS(capacity_sats_arg_ptr);
26631         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(capacity_sats_arg_ptr);
26632         capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1));
26633         LDKChannelAnnouncement announcement_message_arg_conv;
26634         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
26635         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
26636         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
26637         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_conv, one_to_two_arg_conv, node_two_arg_conv, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
26638         uint64_t ret_ref = 0;
26639         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26640         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26641         ret_ref = (uint64_t)ret_var.inner;
26642         if (ret_var.is_owned) {
26643                 ret_ref |= 1;
26644         }
26645         return ret_ref;
26646 }
26647
26648 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
26649         LDKChannelInfo orig_conv;
26650         orig_conv.inner = (void*)(orig & (~1));
26651         orig_conv.is_owned = false;
26652         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
26653         uint64_t ret_ref = 0;
26654         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26655         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26656         ret_ref = (uint64_t)ret_var.inner;
26657         if (ret_var.is_owned) {
26658                 ret_ref |= 1;
26659         }
26660         return ret_ref;
26661 }
26662
26663 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
26664         LDKChannelInfo obj_conv;
26665         obj_conv.inner = (void*)(obj & (~1));
26666         obj_conv.is_owned = false;
26667         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
26668         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
26669         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
26670         CVec_u8Z_free(ret_var);
26671         return ret_arr;
26672 }
26673
26674 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
26675         LDKu8slice ser_ref;
26676         ser_ref.datalen = *((uint32_t*)ser);
26677         ser_ref.data = (int8_t*)(ser + 4);
26678         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
26679         *ret_conv = ChannelInfo_read(ser_ref);
26680         return (uint64_t)ret_conv;
26681 }
26682
26683 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
26684         LDKRoutingFees this_obj_conv;
26685         this_obj_conv.inner = (void*)(this_obj & (~1));
26686         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26687         RoutingFees_free(this_obj_conv);
26688 }
26689
26690 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
26691         LDKRoutingFees this_ptr_conv;
26692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26693         this_ptr_conv.is_owned = false;
26694         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
26695         return ret_val;
26696 }
26697
26698 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
26699         LDKRoutingFees this_ptr_conv;
26700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26701         this_ptr_conv.is_owned = false;
26702         RoutingFees_set_base_msat(&this_ptr_conv, val);
26703 }
26704
26705 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
26706         LDKRoutingFees this_ptr_conv;
26707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26708         this_ptr_conv.is_owned = false;
26709         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
26710         return ret_val;
26711 }
26712
26713 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
26714         LDKRoutingFees this_ptr_conv;
26715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26716         this_ptr_conv.is_owned = false;
26717         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
26718 }
26719
26720 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
26721         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
26722         uint64_t ret_ref = 0;
26723         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26724         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26725         ret_ref = (uint64_t)ret_var.inner;
26726         if (ret_var.is_owned) {
26727                 ret_ref |= 1;
26728         }
26729         return ret_ref;
26730 }
26731
26732 jboolean  __attribute__((visibility("default"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
26733         LDKRoutingFees a_conv;
26734         a_conv.inner = (void*)(a & (~1));
26735         a_conv.is_owned = false;
26736         LDKRoutingFees b_conv;
26737         b_conv.inner = (void*)(b & (~1));
26738         b_conv.is_owned = false;
26739         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
26740         return ret_val;
26741 }
26742
26743 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
26744         LDKRoutingFees orig_conv;
26745         orig_conv.inner = (void*)(orig & (~1));
26746         orig_conv.is_owned = false;
26747         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
26748         uint64_t ret_ref = 0;
26749         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26750         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26751         ret_ref = (uint64_t)ret_var.inner;
26752         if (ret_var.is_owned) {
26753                 ret_ref |= 1;
26754         }
26755         return ret_ref;
26756 }
26757
26758 int64_t  __attribute__((visibility("default"))) TS_RoutingFees_hash(uint32_t o) {
26759         LDKRoutingFees o_conv;
26760         o_conv.inner = (void*)(o & (~1));
26761         o_conv.is_owned = false;
26762         int64_t ret_val = RoutingFees_hash(&o_conv);
26763         return ret_val;
26764 }
26765
26766 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
26767         LDKRoutingFees obj_conv;
26768         obj_conv.inner = (void*)(obj & (~1));
26769         obj_conv.is_owned = false;
26770         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
26771         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
26772         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
26773         CVec_u8Z_free(ret_var);
26774         return ret_arr;
26775 }
26776
26777 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
26778         LDKu8slice ser_ref;
26779         ser_ref.datalen = *((uint32_t*)ser);
26780         ser_ref.data = (int8_t*)(ser + 4);
26781         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
26782         *ret_conv = RoutingFees_read(ser_ref);
26783         return (uint64_t)ret_conv;
26784 }
26785
26786 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
26787         LDKNodeAnnouncementInfo this_obj_conv;
26788         this_obj_conv.inner = (void*)(this_obj & (~1));
26789         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26790         NodeAnnouncementInfo_free(this_obj_conv);
26791 }
26792
26793 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
26794         LDKNodeAnnouncementInfo this_ptr_conv;
26795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26796         this_ptr_conv.is_owned = false;
26797         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
26798         uint64_t ret_ref = 0;
26799         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26800         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26801         ret_ref = (uint64_t)ret_var.inner;
26802         if (ret_var.is_owned) {
26803                 ret_ref |= 1;
26804         }
26805         return ret_ref;
26806 }
26807
26808 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
26809         LDKNodeAnnouncementInfo this_ptr_conv;
26810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26811         this_ptr_conv.is_owned = false;
26812         LDKNodeFeatures val_conv;
26813         val_conv.inner = (void*)(val & (~1));
26814         val_conv.is_owned = (val & 1) || (val == 0);
26815         val_conv = NodeFeatures_clone(&val_conv);
26816         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
26817 }
26818
26819 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
26820         LDKNodeAnnouncementInfo this_ptr_conv;
26821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26822         this_ptr_conv.is_owned = false;
26823         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
26824         return ret_val;
26825 }
26826
26827 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
26828         LDKNodeAnnouncementInfo this_ptr_conv;
26829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26830         this_ptr_conv.is_owned = false;
26831         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
26832 }
26833
26834 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
26835         LDKNodeAnnouncementInfo this_ptr_conv;
26836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26837         this_ptr_conv.is_owned = false;
26838         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
26839         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
26840         return ret_arr;
26841 }
26842
26843 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
26844         LDKNodeAnnouncementInfo this_ptr_conv;
26845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26846         this_ptr_conv.is_owned = false;
26847         LDKThreeBytes val_ref;
26848         CHECK(*((uint32_t*)val) == 3);
26849         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
26850         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
26851 }
26852
26853 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
26854         LDKNodeAnnouncementInfo this_ptr_conv;
26855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26856         this_ptr_conv.is_owned = false;
26857         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26858         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
26859         return ret_arr;
26860 }
26861
26862 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
26863         LDKNodeAnnouncementInfo this_ptr_conv;
26864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26865         this_ptr_conv.is_owned = false;
26866         LDKThirtyTwoBytes val_ref;
26867         CHECK(*((uint32_t*)val) == 32);
26868         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
26869         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
26870 }
26871
26872 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
26873         LDKNodeAnnouncementInfo this_ptr_conv;
26874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26875         this_ptr_conv.is_owned = false;
26876         LDKCVec_NetAddressZ val_constr;
26877         val_constr.datalen = *((uint32_t*)val);
26878         if (val_constr.datalen > 0)
26879                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
26880         else
26881                 val_constr.data = NULL;
26882         uint32_t* val_vals = (uint32_t*)(val + 4);
26883         for (size_t m = 0; m < val_constr.datalen; m++) {
26884                 uint32_t val_conv_12 = val_vals[m];
26885                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
26886                 CHECK_ACCESS(val_conv_12_ptr);
26887                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
26888                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
26889                 val_constr.data[m] = val_conv_12_conv;
26890         }
26891         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
26892 }
26893
26894 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
26895         LDKNodeAnnouncementInfo this_ptr_conv;
26896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26897         this_ptr_conv.is_owned = false;
26898         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
26899         uint64_t ret_ref = 0;
26900         if ((uint64_t)ret_var.inner > 4096) {
26901                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26902                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26903                 ret_ref = (uint64_t)ret_var.inner;
26904                 if (ret_var.is_owned) {
26905                         ret_ref |= 1;
26906                 }
26907         }
26908         return ret_ref;
26909 }
26910
26911 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
26912         LDKNodeAnnouncementInfo this_ptr_conv;
26913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26914         this_ptr_conv.is_owned = false;
26915         LDKNodeAnnouncement val_conv;
26916         val_conv.inner = (void*)(val & (~1));
26917         val_conv.is_owned = (val & 1) || (val == 0);
26918         val_conv = NodeAnnouncement_clone(&val_conv);
26919         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
26920 }
26921
26922 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) {
26923         LDKNodeFeatures features_arg_conv;
26924         features_arg_conv.inner = (void*)(features_arg & (~1));
26925         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26926         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
26927         LDKThreeBytes rgb_arg_ref;
26928         CHECK(*((uint32_t*)rgb_arg) == 3);
26929         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
26930         LDKThirtyTwoBytes alias_arg_ref;
26931         CHECK(*((uint32_t*)alias_arg) == 32);
26932         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
26933         LDKCVec_NetAddressZ addresses_arg_constr;
26934         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
26935         if (addresses_arg_constr.datalen > 0)
26936                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
26937         else
26938                 addresses_arg_constr.data = NULL;
26939         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
26940         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
26941                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
26942                 void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
26943                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
26944                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
26945                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
26946         }
26947         LDKNodeAnnouncement announcement_message_arg_conv;
26948         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
26949         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
26950         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
26951         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
26952         uint64_t ret_ref = 0;
26953         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26954         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26955         ret_ref = (uint64_t)ret_var.inner;
26956         if (ret_var.is_owned) {
26957                 ret_ref |= 1;
26958         }
26959         return ret_ref;
26960 }
26961
26962 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
26963         LDKNodeAnnouncementInfo orig_conv;
26964         orig_conv.inner = (void*)(orig & (~1));
26965         orig_conv.is_owned = false;
26966         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
26967         uint64_t ret_ref = 0;
26968         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26969         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26970         ret_ref = (uint64_t)ret_var.inner;
26971         if (ret_var.is_owned) {
26972                 ret_ref |= 1;
26973         }
26974         return ret_ref;
26975 }
26976
26977 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
26978         LDKNodeAnnouncementInfo obj_conv;
26979         obj_conv.inner = (void*)(obj & (~1));
26980         obj_conv.is_owned = false;
26981         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
26982         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
26983         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
26984         CVec_u8Z_free(ret_var);
26985         return ret_arr;
26986 }
26987
26988 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
26989         LDKu8slice ser_ref;
26990         ser_ref.datalen = *((uint32_t*)ser);
26991         ser_ref.data = (int8_t*)(ser + 4);
26992         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
26993         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
26994         return (uint64_t)ret_conv;
26995 }
26996
26997 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
26998         LDKNodeInfo this_obj_conv;
26999         this_obj_conv.inner = (void*)(this_obj & (~1));
27000         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27001         NodeInfo_free(this_obj_conv);
27002 }
27003
27004 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
27005         LDKNodeInfo this_ptr_conv;
27006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27007         this_ptr_conv.is_owned = false;
27008         LDKCVec_u64Z val_constr;
27009         val_constr.datalen = *((uint32_t*)val);
27010         if (val_constr.datalen > 0)
27011                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
27012         else
27013                 val_constr.data = NULL;
27014         int64_t* val_vals = (int64_t*)(val + 4);
27015         for (size_t i = 0; i < val_constr.datalen; i++) {
27016                 int64_t val_conv_8 = val_vals[i];
27017                 val_constr.data[i] = val_conv_8;
27018         }
27019         NodeInfo_set_channels(&this_ptr_conv, val_constr);
27020 }
27021
27022 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
27023         LDKNodeInfo this_ptr_conv;
27024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27025         this_ptr_conv.is_owned = false;
27026         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
27027         uint64_t ret_ref = 0;
27028         if ((uint64_t)ret_var.inner > 4096) {
27029                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27030                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27031                 ret_ref = (uint64_t)ret_var.inner;
27032                 if (ret_var.is_owned) {
27033                         ret_ref |= 1;
27034                 }
27035         }
27036         return ret_ref;
27037 }
27038
27039 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
27040         LDKNodeInfo this_ptr_conv;
27041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27042         this_ptr_conv.is_owned = false;
27043         LDKRoutingFees val_conv;
27044         val_conv.inner = (void*)(val & (~1));
27045         val_conv.is_owned = (val & 1) || (val == 0);
27046         val_conv = RoutingFees_clone(&val_conv);
27047         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
27048 }
27049
27050 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
27051         LDKNodeInfo this_ptr_conv;
27052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27053         this_ptr_conv.is_owned = false;
27054         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
27055         uint64_t ret_ref = 0;
27056         if ((uint64_t)ret_var.inner > 4096) {
27057                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27058                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27059                 ret_ref = (uint64_t)ret_var.inner;
27060                 if (ret_var.is_owned) {
27061                         ret_ref |= 1;
27062                 }
27063         }
27064         return ret_ref;
27065 }
27066
27067 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
27068         LDKNodeInfo this_ptr_conv;
27069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27070         this_ptr_conv.is_owned = false;
27071         LDKNodeAnnouncementInfo val_conv;
27072         val_conv.inner = (void*)(val & (~1));
27073         val_conv.is_owned = (val & 1) || (val == 0);
27074         val_conv = NodeAnnouncementInfo_clone(&val_conv);
27075         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
27076 }
27077
27078 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
27079         LDKCVec_u64Z channels_arg_constr;
27080         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
27081         if (channels_arg_constr.datalen > 0)
27082                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
27083         else
27084                 channels_arg_constr.data = NULL;
27085         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
27086         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
27087                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
27088                 channels_arg_constr.data[i] = channels_arg_conv_8;
27089         }
27090         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
27091         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
27092         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
27093         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
27094         LDKNodeAnnouncementInfo announcement_info_arg_conv;
27095         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
27096         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
27097         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
27098         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
27099         uint64_t ret_ref = 0;
27100         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27101         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27102         ret_ref = (uint64_t)ret_var.inner;
27103         if (ret_var.is_owned) {
27104                 ret_ref |= 1;
27105         }
27106         return ret_ref;
27107 }
27108
27109 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
27110         LDKNodeInfo orig_conv;
27111         orig_conv.inner = (void*)(orig & (~1));
27112         orig_conv.is_owned = false;
27113         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
27114         uint64_t ret_ref = 0;
27115         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27116         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27117         ret_ref = (uint64_t)ret_var.inner;
27118         if (ret_var.is_owned) {
27119                 ret_ref |= 1;
27120         }
27121         return ret_ref;
27122 }
27123
27124 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
27125         LDKNodeInfo obj_conv;
27126         obj_conv.inner = (void*)(obj & (~1));
27127         obj_conv.is_owned = false;
27128         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
27129         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27130         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27131         CVec_u8Z_free(ret_var);
27132         return ret_arr;
27133 }
27134
27135 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
27136         LDKu8slice ser_ref;
27137         ser_ref.datalen = *((uint32_t*)ser);
27138         ser_ref.data = (int8_t*)(ser + 4);
27139         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
27140         *ret_conv = NodeInfo_read(ser_ref);
27141         return (uint64_t)ret_conv;
27142 }
27143
27144 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
27145         LDKNetworkGraph obj_conv;
27146         obj_conv.inner = (void*)(obj & (~1));
27147         obj_conv.is_owned = false;
27148         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
27149         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27150         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27151         CVec_u8Z_free(ret_var);
27152         return ret_arr;
27153 }
27154
27155 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
27156         LDKu8slice ser_ref;
27157         ser_ref.datalen = *((uint32_t*)ser);
27158         ser_ref.data = (int8_t*)(ser + 4);
27159         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
27160         *ret_conv = NetworkGraph_read(ser_ref);
27161         return (uint64_t)ret_conv;
27162 }
27163
27164 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
27165         LDKThirtyTwoBytes genesis_hash_ref;
27166         CHECK(*((uint32_t*)genesis_hash) == 32);
27167         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
27168         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
27169         uint64_t ret_ref = 0;
27170         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27171         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27172         ret_ref = (uint64_t)ret_var.inner;
27173         if (ret_var.is_owned) {
27174                 ret_ref |= 1;
27175         }
27176         return ret_ref;
27177 }
27178
27179 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
27180         LDKNetworkGraph this_arg_conv;
27181         this_arg_conv.inner = (void*)(this_arg & (~1));
27182         this_arg_conv.is_owned = false;
27183         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
27184         uint64_t ret_ref = 0;
27185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27187         ret_ref = (uint64_t)ret_var.inner;
27188         if (ret_var.is_owned) {
27189                 ret_ref |= 1;
27190         }
27191         return ret_ref;
27192 }
27193
27194 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
27195         LDKNetworkGraph this_arg_conv;
27196         this_arg_conv.inner = (void*)(this_arg & (~1));
27197         this_arg_conv.is_owned = false;
27198         LDKNodeAnnouncement msg_conv;
27199         msg_conv.inner = (void*)(msg & (~1));
27200         msg_conv.is_owned = false;
27201         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
27202         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
27203         return (uint64_t)ret_conv;
27204 }
27205
27206 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
27207         LDKNetworkGraph this_arg_conv;
27208         this_arg_conv.inner = (void*)(this_arg & (~1));
27209         this_arg_conv.is_owned = false;
27210         LDKUnsignedNodeAnnouncement msg_conv;
27211         msg_conv.inner = (void*)(msg & (~1));
27212         msg_conv.is_owned = false;
27213         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
27214         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
27215         return (uint64_t)ret_conv;
27216 }
27217
27218 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
27219         LDKNetworkGraph this_arg_conv;
27220         this_arg_conv.inner = (void*)(this_arg & (~1));
27221         this_arg_conv.is_owned = false;
27222         LDKChannelAnnouncement msg_conv;
27223         msg_conv.inner = (void*)(msg & (~1));
27224         msg_conv.is_owned = false;
27225         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
27226         CHECK_ACCESS(chain_access_ptr);
27227         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
27228         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
27229         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
27230                 // Manually implement clone for Java trait instances
27231         }
27232         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
27233         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
27234         return (uint64_t)ret_conv;
27235 }
27236
27237 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
27238         LDKNetworkGraph this_arg_conv;
27239         this_arg_conv.inner = (void*)(this_arg & (~1));
27240         this_arg_conv.is_owned = false;
27241         LDKUnsignedChannelAnnouncement msg_conv;
27242         msg_conv.inner = (void*)(msg & (~1));
27243         msg_conv.is_owned = false;
27244         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
27245         CHECK_ACCESS(chain_access_ptr);
27246         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
27247         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
27248         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
27249                 // Manually implement clone for Java trait instances
27250         }
27251         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
27252         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
27253         return (uint64_t)ret_conv;
27254 }
27255
27256 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
27257         LDKNetworkGraph this_arg_conv;
27258         this_arg_conv.inner = (void*)(this_arg & (~1));
27259         this_arg_conv.is_owned = false;
27260         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
27261 }
27262
27263 void  __attribute__((visibility("default"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
27264         LDKNetworkGraph this_arg_conv;
27265         this_arg_conv.inner = (void*)(this_arg & (~1));
27266         this_arg_conv.is_owned = false;
27267         LDKPublicKey _node_id_ref;
27268         CHECK(*((uint32_t*)_node_id) == 33);
27269         memcpy(_node_id_ref.compressed_form, (uint8_t*)(_node_id + 4), 33);
27270         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
27271 }
27272
27273 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
27274         LDKNetworkGraph this_arg_conv;
27275         this_arg_conv.inner = (void*)(this_arg & (~1));
27276         this_arg_conv.is_owned = false;
27277         LDKChannelUpdate msg_conv;
27278         msg_conv.inner = (void*)(msg & (~1));
27279         msg_conv.is_owned = false;
27280         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
27281         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
27282         return (uint64_t)ret_conv;
27283 }
27284
27285 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
27286         LDKNetworkGraph this_arg_conv;
27287         this_arg_conv.inner = (void*)(this_arg & (~1));
27288         this_arg_conv.is_owned = false;
27289         LDKUnsignedChannelUpdate msg_conv;
27290         msg_conv.inner = (void*)(msg & (~1));
27291         msg_conv.is_owned = false;
27292         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
27293         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
27294         return (uint64_t)ret_conv;
27295 }
27296
27297 uint32_t  __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
27298         LDKReadOnlyNetworkGraph this_arg_conv;
27299         this_arg_conv.inner = (void*)(this_arg & (~1));
27300         this_arg_conv.is_owned = false;
27301         LDKPublicKey pubkey_ref;
27302         CHECK(*((uint32_t*)pubkey) == 33);
27303         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
27304         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
27305         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
27306         uint64_t ret_ref = (uint64_t)ret_copy;
27307         return ret_ref;
27308 }
27309
27310 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
27311         LDKRouteHop this_obj_conv;
27312         this_obj_conv.inner = (void*)(this_obj & (~1));
27313         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27314         RouteHop_free(this_obj_conv);
27315 }
27316
27317 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
27318         LDKRouteHop this_ptr_conv;
27319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27320         this_ptr_conv.is_owned = false;
27321         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
27322         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
27323         return ret_arr;
27324 }
27325
27326 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
27327         LDKRouteHop this_ptr_conv;
27328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27329         this_ptr_conv.is_owned = false;
27330         LDKPublicKey val_ref;
27331         CHECK(*((uint32_t*)val) == 33);
27332         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
27333         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
27334 }
27335
27336 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
27337         LDKRouteHop this_ptr_conv;
27338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27339         this_ptr_conv.is_owned = false;
27340         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
27341         uint64_t ret_ref = 0;
27342         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27343         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27344         ret_ref = (uint64_t)ret_var.inner;
27345         if (ret_var.is_owned) {
27346                 ret_ref |= 1;
27347         }
27348         return ret_ref;
27349 }
27350
27351 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
27352         LDKRouteHop this_ptr_conv;
27353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27354         this_ptr_conv.is_owned = false;
27355         LDKNodeFeatures val_conv;
27356         val_conv.inner = (void*)(val & (~1));
27357         val_conv.is_owned = (val & 1) || (val == 0);
27358         val_conv = NodeFeatures_clone(&val_conv);
27359         RouteHop_set_node_features(&this_ptr_conv, val_conv);
27360 }
27361
27362 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
27363         LDKRouteHop this_ptr_conv;
27364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27365         this_ptr_conv.is_owned = false;
27366         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
27367         return ret_val;
27368 }
27369
27370 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
27371         LDKRouteHop this_ptr_conv;
27372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27373         this_ptr_conv.is_owned = false;
27374         RouteHop_set_short_channel_id(&this_ptr_conv, val);
27375 }
27376
27377 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
27378         LDKRouteHop this_ptr_conv;
27379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27380         this_ptr_conv.is_owned = false;
27381         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
27382         uint64_t ret_ref = 0;
27383         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27384         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27385         ret_ref = (uint64_t)ret_var.inner;
27386         if (ret_var.is_owned) {
27387                 ret_ref |= 1;
27388         }
27389         return ret_ref;
27390 }
27391
27392 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
27393         LDKRouteHop this_ptr_conv;
27394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27395         this_ptr_conv.is_owned = false;
27396         LDKChannelFeatures val_conv;
27397         val_conv.inner = (void*)(val & (~1));
27398         val_conv.is_owned = (val & 1) || (val == 0);
27399         val_conv = ChannelFeatures_clone(&val_conv);
27400         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
27401 }
27402
27403 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
27404         LDKRouteHop this_ptr_conv;
27405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27406         this_ptr_conv.is_owned = false;
27407         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
27408         return ret_val;
27409 }
27410
27411 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
27412         LDKRouteHop this_ptr_conv;
27413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27414         this_ptr_conv.is_owned = false;
27415         RouteHop_set_fee_msat(&this_ptr_conv, val);
27416 }
27417
27418 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
27419         LDKRouteHop this_ptr_conv;
27420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27421         this_ptr_conv.is_owned = false;
27422         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
27423         return ret_val;
27424 }
27425
27426 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
27427         LDKRouteHop this_ptr_conv;
27428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27429         this_ptr_conv.is_owned = false;
27430         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
27431 }
27432
27433 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) {
27434         LDKPublicKey pubkey_arg_ref;
27435         CHECK(*((uint32_t*)pubkey_arg) == 33);
27436         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
27437         LDKNodeFeatures node_features_arg_conv;
27438         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
27439         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
27440         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
27441         LDKChannelFeatures channel_features_arg_conv;
27442         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
27443         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
27444         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
27445         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);
27446         uint64_t ret_ref = 0;
27447         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27448         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27449         ret_ref = (uint64_t)ret_var.inner;
27450         if (ret_var.is_owned) {
27451                 ret_ref |= 1;
27452         }
27453         return ret_ref;
27454 }
27455
27456 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
27457         LDKRouteHop orig_conv;
27458         orig_conv.inner = (void*)(orig & (~1));
27459         orig_conv.is_owned = false;
27460         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
27461         uint64_t ret_ref = 0;
27462         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27463         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27464         ret_ref = (uint64_t)ret_var.inner;
27465         if (ret_var.is_owned) {
27466                 ret_ref |= 1;
27467         }
27468         return ret_ref;
27469 }
27470
27471 int64_t  __attribute__((visibility("default"))) TS_RouteHop_hash(uint32_t o) {
27472         LDKRouteHop o_conv;
27473         o_conv.inner = (void*)(o & (~1));
27474         o_conv.is_owned = false;
27475         int64_t ret_val = RouteHop_hash(&o_conv);
27476         return ret_val;
27477 }
27478
27479 jboolean  __attribute__((visibility("default"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
27480         LDKRouteHop a_conv;
27481         a_conv.inner = (void*)(a & (~1));
27482         a_conv.is_owned = false;
27483         LDKRouteHop b_conv;
27484         b_conv.inner = (void*)(b & (~1));
27485         b_conv.is_owned = false;
27486         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
27487         return ret_val;
27488 }
27489
27490 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) {
27491         LDKRouteHop obj_conv;
27492         obj_conv.inner = (void*)(obj & (~1));
27493         obj_conv.is_owned = false;
27494         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
27495         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27496         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27497         CVec_u8Z_free(ret_var);
27498         return ret_arr;
27499 }
27500
27501 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_read(int8_tArray ser) {
27502         LDKu8slice ser_ref;
27503         ser_ref.datalen = *((uint32_t*)ser);
27504         ser_ref.data = (int8_t*)(ser + 4);
27505         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
27506         *ret_conv = RouteHop_read(ser_ref);
27507         return (uint64_t)ret_conv;
27508 }
27509
27510 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
27511         LDKRoute this_obj_conv;
27512         this_obj_conv.inner = (void*)(this_obj & (~1));
27513         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27514         Route_free(this_obj_conv);
27515 }
27516
27517 ptrArray  __attribute__((visibility("default"))) TS_Route_get_paths(uint32_t this_ptr) {
27518         LDKRoute this_ptr_conv;
27519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27520         this_ptr_conv.is_owned = false;
27521         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
27522         ptrArray ret_arr = NULL;
27523         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
27524         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(ret_arr + 4);
27525         for (size_t m = 0; m < ret_var.datalen; m++) {
27526                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
27527                 uint32_tArray ret_conv_12_arr = NULL;
27528                 ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
27529                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(ret_conv_12_arr + 4);
27530                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
27531                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
27532                         uint64_t ret_conv_12_conv_10_ref = 0;
27533                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27534                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27535                         ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
27536                         if (ret_conv_12_conv_10_var.is_owned) {
27537                                 ret_conv_12_conv_10_ref |= 1;
27538                         }
27539                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
27540                 }
27541                 
27542                 FREE(ret_conv_12_var.data);
27543                 ret_arr_ptr[m] = ret_conv_12_arr;
27544         }
27545         
27546         FREE(ret_var.data);
27547         return ret_arr;
27548 }
27549
27550 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
27551         LDKRoute this_ptr_conv;
27552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27553         this_ptr_conv.is_owned = false;
27554         LDKCVec_CVec_RouteHopZZ val_constr;
27555         val_constr.datalen = *((uint32_t*)val);
27556         if (val_constr.datalen > 0)
27557                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
27558         else
27559                 val_constr.data = NULL;
27560         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
27561         for (size_t m = 0; m < val_constr.datalen; m++) {
27562                 uint32_tArray val_conv_12 = val_vals[m];
27563                 LDKCVec_RouteHopZ val_conv_12_constr;
27564                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
27565                 if (val_conv_12_constr.datalen > 0)
27566                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
27567                 else
27568                         val_conv_12_constr.data = NULL;
27569                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
27570                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
27571                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
27572                         LDKRouteHop val_conv_12_conv_10_conv;
27573                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
27574                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
27575                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
27576                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
27577                 }
27578                 val_constr.data[m] = val_conv_12_constr;
27579         }
27580         Route_set_paths(&this_ptr_conv, val_constr);
27581 }
27582
27583 uint32_t  __attribute__((visibility("default"))) TS_Route_get_payee(uint32_t this_ptr) {
27584         LDKRoute this_ptr_conv;
27585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27586         this_ptr_conv.is_owned = false;
27587         LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
27588         uint64_t ret_ref = 0;
27589         if ((uint64_t)ret_var.inner > 4096) {
27590                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27591                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27592                 ret_ref = (uint64_t)ret_var.inner;
27593                 if (ret_var.is_owned) {
27594                         ret_ref |= 1;
27595                 }
27596         }
27597         return ret_ref;
27598 }
27599
27600 void  __attribute__((visibility("default"))) TS_Route_set_payee(uint32_t this_ptr, uint32_t val) {
27601         LDKRoute this_ptr_conv;
27602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27603         this_ptr_conv.is_owned = false;
27604         LDKPayee val_conv;
27605         val_conv.inner = (void*)(val & (~1));
27606         val_conv.is_owned = (val & 1) || (val == 0);
27607         val_conv = Payee_clone(&val_conv);
27608         Route_set_payee(&this_ptr_conv, val_conv);
27609 }
27610
27611 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg, uint32_t payee_arg) {
27612         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
27613         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
27614         if (paths_arg_constr.datalen > 0)
27615                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
27616         else
27617                 paths_arg_constr.data = NULL;
27618         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
27619         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
27620                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
27621                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
27622                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
27623                 if (paths_arg_conv_12_constr.datalen > 0)
27624                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
27625                 else
27626                         paths_arg_conv_12_constr.data = NULL;
27627                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
27628                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
27629                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
27630                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
27631                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
27632                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
27633                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
27634                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
27635                 }
27636                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
27637         }
27638         LDKPayee payee_arg_conv;
27639         payee_arg_conv.inner = (void*)(payee_arg & (~1));
27640         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
27641         payee_arg_conv = Payee_clone(&payee_arg_conv);
27642         LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
27643         uint64_t ret_ref = 0;
27644         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27645         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27646         ret_ref = (uint64_t)ret_var.inner;
27647         if (ret_var.is_owned) {
27648                 ret_ref |= 1;
27649         }
27650         return ret_ref;
27651 }
27652
27653 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
27654         LDKRoute orig_conv;
27655         orig_conv.inner = (void*)(orig & (~1));
27656         orig_conv.is_owned = false;
27657         LDKRoute ret_var = Route_clone(&orig_conv);
27658         uint64_t ret_ref = 0;
27659         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27660         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27661         ret_ref = (uint64_t)ret_var.inner;
27662         if (ret_var.is_owned) {
27663                 ret_ref |= 1;
27664         }
27665         return ret_ref;
27666 }
27667
27668 int64_t  __attribute__((visibility("default"))) TS_Route_hash(uint32_t o) {
27669         LDKRoute o_conv;
27670         o_conv.inner = (void*)(o & (~1));
27671         o_conv.is_owned = false;
27672         int64_t ret_val = Route_hash(&o_conv);
27673         return ret_val;
27674 }
27675
27676 jboolean  __attribute__((visibility("default"))) TS_Route_eq(uint32_t a, uint32_t b) {
27677         LDKRoute a_conv;
27678         a_conv.inner = (void*)(a & (~1));
27679         a_conv.is_owned = false;
27680         LDKRoute b_conv;
27681         b_conv.inner = (void*)(b & (~1));
27682         b_conv.is_owned = false;
27683         jboolean ret_val = Route_eq(&a_conv, &b_conv);
27684         return ret_val;
27685 }
27686
27687 int64_t  __attribute__((visibility("default"))) TS_Route_get_total_fees(uint32_t this_arg) {
27688         LDKRoute this_arg_conv;
27689         this_arg_conv.inner = (void*)(this_arg & (~1));
27690         this_arg_conv.is_owned = false;
27691         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
27692         return ret_val;
27693 }
27694
27695 int64_t  __attribute__((visibility("default"))) TS_Route_get_total_amount(uint32_t this_arg) {
27696         LDKRoute this_arg_conv;
27697         this_arg_conv.inner = (void*)(this_arg & (~1));
27698         this_arg_conv.is_owned = false;
27699         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
27700         return ret_val;
27701 }
27702
27703 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
27704         LDKRoute obj_conv;
27705         obj_conv.inner = (void*)(obj & (~1));
27706         obj_conv.is_owned = false;
27707         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
27708         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27709         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27710         CVec_u8Z_free(ret_var);
27711         return ret_arr;
27712 }
27713
27714 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
27715         LDKu8slice ser_ref;
27716         ser_ref.datalen = *((uint32_t*)ser);
27717         ser_ref.data = (int8_t*)(ser + 4);
27718         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
27719         *ret_conv = Route_read(ser_ref);
27720         return (uint64_t)ret_conv;
27721 }
27722
27723 void  __attribute__((visibility("default"))) TS_RouteParameters_free(uint32_t this_obj) {
27724         LDKRouteParameters this_obj_conv;
27725         this_obj_conv.inner = (void*)(this_obj & (~1));
27726         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27727         RouteParameters_free(this_obj_conv);
27728 }
27729
27730 uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_get_payee(uint32_t this_ptr) {
27731         LDKRouteParameters this_ptr_conv;
27732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27733         this_ptr_conv.is_owned = false;
27734         LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
27735         uint64_t ret_ref = 0;
27736         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27737         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27738         ret_ref = (uint64_t)ret_var.inner;
27739         if (ret_var.is_owned) {
27740                 ret_ref |= 1;
27741         }
27742         return ret_ref;
27743 }
27744
27745 void  __attribute__((visibility("default"))) TS_RouteParameters_set_payee(uint32_t this_ptr, uint32_t val) {
27746         LDKRouteParameters this_ptr_conv;
27747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27748         this_ptr_conv.is_owned = false;
27749         LDKPayee val_conv;
27750         val_conv.inner = (void*)(val & (~1));
27751         val_conv.is_owned = (val & 1) || (val == 0);
27752         val_conv = Payee_clone(&val_conv);
27753         RouteParameters_set_payee(&this_ptr_conv, val_conv);
27754 }
27755
27756 int64_t  __attribute__((visibility("default"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
27757         LDKRouteParameters this_ptr_conv;
27758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27759         this_ptr_conv.is_owned = false;
27760         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
27761         return ret_val;
27762 }
27763
27764 void  __attribute__((visibility("default"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
27765         LDKRouteParameters this_ptr_conv;
27766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27767         this_ptr_conv.is_owned = false;
27768         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
27769 }
27770
27771 int32_t  __attribute__((visibility("default"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
27772         LDKRouteParameters this_ptr_conv;
27773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27774         this_ptr_conv.is_owned = false;
27775         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
27776         return ret_val;
27777 }
27778
27779 void  __attribute__((visibility("default"))) TS_RouteParameters_set_final_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
27780         LDKRouteParameters this_ptr_conv;
27781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27782         this_ptr_conv.is_owned = false;
27783         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
27784 }
27785
27786 uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_new(uint32_t payee_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
27787         LDKPayee payee_arg_conv;
27788         payee_arg_conv.inner = (void*)(payee_arg & (~1));
27789         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
27790         payee_arg_conv = Payee_clone(&payee_arg_conv);
27791         LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
27792         uint64_t ret_ref = 0;
27793         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27794         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27795         ret_ref = (uint64_t)ret_var.inner;
27796         if (ret_var.is_owned) {
27797                 ret_ref |= 1;
27798         }
27799         return ret_ref;
27800 }
27801
27802 uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_clone(uint32_t orig) {
27803         LDKRouteParameters orig_conv;
27804         orig_conv.inner = (void*)(orig & (~1));
27805         orig_conv.is_owned = false;
27806         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
27807         uint64_t ret_ref = 0;
27808         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27809         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27810         ret_ref = (uint64_t)ret_var.inner;
27811         if (ret_var.is_owned) {
27812                 ret_ref |= 1;
27813         }
27814         return ret_ref;
27815 }
27816
27817 int8_tArray  __attribute__((visibility("default"))) TS_RouteParameters_write(uint32_t obj) {
27818         LDKRouteParameters obj_conv;
27819         obj_conv.inner = (void*)(obj & (~1));
27820         obj_conv.is_owned = false;
27821         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
27822         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27823         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27824         CVec_u8Z_free(ret_var);
27825         return ret_arr;
27826 }
27827
27828 uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_read(int8_tArray ser) {
27829         LDKu8slice ser_ref;
27830         ser_ref.datalen = *((uint32_t*)ser);
27831         ser_ref.data = (int8_t*)(ser + 4);
27832         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
27833         *ret_conv = RouteParameters_read(ser_ref);
27834         return (uint64_t)ret_conv;
27835 }
27836
27837 void  __attribute__((visibility("default"))) TS_Payee_free(uint32_t this_obj) {
27838         LDKPayee this_obj_conv;
27839         this_obj_conv.inner = (void*)(this_obj & (~1));
27840         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27841         Payee_free(this_obj_conv);
27842 }
27843
27844 int8_tArray  __attribute__((visibility("default"))) TS_Payee_get_pubkey(uint32_t this_ptr) {
27845         LDKPayee this_ptr_conv;
27846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27847         this_ptr_conv.is_owned = false;
27848         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
27849         memcpy((uint8_t*)(ret_arr + 4), Payee_get_pubkey(&this_ptr_conv).compressed_form, 33);
27850         return ret_arr;
27851 }
27852
27853 void  __attribute__((visibility("default"))) TS_Payee_set_pubkey(uint32_t this_ptr, int8_tArray val) {
27854         LDKPayee this_ptr_conv;
27855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27856         this_ptr_conv.is_owned = false;
27857         LDKPublicKey val_ref;
27858         CHECK(*((uint32_t*)val) == 33);
27859         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
27860         Payee_set_pubkey(&this_ptr_conv, val_ref);
27861 }
27862
27863 uint32_t  __attribute__((visibility("default"))) TS_Payee_get_features(uint32_t this_ptr) {
27864         LDKPayee this_ptr_conv;
27865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27866         this_ptr_conv.is_owned = false;
27867         LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
27868         uint64_t ret_ref = 0;
27869         if ((uint64_t)ret_var.inner > 4096) {
27870                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27871                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27872                 ret_ref = (uint64_t)ret_var.inner;
27873                 if (ret_var.is_owned) {
27874                         ret_ref |= 1;
27875                 }
27876         }
27877         return ret_ref;
27878 }
27879
27880 void  __attribute__((visibility("default"))) TS_Payee_set_features(uint32_t this_ptr, uint32_t val) {
27881         LDKPayee this_ptr_conv;
27882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27883         this_ptr_conv.is_owned = false;
27884         LDKInvoiceFeatures val_conv;
27885         val_conv.inner = (void*)(val & (~1));
27886         val_conv.is_owned = (val & 1) || (val == 0);
27887         val_conv = InvoiceFeatures_clone(&val_conv);
27888         Payee_set_features(&this_ptr_conv, val_conv);
27889 }
27890
27891 uint32_tArray  __attribute__((visibility("default"))) TS_Payee_get_route_hints(uint32_t this_ptr) {
27892         LDKPayee this_ptr_conv;
27893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27894         this_ptr_conv.is_owned = false;
27895         LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
27896         uint32_tArray ret_arr = NULL;
27897         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
27898         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
27899         for (size_t l = 0; l < ret_var.datalen; l++) {
27900                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
27901                 uint64_t ret_conv_11_ref = 0;
27902                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27903                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27904                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
27905                 if (ret_conv_11_var.is_owned) {
27906                         ret_conv_11_ref |= 1;
27907                 }
27908                 ret_arr_ptr[l] = ret_conv_11_ref;
27909         }
27910         
27911         FREE(ret_var.data);
27912         return ret_arr;
27913 }
27914
27915 void  __attribute__((visibility("default"))) TS_Payee_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
27916         LDKPayee this_ptr_conv;
27917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27918         this_ptr_conv.is_owned = false;
27919         LDKCVec_RouteHintZ val_constr;
27920         val_constr.datalen = *((uint32_t*)val);
27921         if (val_constr.datalen > 0)
27922                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
27923         else
27924                 val_constr.data = NULL;
27925         uint32_t* val_vals = (uint32_t*)(val + 4);
27926         for (size_t l = 0; l < val_constr.datalen; l++) {
27927                 uint32_t val_conv_11 = val_vals[l];
27928                 LDKRouteHint val_conv_11_conv;
27929                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
27930                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
27931                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
27932                 val_constr.data[l] = val_conv_11_conv;
27933         }
27934         Payee_set_route_hints(&this_ptr_conv, val_constr);
27935 }
27936
27937 uint32_t  __attribute__((visibility("default"))) TS_Payee_get_expiry_time(uint32_t this_ptr) {
27938         LDKPayee this_ptr_conv;
27939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27940         this_ptr_conv.is_owned = false;
27941         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27942         *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
27943         uint64_t ret_ref = (uint64_t)ret_copy;
27944         return ret_ref;
27945 }
27946
27947 void  __attribute__((visibility("default"))) TS_Payee_set_expiry_time(uint32_t this_ptr, uint32_t val) {
27948         LDKPayee this_ptr_conv;
27949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27950         this_ptr_conv.is_owned = false;
27951         void* val_ptr = (void*)(((uint64_t)val) & ~1);
27952         CHECK_ACCESS(val_ptr);
27953         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
27954         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
27955         Payee_set_expiry_time(&this_ptr_conv, val_conv);
27956 }
27957
27958 uint32_t  __attribute__((visibility("default"))) TS_Payee_new(int8_tArray pubkey_arg, uint32_t features_arg, uint32_tArray route_hints_arg, uint32_t expiry_time_arg) {
27959         LDKPublicKey pubkey_arg_ref;
27960         CHECK(*((uint32_t*)pubkey_arg) == 33);
27961         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
27962         LDKInvoiceFeatures features_arg_conv;
27963         features_arg_conv.inner = (void*)(features_arg & (~1));
27964         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
27965         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
27966         LDKCVec_RouteHintZ route_hints_arg_constr;
27967         route_hints_arg_constr.datalen = *((uint32_t*)route_hints_arg);
27968         if (route_hints_arg_constr.datalen > 0)
27969                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
27970         else
27971                 route_hints_arg_constr.data = NULL;
27972         uint32_t* route_hints_arg_vals = (uint32_t*)(route_hints_arg + 4);
27973         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
27974                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
27975                 LDKRouteHint route_hints_arg_conv_11_conv;
27976                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
27977                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
27978                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
27979                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
27980         }
27981         void* expiry_time_arg_ptr = (void*)(((uint64_t)expiry_time_arg) & ~1);
27982         CHECK_ACCESS(expiry_time_arg_ptr);
27983         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
27984         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)expiry_time_arg) & ~1));
27985         LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
27986         uint64_t ret_ref = 0;
27987         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27988         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27989         ret_ref = (uint64_t)ret_var.inner;
27990         if (ret_var.is_owned) {
27991                 ret_ref |= 1;
27992         }
27993         return ret_ref;
27994 }
27995
27996 uint32_t  __attribute__((visibility("default"))) TS_Payee_clone(uint32_t orig) {
27997         LDKPayee orig_conv;
27998         orig_conv.inner = (void*)(orig & (~1));
27999         orig_conv.is_owned = false;
28000         LDKPayee ret_var = Payee_clone(&orig_conv);
28001         uint64_t ret_ref = 0;
28002         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28003         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28004         ret_ref = (uint64_t)ret_var.inner;
28005         if (ret_var.is_owned) {
28006                 ret_ref |= 1;
28007         }
28008         return ret_ref;
28009 }
28010
28011 int64_t  __attribute__((visibility("default"))) TS_Payee_hash(uint32_t o) {
28012         LDKPayee o_conv;
28013         o_conv.inner = (void*)(o & (~1));
28014         o_conv.is_owned = false;
28015         int64_t ret_val = Payee_hash(&o_conv);
28016         return ret_val;
28017 }
28018
28019 jboolean  __attribute__((visibility("default"))) TS_Payee_eq(uint32_t a, uint32_t b) {
28020         LDKPayee a_conv;
28021         a_conv.inner = (void*)(a & (~1));
28022         a_conv.is_owned = false;
28023         LDKPayee b_conv;
28024         b_conv.inner = (void*)(b & (~1));
28025         b_conv.is_owned = false;
28026         jboolean ret_val = Payee_eq(&a_conv, &b_conv);
28027         return ret_val;
28028 }
28029
28030 int8_tArray  __attribute__((visibility("default"))) TS_Payee_write(uint32_t obj) {
28031         LDKPayee obj_conv;
28032         obj_conv.inner = (void*)(obj & (~1));
28033         obj_conv.is_owned = false;
28034         LDKCVec_u8Z ret_var = Payee_write(&obj_conv);
28035         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28036         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28037         CVec_u8Z_free(ret_var);
28038         return ret_arr;
28039 }
28040
28041 uint32_t  __attribute__((visibility("default"))) TS_Payee_read(int8_tArray ser) {
28042         LDKu8slice ser_ref;
28043         ser_ref.datalen = *((uint32_t*)ser);
28044         ser_ref.data = (int8_t*)(ser + 4);
28045         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
28046         *ret_conv = Payee_read(ser_ref);
28047         return (uint64_t)ret_conv;
28048 }
28049
28050 uint32_t  __attribute__((visibility("default"))) TS_Payee_from_node_id(int8_tArray pubkey) {
28051         LDKPublicKey pubkey_ref;
28052         CHECK(*((uint32_t*)pubkey) == 33);
28053         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
28054         LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
28055         uint64_t ret_ref = 0;
28056         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28057         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28058         ret_ref = (uint64_t)ret_var.inner;
28059         if (ret_var.is_owned) {
28060                 ret_ref |= 1;
28061         }
28062         return ret_ref;
28063 }
28064
28065 uint32_t  __attribute__((visibility("default"))) TS_Payee_for_keysend(int8_tArray pubkey) {
28066         LDKPublicKey pubkey_ref;
28067         CHECK(*((uint32_t*)pubkey) == 33);
28068         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
28069         LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
28070         uint64_t ret_ref = 0;
28071         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28072         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28073         ret_ref = (uint64_t)ret_var.inner;
28074         if (ret_var.is_owned) {
28075                 ret_ref |= 1;
28076         }
28077         return ret_ref;
28078 }
28079
28080 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
28081         LDKRouteHint this_obj_conv;
28082         this_obj_conv.inner = (void*)(this_obj & (~1));
28083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28084         RouteHint_free(this_obj_conv);
28085 }
28086
28087 uint32_tArray  __attribute__((visibility("default"))) TS_RouteHint_get_a(uint32_t this_ptr) {
28088         LDKRouteHint this_ptr_conv;
28089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28090         this_ptr_conv.is_owned = false;
28091         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
28092         uint32_tArray ret_arr = NULL;
28093         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
28094         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
28095         for (size_t o = 0; o < ret_var.datalen; o++) {
28096                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
28097                 uint64_t ret_conv_14_ref = 0;
28098                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28099                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28100                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
28101                 if (ret_conv_14_var.is_owned) {
28102                         ret_conv_14_ref |= 1;
28103                 }
28104                 ret_arr_ptr[o] = ret_conv_14_ref;
28105         }
28106         
28107         FREE(ret_var.data);
28108         return ret_arr;
28109 }
28110
28111 void  __attribute__((visibility("default"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
28112         LDKRouteHint this_ptr_conv;
28113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28114         this_ptr_conv.is_owned = false;
28115         LDKCVec_RouteHintHopZ val_constr;
28116         val_constr.datalen = *((uint32_t*)val);
28117         if (val_constr.datalen > 0)
28118                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
28119         else
28120                 val_constr.data = NULL;
28121         uint32_t* val_vals = (uint32_t*)(val + 4);
28122         for (size_t o = 0; o < val_constr.datalen; o++) {
28123                 uint32_t val_conv_14 = val_vals[o];
28124                 LDKRouteHintHop val_conv_14_conv;
28125                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
28126                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
28127                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
28128                 val_constr.data[o] = val_conv_14_conv;
28129         }
28130         RouteHint_set_a(&this_ptr_conv, val_constr);
28131 }
28132
28133 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_new(uint32_tArray a_arg) {
28134         LDKCVec_RouteHintHopZ a_arg_constr;
28135         a_arg_constr.datalen = *((uint32_t*)a_arg);
28136         if (a_arg_constr.datalen > 0)
28137                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
28138         else
28139                 a_arg_constr.data = NULL;
28140         uint32_t* a_arg_vals = (uint32_t*)(a_arg + 4);
28141         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
28142                 uint32_t a_arg_conv_14 = a_arg_vals[o];
28143                 LDKRouteHintHop a_arg_conv_14_conv;
28144                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
28145                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
28146                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
28147                 a_arg_constr.data[o] = a_arg_conv_14_conv;
28148         }
28149         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
28150         uint64_t ret_ref = 0;
28151         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28152         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28153         ret_ref = (uint64_t)ret_var.inner;
28154         if (ret_var.is_owned) {
28155                 ret_ref |= 1;
28156         }
28157         return ret_ref;
28158 }
28159
28160 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
28161         LDKRouteHint orig_conv;
28162         orig_conv.inner = (void*)(orig & (~1));
28163         orig_conv.is_owned = false;
28164         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
28165         uint64_t ret_ref = 0;
28166         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28167         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28168         ret_ref = (uint64_t)ret_var.inner;
28169         if (ret_var.is_owned) {
28170                 ret_ref |= 1;
28171         }
28172         return ret_ref;
28173 }
28174
28175 int64_t  __attribute__((visibility("default"))) TS_RouteHint_hash(uint32_t o) {
28176         LDKRouteHint o_conv;
28177         o_conv.inner = (void*)(o & (~1));
28178         o_conv.is_owned = false;
28179         int64_t ret_val = RouteHint_hash(&o_conv);
28180         return ret_val;
28181 }
28182
28183 jboolean  __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
28184         LDKRouteHint a_conv;
28185         a_conv.inner = (void*)(a & (~1));
28186         a_conv.is_owned = false;
28187         LDKRouteHint b_conv;
28188         b_conv.inner = (void*)(b & (~1));
28189         b_conv.is_owned = false;
28190         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
28191         return ret_val;
28192 }
28193
28194 int8_tArray  __attribute__((visibility("default"))) TS_RouteHint_write(uint32_t obj) {
28195         LDKRouteHint obj_conv;
28196         obj_conv.inner = (void*)(obj & (~1));
28197         obj_conv.is_owned = false;
28198         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
28199         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28200         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28201         CVec_u8Z_free(ret_var);
28202         return ret_arr;
28203 }
28204
28205 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_read(int8_tArray ser) {
28206         LDKu8slice ser_ref;
28207         ser_ref.datalen = *((uint32_t*)ser);
28208         ser_ref.data = (int8_t*)(ser + 4);
28209         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
28210         *ret_conv = RouteHint_read(ser_ref);
28211         return (uint64_t)ret_conv;
28212 }
28213
28214 void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
28215         LDKRouteHintHop this_obj_conv;
28216         this_obj_conv.inner = (void*)(this_obj & (~1));
28217         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28218         RouteHintHop_free(this_obj_conv);
28219 }
28220
28221 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
28222         LDKRouteHintHop this_ptr_conv;
28223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28224         this_ptr_conv.is_owned = false;
28225         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28226         memcpy((uint8_t*)(ret_arr + 4), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
28227         return ret_arr;
28228 }
28229
28230 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
28231         LDKRouteHintHop this_ptr_conv;
28232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28233         this_ptr_conv.is_owned = false;
28234         LDKPublicKey val_ref;
28235         CHECK(*((uint32_t*)val) == 33);
28236         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
28237         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
28238 }
28239
28240 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
28241         LDKRouteHintHop this_ptr_conv;
28242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28243         this_ptr_conv.is_owned = false;
28244         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
28245         return ret_val;
28246 }
28247
28248 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
28249         LDKRouteHintHop this_ptr_conv;
28250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28251         this_ptr_conv.is_owned = false;
28252         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
28253 }
28254
28255 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
28256         LDKRouteHintHop this_ptr_conv;
28257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28258         this_ptr_conv.is_owned = false;
28259         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
28260         uint64_t ret_ref = 0;
28261         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28262         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28263         ret_ref = (uint64_t)ret_var.inner;
28264         if (ret_var.is_owned) {
28265                 ret_ref |= 1;
28266         }
28267         return ret_ref;
28268 }
28269
28270 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
28271         LDKRouteHintHop this_ptr_conv;
28272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28273         this_ptr_conv.is_owned = false;
28274         LDKRoutingFees val_conv;
28275         val_conv.inner = (void*)(val & (~1));
28276         val_conv.is_owned = (val & 1) || (val == 0);
28277         val_conv = RoutingFees_clone(&val_conv);
28278         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
28279 }
28280
28281 int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
28282         LDKRouteHintHop this_ptr_conv;
28283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28284         this_ptr_conv.is_owned = false;
28285         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
28286         return ret_val;
28287 }
28288
28289 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
28290         LDKRouteHintHop this_ptr_conv;
28291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28292         this_ptr_conv.is_owned = false;
28293         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
28294 }
28295
28296 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
28297         LDKRouteHintHop this_ptr_conv;
28298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28299         this_ptr_conv.is_owned = false;
28300         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28301         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
28302         uint64_t ret_ref = (uint64_t)ret_copy;
28303         return ret_ref;
28304 }
28305
28306 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
28307         LDKRouteHintHop this_ptr_conv;
28308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28309         this_ptr_conv.is_owned = false;
28310         void* val_ptr = (void*)(((uint64_t)val) & ~1);
28311         CHECK_ACCESS(val_ptr);
28312         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28313         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
28314         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
28315 }
28316
28317 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
28318         LDKRouteHintHop this_ptr_conv;
28319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28320         this_ptr_conv.is_owned = false;
28321         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28322         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
28323         uint64_t ret_ref = (uint64_t)ret_copy;
28324         return ret_ref;
28325 }
28326
28327 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
28328         LDKRouteHintHop this_ptr_conv;
28329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28330         this_ptr_conv.is_owned = false;
28331         void* val_ptr = (void*)(((uint64_t)val) & ~1);
28332         CHECK_ACCESS(val_ptr);
28333         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28334         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
28335         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
28336 }
28337
28338 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) {
28339         LDKPublicKey src_node_id_arg_ref;
28340         CHECK(*((uint32_t*)src_node_id_arg) == 33);
28341         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
28342         LDKRoutingFees fees_arg_conv;
28343         fees_arg_conv.inner = (void*)(fees_arg & (~1));
28344         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
28345         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
28346         void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
28347         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
28348         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
28349         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
28350         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
28351         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
28352         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
28353         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
28354         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);
28355         uint64_t ret_ref = 0;
28356         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28357         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28358         ret_ref = (uint64_t)ret_var.inner;
28359         if (ret_var.is_owned) {
28360                 ret_ref |= 1;
28361         }
28362         return ret_ref;
28363 }
28364
28365 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) {
28366         LDKRouteHintHop orig_conv;
28367         orig_conv.inner = (void*)(orig & (~1));
28368         orig_conv.is_owned = false;
28369         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
28370         uint64_t ret_ref = 0;
28371         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28372         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28373         ret_ref = (uint64_t)ret_var.inner;
28374         if (ret_var.is_owned) {
28375                 ret_ref |= 1;
28376         }
28377         return ret_ref;
28378 }
28379
28380 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_hash(uint32_t o) {
28381         LDKRouteHintHop o_conv;
28382         o_conv.inner = (void*)(o & (~1));
28383         o_conv.is_owned = false;
28384         int64_t ret_val = RouteHintHop_hash(&o_conv);
28385         return ret_val;
28386 }
28387
28388 jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
28389         LDKRouteHintHop a_conv;
28390         a_conv.inner = (void*)(a & (~1));
28391         a_conv.is_owned = false;
28392         LDKRouteHintHop b_conv;
28393         b_conv.inner = (void*)(b & (~1));
28394         b_conv.is_owned = false;
28395         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
28396         return ret_val;
28397 }
28398
28399 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_write(uint32_t obj) {
28400         LDKRouteHintHop obj_conv;
28401         obj_conv.inner = (void*)(obj & (~1));
28402         obj_conv.is_owned = false;
28403         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
28404         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28405         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28406         CVec_u8Z_free(ret_var);
28407         return ret_arr;
28408 }
28409
28410 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_read(int8_tArray ser) {
28411         LDKu8slice ser_ref;
28412         ser_ref.datalen = *((uint32_t*)ser);
28413         ser_ref.data = (int8_t*)(ser + 4);
28414         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
28415         *ret_conv = RouteHintHop_read(ser_ref);
28416         return (uint64_t)ret_conv;
28417 }
28418
28419 uint32_t  __attribute__((visibility("default"))) TS_find_route(int8_tArray our_node_pubkey, uint32_t params, uint32_t network, uint32_tArray first_hops, uint32_t logger, uint32_t scorer) {
28420         LDKPublicKey our_node_pubkey_ref;
28421         CHECK(*((uint32_t*)our_node_pubkey) == 33);
28422         memcpy(our_node_pubkey_ref.compressed_form, (uint8_t*)(our_node_pubkey + 4), 33);
28423         LDKRouteParameters params_conv;
28424         params_conv.inner = (void*)(params & (~1));
28425         params_conv.is_owned = false;
28426         LDKNetworkGraph network_conv;
28427         network_conv.inner = (void*)(network & (~1));
28428         network_conv.is_owned = false;
28429         LDKCVec_ChannelDetailsZ first_hops_constr;
28430         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
28431         if (first_hops != 0) {
28432                 first_hops_constr.datalen = *((uint32_t*)first_hops);
28433                 if (first_hops_constr.datalen > 0)
28434                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28435                 else
28436                         first_hops_constr.data = NULL;
28437                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
28438                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
28439                         uint32_t first_hops_conv_16 = first_hops_vals[q];
28440                         LDKChannelDetails first_hops_conv_16_conv;
28441                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
28442                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
28443                         first_hops_constr.data[q] = first_hops_conv_16_conv;
28444                 }
28445                 first_hops_ptr = &first_hops_constr;
28446         }
28447         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
28448         CHECK_ACCESS(logger_ptr);
28449         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28450         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
28451         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
28452         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
28453         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
28454         *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
28455         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
28456         return (uint64_t)ret_conv;
28457 }
28458
28459 void  __attribute__((visibility("default"))) TS_Scorer_free(uint32_t this_obj) {
28460         LDKScorer this_obj_conv;
28461         this_obj_conv.inner = (void*)(this_obj & (~1));
28462         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28463         Scorer_free(this_obj_conv);
28464 }
28465
28466 void  __attribute__((visibility("default"))) TS_ScoringParameters_free(uint32_t this_obj) {
28467         LDKScoringParameters this_obj_conv;
28468         this_obj_conv.inner = (void*)(this_obj & (~1));
28469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28470         ScoringParameters_free(this_obj_conv);
28471 }
28472
28473 int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
28474         LDKScoringParameters this_ptr_conv;
28475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28476         this_ptr_conv.is_owned = false;
28477         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
28478         return ret_val;
28479 }
28480
28481 void  __attribute__((visibility("default"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
28482         LDKScoringParameters this_ptr_conv;
28483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28484         this_ptr_conv.is_owned = false;
28485         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
28486 }
28487
28488 int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
28489         LDKScoringParameters this_ptr_conv;
28490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28491         this_ptr_conv.is_owned = false;
28492         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
28493         return ret_val;
28494 }
28495
28496 void  __attribute__((visibility("default"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
28497         LDKScoringParameters this_ptr_conv;
28498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28499         this_ptr_conv.is_owned = false;
28500         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
28501 }
28502
28503 int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
28504         LDKScoringParameters this_ptr_conv;
28505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28506         this_ptr_conv.is_owned = false;
28507         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
28508         return ret_val;
28509 }
28510
28511 void  __attribute__((visibility("default"))) TS_ScoringParameters_set_failure_penalty_half_life(uint32_t this_ptr, int64_t val) {
28512         LDKScoringParameters this_ptr_conv;
28513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28514         this_ptr_conv.is_owned = false;
28515         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
28516 }
28517
28518 uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_new(int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int64_t failure_penalty_half_life_arg) {
28519         LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
28520         uint64_t ret_ref = 0;
28521         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28522         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28523         ret_ref = (uint64_t)ret_var.inner;
28524         if (ret_var.is_owned) {
28525                 ret_ref |= 1;
28526         }
28527         return ret_ref;
28528 }
28529
28530 int8_tArray  __attribute__((visibility("default"))) TS_ScoringParameters_write(uint32_t obj) {
28531         LDKScoringParameters obj_conv;
28532         obj_conv.inner = (void*)(obj & (~1));
28533         obj_conv.is_owned = false;
28534         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
28535         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28536         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28537         CVec_u8Z_free(ret_var);
28538         return ret_arr;
28539 }
28540
28541 uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_read(int8_tArray ser) {
28542         LDKu8slice ser_ref;
28543         ser_ref.datalen = *((uint32_t*)ser);
28544         ser_ref.data = (int8_t*)(ser + 4);
28545         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
28546         *ret_conv = ScoringParameters_read(ser_ref);
28547         return (uint64_t)ret_conv;
28548 }
28549
28550 uint32_t  __attribute__((visibility("default"))) TS_Scorer_new(uint32_t params) {
28551         LDKScoringParameters params_conv;
28552         params_conv.inner = (void*)(params & (~1));
28553         params_conv.is_owned = (params & 1) || (params == 0);
28554         // Warning: we need a move here but no clone is available for LDKScoringParameters
28555         LDKScorer ret_var = Scorer_new(params_conv);
28556         uint64_t ret_ref = 0;
28557         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28558         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28559         ret_ref = (uint64_t)ret_var.inner;
28560         if (ret_var.is_owned) {
28561                 ret_ref |= 1;
28562         }
28563         return ret_ref;
28564 }
28565
28566 uint32_t  __attribute__((visibility("default"))) TS_Scorer_default() {
28567         LDKScorer ret_var = Scorer_default();
28568         uint64_t ret_ref = 0;
28569         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28570         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28571         ret_ref = (uint64_t)ret_var.inner;
28572         if (ret_var.is_owned) {
28573                 ret_ref |= 1;
28574         }
28575         return ret_ref;
28576 }
28577
28578 uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_default() {
28579         LDKScoringParameters ret_var = ScoringParameters_default();
28580         uint64_t ret_ref = 0;
28581         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28582         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28583         ret_ref = (uint64_t)ret_var.inner;
28584         if (ret_var.is_owned) {
28585                 ret_ref |= 1;
28586         }
28587         return ret_ref;
28588 }
28589
28590 uint32_t  __attribute__((visibility("default"))) TS_Scorer_as_Score(uint32_t this_arg) {
28591         LDKScorer this_arg_conv;
28592         this_arg_conv.inner = (void*)(this_arg & (~1));
28593         this_arg_conv.is_owned = false;
28594         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
28595         *ret_ret = Scorer_as_Score(&this_arg_conv);
28596         return (uint64_t)ret_ret;
28597 }
28598
28599 int8_tArray  __attribute__((visibility("default"))) TS_Scorer_write(uint32_t obj) {
28600         LDKScorer obj_conv;
28601         obj_conv.inner = (void*)(obj & (~1));
28602         obj_conv.is_owned = false;
28603         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
28604         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28605         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28606         CVec_u8Z_free(ret_var);
28607         return ret_arr;
28608 }
28609
28610 uint32_t  __attribute__((visibility("default"))) TS_Scorer_read(int8_tArray ser) {
28611         LDKu8slice ser_ref;
28612         ser_ref.datalen = *((uint32_t*)ser);
28613         ser_ref.data = (int8_t*)(ser + 4);
28614         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
28615         *ret_conv = Scorer_read(ser_ref);
28616         return (uint64_t)ret_conv;
28617 }
28618
28619 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
28620         LDKFilesystemPersister this_obj_conv;
28621         this_obj_conv.inner = (void*)(this_obj & (~1));
28622         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28623         FilesystemPersister_free(this_obj_conv);
28624 }
28625
28626 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
28627         LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
28628         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
28629         uint64_t ret_ref = 0;
28630         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28631         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28632         ret_ref = (uint64_t)ret_var.inner;
28633         if (ret_var.is_owned) {
28634                 ret_ref |= 1;
28635         }
28636         return ret_ref;
28637 }
28638
28639 jstring  __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_dir(uint32_t this_arg) {
28640         LDKFilesystemPersister this_arg_conv;
28641         this_arg_conv.inner = (void*)(this_arg & (~1));
28642         this_arg_conv.is_owned = false;
28643         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
28644         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
28645         Str_free(ret_str);
28646         return ret_conv;
28647 }
28648
28649 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_persist_manager(jstring data_dir, uint32_t manager) {
28650         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
28651         LDKChannelManager manager_conv;
28652         manager_conv.inner = (void*)(manager & (~1));
28653         manager_conv.is_owned = false;
28654         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
28655         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
28656         return (uint64_t)ret_conv;
28657 }
28658
28659 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_channelmonitors(uint32_t this_arg, uint32_t keys_manager) {
28660         LDKFilesystemPersister this_arg_conv;
28661         this_arg_conv.inner = (void*)(this_arg & (~1));
28662         this_arg_conv.is_owned = false;
28663         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
28664         CHECK_ACCESS(keys_manager_ptr);
28665         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
28666         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
28667         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
28668         return (uint64_t)ret_conv;
28669 }
28670
28671 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persist(uint32_t this_arg) {
28672         LDKFilesystemPersister this_arg_conv;
28673         this_arg_conv.inner = (void*)(this_arg & (~1));
28674         this_arg_conv.is_owned = false;
28675         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
28676         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
28677         return (uint64_t)ret_ret;
28678 }
28679
28680 void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) {
28681         LDKBackgroundProcessor this_obj_conv;
28682         this_obj_conv.inner = (void*)(this_obj & (~1));
28683         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28684         BackgroundProcessor_free(this_obj_conv);
28685 }
28686
28687 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
28688         if ((this_ptr & 1) != 0) return;
28689         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
28690         CHECK_ACCESS(this_ptr_ptr);
28691         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
28692         FREE((void*)this_ptr);
28693         ChannelManagerPersister_free(this_ptr_conv);
28694 }
28695
28696 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) {
28697         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
28698         CHECK_ACCESS(persister_ptr);
28699         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
28700         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
28701         CHECK_ACCESS(event_handler_ptr);
28702         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
28703         LDKChainMonitor chain_monitor_conv;
28704         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
28705         chain_monitor_conv.is_owned = false;
28706         LDKChannelManager channel_manager_conv;
28707         channel_manager_conv.inner = (void*)(channel_manager & (~1));
28708         channel_manager_conv.is_owned = false;
28709         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
28710         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
28711         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
28712         LDKPeerManager peer_manager_conv;
28713         peer_manager_conv.inner = (void*)(peer_manager & (~1));
28714         peer_manager_conv.is_owned = false;
28715         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
28716         CHECK_ACCESS(logger_ptr);
28717         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28718         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);
28719         uint64_t ret_ref = 0;
28720         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28721         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28722         ret_ref = (uint64_t)ret_var.inner;
28723         if (ret_var.is_owned) {
28724                 ret_ref |= 1;
28725         }
28726         return ret_ref;
28727 }
28728
28729 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_join(uint32_t this_arg) {
28730         LDKBackgroundProcessor this_arg_conv;
28731         this_arg_conv.inner = (void*)(this_arg & (~1));
28732         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
28733         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
28734         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
28735         *ret_conv = BackgroundProcessor_join(this_arg_conv);
28736         return (uint64_t)ret_conv;
28737 }
28738
28739 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_stop(uint32_t this_arg) {
28740         LDKBackgroundProcessor this_arg_conv;
28741         this_arg_conv.inner = (void*)(this_arg & (~1));
28742         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
28743         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
28744         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
28745         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
28746         return (uint64_t)ret_conv;
28747 }
28748
28749 void  __attribute__((visibility("default"))) TS_check_platform() {
28750         check_platform();
28751 }
28752
28753 void  __attribute__((visibility("default"))) TS_Invoice_free(uint32_t this_obj) {
28754         LDKInvoice this_obj_conv;
28755         this_obj_conv.inner = (void*)(this_obj & (~1));
28756         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28757         Invoice_free(this_obj_conv);
28758 }
28759
28760 jboolean  __attribute__((visibility("default"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
28761         LDKInvoice a_conv;
28762         a_conv.inner = (void*)(a & (~1));
28763         a_conv.is_owned = false;
28764         LDKInvoice b_conv;
28765         b_conv.inner = (void*)(b & (~1));
28766         b_conv.is_owned = false;
28767         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
28768         return ret_val;
28769 }
28770
28771 uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig) {
28772         LDKInvoice orig_conv;
28773         orig_conv.inner = (void*)(orig & (~1));
28774         orig_conv.is_owned = false;
28775         LDKInvoice ret_var = Invoice_clone(&orig_conv);
28776         uint64_t ret_ref = 0;
28777         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28778         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28779         ret_ref = (uint64_t)ret_var.inner;
28780         if (ret_var.is_owned) {
28781                 ret_ref |= 1;
28782         }
28783         return ret_ref;
28784 }
28785
28786 void  __attribute__((visibility("default"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
28787         LDKSignedRawInvoice this_obj_conv;
28788         this_obj_conv.inner = (void*)(this_obj & (~1));
28789         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28790         SignedRawInvoice_free(this_obj_conv);
28791 }
28792
28793 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
28794         LDKSignedRawInvoice a_conv;
28795         a_conv.inner = (void*)(a & (~1));
28796         a_conv.is_owned = false;
28797         LDKSignedRawInvoice b_conv;
28798         b_conv.inner = (void*)(b & (~1));
28799         b_conv.is_owned = false;
28800         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
28801         return ret_val;
28802 }
28803
28804 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint32_t orig) {
28805         LDKSignedRawInvoice orig_conv;
28806         orig_conv.inner = (void*)(orig & (~1));
28807         orig_conv.is_owned = false;
28808         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
28809         uint64_t ret_ref = 0;
28810         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28811         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28812         ret_ref = (uint64_t)ret_var.inner;
28813         if (ret_var.is_owned) {
28814                 ret_ref |= 1;
28815         }
28816         return ret_ref;
28817 }
28818
28819 void  __attribute__((visibility("default"))) TS_RawInvoice_free(uint32_t this_obj) {
28820         LDKRawInvoice this_obj_conv;
28821         this_obj_conv.inner = (void*)(this_obj & (~1));
28822         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28823         RawInvoice_free(this_obj_conv);
28824 }
28825
28826 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
28827         LDKRawInvoice this_ptr_conv;
28828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28829         this_ptr_conv.is_owned = false;
28830         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
28831         uint64_t ret_ref = 0;
28832         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28833         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28834         ret_ref = (uint64_t)ret_var.inner;
28835         if (ret_var.is_owned) {
28836                 ret_ref |= 1;
28837         }
28838         return ret_ref;
28839 }
28840
28841 void  __attribute__((visibility("default"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
28842         LDKRawInvoice this_ptr_conv;
28843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28844         this_ptr_conv.is_owned = false;
28845         LDKRawDataPart val_conv;
28846         val_conv.inner = (void*)(val & (~1));
28847         val_conv.is_owned = (val & 1) || (val == 0);
28848         val_conv = RawDataPart_clone(&val_conv);
28849         RawInvoice_set_data(&this_ptr_conv, val_conv);
28850 }
28851
28852 jboolean  __attribute__((visibility("default"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
28853         LDKRawInvoice a_conv;
28854         a_conv.inner = (void*)(a & (~1));
28855         a_conv.is_owned = false;
28856         LDKRawInvoice b_conv;
28857         b_conv.inner = (void*)(b & (~1));
28858         b_conv.is_owned = false;
28859         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
28860         return ret_val;
28861 }
28862
28863 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t orig) {
28864         LDKRawInvoice orig_conv;
28865         orig_conv.inner = (void*)(orig & (~1));
28866         orig_conv.is_owned = false;
28867         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
28868         uint64_t ret_ref = 0;
28869         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28870         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28871         ret_ref = (uint64_t)ret_var.inner;
28872         if (ret_var.is_owned) {
28873                 ret_ref |= 1;
28874         }
28875         return ret_ref;
28876 }
28877
28878 void  __attribute__((visibility("default"))) TS_RawDataPart_free(uint32_t this_obj) {
28879         LDKRawDataPart this_obj_conv;
28880         this_obj_conv.inner = (void*)(this_obj & (~1));
28881         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28882         RawDataPart_free(this_obj_conv);
28883 }
28884
28885 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
28886         LDKRawDataPart this_ptr_conv;
28887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28888         this_ptr_conv.is_owned = false;
28889         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
28890         uint64_t ret_ref = 0;
28891         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28892         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28893         ret_ref = (uint64_t)ret_var.inner;
28894         if (ret_var.is_owned) {
28895                 ret_ref |= 1;
28896         }
28897         return ret_ref;
28898 }
28899
28900 void  __attribute__((visibility("default"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
28901         LDKRawDataPart this_ptr_conv;
28902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28903         this_ptr_conv.is_owned = false;
28904         LDKPositiveTimestamp val_conv;
28905         val_conv.inner = (void*)(val & (~1));
28906         val_conv.is_owned = (val & 1) || (val == 0);
28907         val_conv = PositiveTimestamp_clone(&val_conv);
28908         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
28909 }
28910
28911 jboolean  __attribute__((visibility("default"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
28912         LDKRawDataPart a_conv;
28913         a_conv.inner = (void*)(a & (~1));
28914         a_conv.is_owned = false;
28915         LDKRawDataPart b_conv;
28916         b_conv.inner = (void*)(b & (~1));
28917         b_conv.is_owned = false;
28918         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
28919         return ret_val;
28920 }
28921
28922 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t orig) {
28923         LDKRawDataPart orig_conv;
28924         orig_conv.inner = (void*)(orig & (~1));
28925         orig_conv.is_owned = false;
28926         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
28927         uint64_t ret_ref = 0;
28928         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28929         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28930         ret_ref = (uint64_t)ret_var.inner;
28931         if (ret_var.is_owned) {
28932                 ret_ref |= 1;
28933         }
28934         return ret_ref;
28935 }
28936
28937 void  __attribute__((visibility("default"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
28938         LDKPositiveTimestamp this_obj_conv;
28939         this_obj_conv.inner = (void*)(this_obj & (~1));
28940         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28941         PositiveTimestamp_free(this_obj_conv);
28942 }
28943
28944 jboolean  __attribute__((visibility("default"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
28945         LDKPositiveTimestamp a_conv;
28946         a_conv.inner = (void*)(a & (~1));
28947         a_conv.is_owned = false;
28948         LDKPositiveTimestamp b_conv;
28949         b_conv.inner = (void*)(b & (~1));
28950         b_conv.is_owned = false;
28951         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
28952         return ret_val;
28953 }
28954
28955 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint32_t orig) {
28956         LDKPositiveTimestamp orig_conv;
28957         orig_conv.inner = (void*)(orig & (~1));
28958         orig_conv.is_owned = false;
28959         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
28960         uint64_t ret_ref = 0;
28961         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28962         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28963         ret_ref = (uint64_t)ret_var.inner;
28964         if (ret_var.is_owned) {
28965                 ret_ref |= 1;
28966         }
28967         return ret_ref;
28968 }
28969
28970 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_clone(uint32_t orig) {
28971         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
28972         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
28973         return ret_conv;
28974 }
28975
28976 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_milli() {
28977         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
28978         return ret_conv;
28979 }
28980
28981 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_micro() {
28982         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
28983         return ret_conv;
28984 }
28985
28986 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_nano() {
28987         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
28988         return ret_conv;
28989 }
28990
28991 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_pico() {
28992         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
28993         return ret_conv;
28994 }
28995
28996 jboolean  __attribute__((visibility("default"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
28997         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
28998         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
28999         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
29000         return ret_val;
29001 }
29002
29003 int64_t  __attribute__((visibility("default"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
29004         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
29005         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
29006         return ret_val;
29007 }
29008
29009 uint32_t  __attribute__((visibility("default"))) TS_Currency_clone(uint32_t orig) {
29010         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
29011         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
29012         return ret_conv;
29013 }
29014
29015 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin() {
29016         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
29017         return ret_conv;
29018 }
29019
29020 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin_testnet() {
29021         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
29022         return ret_conv;
29023 }
29024
29025 uint32_t  __attribute__((visibility("default"))) TS_Currency_regtest() {
29026         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
29027         return ret_conv;
29028 }
29029
29030 uint32_t  __attribute__((visibility("default"))) TS_Currency_simnet() {
29031         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
29032         return ret_conv;
29033 }
29034
29035 uint32_t  __attribute__((visibility("default"))) TS_Currency_signet() {
29036         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
29037         return ret_conv;
29038 }
29039
29040 int64_t  __attribute__((visibility("default"))) TS_Currency_hash(uint32_t o) {
29041         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
29042         int64_t ret_val = Currency_hash(o_conv);
29043         return ret_val;
29044 }
29045
29046 jboolean  __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) {
29047         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
29048         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
29049         jboolean ret_val = Currency_eq(a_conv, b_conv);
29050         return ret_val;
29051 }
29052
29053 void  __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) {
29054         LDKSha256 this_obj_conv;
29055         this_obj_conv.inner = (void*)(this_obj & (~1));
29056         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29057         Sha256_free(this_obj_conv);
29058 }
29059
29060 uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) {
29061         LDKSha256 orig_conv;
29062         orig_conv.inner = (void*)(orig & (~1));
29063         orig_conv.is_owned = false;
29064         LDKSha256 ret_var = Sha256_clone(&orig_conv);
29065         uint64_t ret_ref = 0;
29066         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29067         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29068         ret_ref = (uint64_t)ret_var.inner;
29069         if (ret_var.is_owned) {
29070                 ret_ref |= 1;
29071         }
29072         return ret_ref;
29073 }
29074
29075 int64_t  __attribute__((visibility("default"))) TS_Sha256_hash(uint32_t o) {
29076         LDKSha256 o_conv;
29077         o_conv.inner = (void*)(o & (~1));
29078         o_conv.is_owned = false;
29079         int64_t ret_val = Sha256_hash(&o_conv);
29080         return ret_val;
29081 }
29082
29083 jboolean  __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
29084         LDKSha256 a_conv;
29085         a_conv.inner = (void*)(a & (~1));
29086         a_conv.is_owned = false;
29087         LDKSha256 b_conv;
29088         b_conv.inner = (void*)(b & (~1));
29089         b_conv.is_owned = false;
29090         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
29091         return ret_val;
29092 }
29093
29094 void  __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) {
29095         LDKDescription this_obj_conv;
29096         this_obj_conv.inner = (void*)(this_obj & (~1));
29097         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29098         Description_free(this_obj_conv);
29099 }
29100
29101 uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) {
29102         LDKDescription orig_conv;
29103         orig_conv.inner = (void*)(orig & (~1));
29104         orig_conv.is_owned = false;
29105         LDKDescription ret_var = Description_clone(&orig_conv);
29106         uint64_t ret_ref = 0;
29107         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29108         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29109         ret_ref = (uint64_t)ret_var.inner;
29110         if (ret_var.is_owned) {
29111                 ret_ref |= 1;
29112         }
29113         return ret_ref;
29114 }
29115
29116 int64_t  __attribute__((visibility("default"))) TS_Description_hash(uint32_t o) {
29117         LDKDescription o_conv;
29118         o_conv.inner = (void*)(o & (~1));
29119         o_conv.is_owned = false;
29120         int64_t ret_val = Description_hash(&o_conv);
29121         return ret_val;
29122 }
29123
29124 jboolean  __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) {
29125         LDKDescription a_conv;
29126         a_conv.inner = (void*)(a & (~1));
29127         a_conv.is_owned = false;
29128         LDKDescription b_conv;
29129         b_conv.inner = (void*)(b & (~1));
29130         b_conv.is_owned = false;
29131         jboolean ret_val = Description_eq(&a_conv, &b_conv);
29132         return ret_val;
29133 }
29134
29135 void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) {
29136         LDKPayeePubKey this_obj_conv;
29137         this_obj_conv.inner = (void*)(this_obj & (~1));
29138         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29139         PayeePubKey_free(this_obj_conv);
29140 }
29141
29142 int8_tArray  __attribute__((visibility("default"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
29143         LDKPayeePubKey this_ptr_conv;
29144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29145         this_ptr_conv.is_owned = false;
29146         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29147         memcpy((uint8_t*)(ret_arr + 4), PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
29148         return ret_arr;
29149 }
29150
29151 void  __attribute__((visibility("default"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
29152         LDKPayeePubKey this_ptr_conv;
29153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29154         this_ptr_conv.is_owned = false;
29155         LDKPublicKey val_ref;
29156         CHECK(*((uint32_t*)val) == 33);
29157         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
29158         PayeePubKey_set_a(&this_ptr_conv, val_ref);
29159 }
29160
29161 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_new(int8_tArray a_arg) {
29162         LDKPublicKey a_arg_ref;
29163         CHECK(*((uint32_t*)a_arg) == 33);
29164         memcpy(a_arg_ref.compressed_form, (uint8_t*)(a_arg + 4), 33);
29165         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
29166         uint64_t ret_ref = 0;
29167         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29168         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29169         ret_ref = (uint64_t)ret_var.inner;
29170         if (ret_var.is_owned) {
29171                 ret_ref |= 1;
29172         }
29173         return ret_ref;
29174 }
29175
29176 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) {
29177         LDKPayeePubKey orig_conv;
29178         orig_conv.inner = (void*)(orig & (~1));
29179         orig_conv.is_owned = false;
29180         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
29181         uint64_t ret_ref = 0;
29182         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29183         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29184         ret_ref = (uint64_t)ret_var.inner;
29185         if (ret_var.is_owned) {
29186                 ret_ref |= 1;
29187         }
29188         return ret_ref;
29189 }
29190
29191 int64_t  __attribute__((visibility("default"))) TS_PayeePubKey_hash(uint32_t o) {
29192         LDKPayeePubKey o_conv;
29193         o_conv.inner = (void*)(o & (~1));
29194         o_conv.is_owned = false;
29195         int64_t ret_val = PayeePubKey_hash(&o_conv);
29196         return ret_val;
29197 }
29198
29199 jboolean  __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
29200         LDKPayeePubKey a_conv;
29201         a_conv.inner = (void*)(a & (~1));
29202         a_conv.is_owned = false;
29203         LDKPayeePubKey b_conv;
29204         b_conv.inner = (void*)(b & (~1));
29205         b_conv.is_owned = false;
29206         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
29207         return ret_val;
29208 }
29209
29210 void  __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) {
29211         LDKExpiryTime this_obj_conv;
29212         this_obj_conv.inner = (void*)(this_obj & (~1));
29213         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29214         ExpiryTime_free(this_obj_conv);
29215 }
29216
29217 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) {
29218         LDKExpiryTime orig_conv;
29219         orig_conv.inner = (void*)(orig & (~1));
29220         orig_conv.is_owned = false;
29221         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
29222         uint64_t ret_ref = 0;
29223         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29224         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29225         ret_ref = (uint64_t)ret_var.inner;
29226         if (ret_var.is_owned) {
29227                 ret_ref |= 1;
29228         }
29229         return ret_ref;
29230 }
29231
29232 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_hash(uint32_t o) {
29233         LDKExpiryTime o_conv;
29234         o_conv.inner = (void*)(o & (~1));
29235         o_conv.is_owned = false;
29236         int64_t ret_val = ExpiryTime_hash(&o_conv);
29237         return ret_val;
29238 }
29239
29240 jboolean  __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
29241         LDKExpiryTime a_conv;
29242         a_conv.inner = (void*)(a & (~1));
29243         a_conv.is_owned = false;
29244         LDKExpiryTime b_conv;
29245         b_conv.inner = (void*)(b & (~1));
29246         b_conv.is_owned = false;
29247         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
29248         return ret_val;
29249 }
29250
29251 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
29252         LDKMinFinalCltvExpiry this_obj_conv;
29253         this_obj_conv.inner = (void*)(this_obj & (~1));
29254         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29255         MinFinalCltvExpiry_free(this_obj_conv);
29256 }
29257
29258 int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
29259         LDKMinFinalCltvExpiry this_ptr_conv;
29260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29261         this_ptr_conv.is_owned = false;
29262         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
29263         return ret_val;
29264 }
29265
29266 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
29267         LDKMinFinalCltvExpiry this_ptr_conv;
29268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29269         this_ptr_conv.is_owned = false;
29270         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
29271 }
29272
29273 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
29274         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
29275         uint64_t ret_ref = 0;
29276         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29277         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29278         ret_ref = (uint64_t)ret_var.inner;
29279         if (ret_var.is_owned) {
29280                 ret_ref |= 1;
29281         }
29282         return ret_ref;
29283 }
29284
29285 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
29286         LDKMinFinalCltvExpiry orig_conv;
29287         orig_conv.inner = (void*)(orig & (~1));
29288         orig_conv.is_owned = false;
29289         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
29290         uint64_t ret_ref = 0;
29291         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29292         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29293         ret_ref = (uint64_t)ret_var.inner;
29294         if (ret_var.is_owned) {
29295                 ret_ref |= 1;
29296         }
29297         return ret_ref;
29298 }
29299
29300 int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
29301         LDKMinFinalCltvExpiry o_conv;
29302         o_conv.inner = (void*)(o & (~1));
29303         o_conv.is_owned = false;
29304         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
29305         return ret_val;
29306 }
29307
29308 jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
29309         LDKMinFinalCltvExpiry a_conv;
29310         a_conv.inner = (void*)(a & (~1));
29311         a_conv.is_owned = false;
29312         LDKMinFinalCltvExpiry b_conv;
29313         b_conv.inner = (void*)(b & (~1));
29314         b_conv.is_owned = false;
29315         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
29316         return ret_val;
29317 }
29318
29319 void  __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) {
29320         if ((this_ptr & 1) != 0) return;
29321         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
29322         CHECK_ACCESS(this_ptr_ptr);
29323         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
29324         FREE((void*)this_ptr);
29325         Fallback_free(this_ptr_conv);
29326 }
29327
29328 uint32_t  __attribute__((visibility("default"))) TS_Fallback_clone(uint32_t orig) {
29329         LDKFallback* orig_conv = (LDKFallback*)orig;
29330         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
29331         *ret_copy = Fallback_clone(orig_conv);
29332         uint64_t ret_ref = (uint64_t)ret_copy;
29333         return ret_ref;
29334 }
29335
29336 uint32_t  __attribute__((visibility("default"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
29337         
29338         LDKCVec_u8Z program_ref;
29339         program_ref.datalen = *((uint32_t*)program);
29340         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
29341         memcpy(program_ref.data, (uint8_t*)(program + 4), program_ref.datalen);
29342         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
29343         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
29344         uint64_t ret_ref = (uint64_t)ret_copy;
29345         return ret_ref;
29346 }
29347
29348 uint32_t  __attribute__((visibility("default"))) TS_Fallback_pub_key_hash(int8_tArray a) {
29349         LDKTwentyBytes a_ref;
29350         CHECK(*((uint32_t*)a) == 20);
29351         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
29352         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
29353         *ret_copy = Fallback_pub_key_hash(a_ref);
29354         uint64_t ret_ref = (uint64_t)ret_copy;
29355         return ret_ref;
29356 }
29357
29358 uint32_t  __attribute__((visibility("default"))) TS_Fallback_script_hash(int8_tArray a) {
29359         LDKTwentyBytes a_ref;
29360         CHECK(*((uint32_t*)a) == 20);
29361         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
29362         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
29363         *ret_copy = Fallback_script_hash(a_ref);
29364         uint64_t ret_ref = (uint64_t)ret_copy;
29365         return ret_ref;
29366 }
29367
29368 int64_t  __attribute__((visibility("default"))) TS_Fallback_hash(uint32_t o) {
29369         LDKFallback* o_conv = (LDKFallback*)o;
29370         int64_t ret_val = Fallback_hash(o_conv);
29371         return ret_val;
29372 }
29373
29374 jboolean  __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
29375         LDKFallback* a_conv = (LDKFallback*)a;
29376         LDKFallback* b_conv = (LDKFallback*)b;
29377         jboolean ret_val = Fallback_eq(a_conv, b_conv);
29378         return ret_val;
29379 }
29380
29381 void  __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t this_obj) {
29382         LDKInvoiceSignature this_obj_conv;
29383         this_obj_conv.inner = (void*)(this_obj & (~1));
29384         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29385         InvoiceSignature_free(this_obj_conv);
29386 }
29387
29388 uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) {
29389         LDKInvoiceSignature orig_conv;
29390         orig_conv.inner = (void*)(orig & (~1));
29391         orig_conv.is_owned = false;
29392         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
29393         uint64_t ret_ref = 0;
29394         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29395         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29396         ret_ref = (uint64_t)ret_var.inner;
29397         if (ret_var.is_owned) {
29398                 ret_ref |= 1;
29399         }
29400         return ret_ref;
29401 }
29402
29403 jboolean  __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
29404         LDKInvoiceSignature a_conv;
29405         a_conv.inner = (void*)(a & (~1));
29406         a_conv.is_owned = false;
29407         LDKInvoiceSignature b_conv;
29408         b_conv.inner = (void*)(b & (~1));
29409         b_conv.is_owned = false;
29410         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
29411         return ret_val;
29412 }
29413
29414 void  __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) {
29415         LDKPrivateRoute this_obj_conv;
29416         this_obj_conv.inner = (void*)(this_obj & (~1));
29417         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29418         PrivateRoute_free(this_obj_conv);
29419 }
29420
29421 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) {
29422         LDKPrivateRoute orig_conv;
29423         orig_conv.inner = (void*)(orig & (~1));
29424         orig_conv.is_owned = false;
29425         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
29426         uint64_t ret_ref = 0;
29427         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29428         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29429         ret_ref = (uint64_t)ret_var.inner;
29430         if (ret_var.is_owned) {
29431                 ret_ref |= 1;
29432         }
29433         return ret_ref;
29434 }
29435
29436 int64_t  __attribute__((visibility("default"))) TS_PrivateRoute_hash(uint32_t o) {
29437         LDKPrivateRoute o_conv;
29438         o_conv.inner = (void*)(o & (~1));
29439         o_conv.is_owned = false;
29440         int64_t ret_val = PrivateRoute_hash(&o_conv);
29441         return ret_val;
29442 }
29443
29444 jboolean  __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
29445         LDKPrivateRoute a_conv;
29446         a_conv.inner = (void*)(a & (~1));
29447         a_conv.is_owned = false;
29448         LDKPrivateRoute b_conv;
29449         b_conv.inner = (void*)(b & (~1));
29450         b_conv.is_owned = false;
29451         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
29452         return ret_val;
29453 }
29454
29455 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
29456         LDKSignedRawInvoice this_arg_conv;
29457         this_arg_conv.inner = (void*)(this_arg & (~1));
29458         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
29459         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
29460         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
29461         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
29462         return ((uint64_t)ret_conv);
29463 }
29464
29465 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
29466         LDKSignedRawInvoice this_arg_conv;
29467         this_arg_conv.inner = (void*)(this_arg & (~1));
29468         this_arg_conv.is_owned = false;
29469         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
29470         uint64_t ret_ref = 0;
29471         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29472         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29473         ret_ref = (uint64_t)ret_var.inner;
29474         if (ret_var.is_owned) {
29475                 ret_ref |= 1;
29476         }
29477         return ret_ref;
29478 }
29479
29480 int8_tArray  __attribute__((visibility("default"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
29481         LDKSignedRawInvoice this_arg_conv;
29482         this_arg_conv.inner = (void*)(this_arg & (~1));
29483         this_arg_conv.is_owned = false;
29484         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
29485         memcpy((uint8_t*)(ret_arr + 4), *SignedRawInvoice_hash(&this_arg_conv), 32);
29486         return ret_arr;
29487 }
29488
29489 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
29490         LDKSignedRawInvoice this_arg_conv;
29491         this_arg_conv.inner = (void*)(this_arg & (~1));
29492         this_arg_conv.is_owned = false;
29493         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
29494         uint64_t ret_ref = 0;
29495         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29496         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29497         ret_ref = (uint64_t)ret_var.inner;
29498         if (ret_var.is_owned) {
29499                 ret_ref |= 1;
29500         }
29501         return ret_ref;
29502 }
29503
29504 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
29505         LDKSignedRawInvoice this_arg_conv;
29506         this_arg_conv.inner = (void*)(this_arg & (~1));
29507         this_arg_conv.is_owned = false;
29508         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
29509         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
29510         return (uint64_t)ret_conv;
29511 }
29512
29513 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
29514         LDKSignedRawInvoice this_arg_conv;
29515         this_arg_conv.inner = (void*)(this_arg & (~1));
29516         this_arg_conv.is_owned = false;
29517         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
29518         return ret_val;
29519 }
29520
29521 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_hash(uint32_t this_arg) {
29522         LDKRawInvoice this_arg_conv;
29523         this_arg_conv.inner = (void*)(this_arg & (~1));
29524         this_arg_conv.is_owned = false;
29525         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
29526         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_hash(&this_arg_conv).data, 32);
29527         return ret_arr;
29528 }
29529
29530 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
29531         LDKRawInvoice this_arg_conv;
29532         this_arg_conv.inner = (void*)(this_arg & (~1));
29533         this_arg_conv.is_owned = false;
29534         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
29535         uint64_t ret_ref = 0;
29536         if ((uint64_t)ret_var.inner > 4096) {
29537                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29538                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29539                 ret_ref = (uint64_t)ret_var.inner;
29540                 if (ret_var.is_owned) {
29541                         ret_ref |= 1;
29542                 }
29543         }
29544         return ret_ref;
29545 }
29546
29547 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint32_t this_arg) {
29548         LDKRawInvoice this_arg_conv;
29549         this_arg_conv.inner = (void*)(this_arg & (~1));
29550         this_arg_conv.is_owned = false;
29551         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
29552         uint64_t ret_ref = 0;
29553         if ((uint64_t)ret_var.inner > 4096) {
29554                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29555                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29556                 ret_ref = (uint64_t)ret_var.inner;
29557                 if (ret_var.is_owned) {
29558                         ret_ref |= 1;
29559                 }
29560         }
29561         return ret_ref;
29562 }
29563
29564 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
29565         LDKRawInvoice this_arg_conv;
29566         this_arg_conv.inner = (void*)(this_arg & (~1));
29567         this_arg_conv.is_owned = false;
29568         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
29569         uint64_t ret_ref = 0;
29570         if ((uint64_t)ret_var.inner > 4096) {
29571                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29572                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29573                 ret_ref = (uint64_t)ret_var.inner;
29574                 if (ret_var.is_owned) {
29575                         ret_ref |= 1;
29576                 }
29577         }
29578         return ret_ref;
29579 }
29580
29581 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
29582         LDKRawInvoice this_arg_conv;
29583         this_arg_conv.inner = (void*)(this_arg & (~1));
29584         this_arg_conv.is_owned = false;
29585         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
29586         uint64_t ret_ref = 0;
29587         if ((uint64_t)ret_var.inner > 4096) {
29588                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29589                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29590                 ret_ref = (uint64_t)ret_var.inner;
29591                 if (ret_var.is_owned) {
29592                         ret_ref |= 1;
29593                 }
29594         }
29595         return ret_ref;
29596 }
29597
29598 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
29599         LDKRawInvoice this_arg_conv;
29600         this_arg_conv.inner = (void*)(this_arg & (~1));
29601         this_arg_conv.is_owned = false;
29602         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
29603         uint64_t ret_ref = 0;
29604         if ((uint64_t)ret_var.inner > 4096) {
29605                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29606                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29607                 ret_ref = (uint64_t)ret_var.inner;
29608                 if (ret_var.is_owned) {
29609                         ret_ref |= 1;
29610                 }
29611         }
29612         return ret_ref;
29613 }
29614
29615 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
29616         LDKRawInvoice this_arg_conv;
29617         this_arg_conv.inner = (void*)(this_arg & (~1));
29618         this_arg_conv.is_owned = false;
29619         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
29620         uint64_t ret_ref = 0;
29621         if ((uint64_t)ret_var.inner > 4096) {
29622                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29623                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29624                 ret_ref = (uint64_t)ret_var.inner;
29625                 if (ret_var.is_owned) {
29626                         ret_ref |= 1;
29627                 }
29628         }
29629         return ret_ref;
29630 }
29631
29632 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
29633         LDKRawInvoice this_arg_conv;
29634         this_arg_conv.inner = (void*)(this_arg & (~1));
29635         this_arg_conv.is_owned = false;
29636         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
29637         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_payment_secret(&this_arg_conv).data, 32);
29638         return ret_arr;
29639 }
29640
29641 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t this_arg) {
29642         LDKRawInvoice this_arg_conv;
29643         this_arg_conv.inner = (void*)(this_arg & (~1));
29644         this_arg_conv.is_owned = false;
29645         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
29646         uint64_t ret_ref = 0;
29647         if ((uint64_t)ret_var.inner > 4096) {
29648                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29649                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29650                 ret_ref = (uint64_t)ret_var.inner;
29651                 if (ret_var.is_owned) {
29652                         ret_ref |= 1;
29653                 }
29654         }
29655         return ret_ref;
29656 }
29657
29658 uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
29659         LDKRawInvoice this_arg_conv;
29660         this_arg_conv.inner = (void*)(this_arg & (~1));
29661         this_arg_conv.is_owned = false;
29662         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
29663         uint32_tArray ret_arr = NULL;
29664         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
29665         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
29666         for (size_t o = 0; o < ret_var.datalen; o++) {
29667                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
29668                 uint64_t ret_conv_14_ref = 0;
29669                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29670                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29671                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
29672                 if (ret_conv_14_var.is_owned) {
29673                         ret_conv_14_ref |= 1;
29674                 }
29675                 ret_arr_ptr[o] = ret_conv_14_ref;
29676         }
29677         
29678         FREE(ret_var.data);
29679         return ret_arr;
29680 }
29681
29682 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
29683         LDKRawInvoice this_arg_conv;
29684         this_arg_conv.inner = (void*)(this_arg & (~1));
29685         this_arg_conv.is_owned = false;
29686         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29687         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
29688         uint64_t ret_ref = (uint64_t)ret_copy;
29689         return ret_ref;
29690 }
29691
29692 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_currency(uint32_t this_arg) {
29693         LDKRawInvoice this_arg_conv;
29694         this_arg_conv.inner = (void*)(this_arg & (~1));
29695         this_arg_conv.is_owned = false;
29696         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
29697         return ret_conv;
29698 }
29699
29700 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
29701         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
29702         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
29703         return (uint64_t)ret_conv;
29704 }
29705
29706 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_system_time(int64_t time) {
29707         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
29708         *ret_conv = PositiveTimestamp_from_system_time(time);
29709         return (uint64_t)ret_conv;
29710 }
29711
29712 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
29713         LDKPositiveTimestamp this_arg_conv;
29714         this_arg_conv.inner = (void*)(this_arg & (~1));
29715         this_arg_conv.is_owned = false;
29716         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
29717         return ret_val;
29718 }
29719
29720 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_time(uint32_t this_arg) {
29721         LDKPositiveTimestamp this_arg_conv;
29722         this_arg_conv.inner = (void*)(this_arg & (~1));
29723         this_arg_conv.is_owned = false;
29724         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
29725         return ret_val;
29726 }
29727
29728 uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
29729         LDKInvoice this_arg_conv;
29730         this_arg_conv.inner = (void*)(this_arg & (~1));
29731         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
29732         this_arg_conv = Invoice_clone(&this_arg_conv);
29733         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
29734         uint64_t ret_ref = 0;
29735         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29736         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29737         ret_ref = (uint64_t)ret_var.inner;
29738         if (ret_var.is_owned) {
29739                 ret_ref |= 1;
29740         }
29741         return ret_ref;
29742 }
29743
29744 uint32_t  __attribute__((visibility("default"))) TS_Invoice_check_signature(uint32_t this_arg) {
29745         LDKInvoice this_arg_conv;
29746         this_arg_conv.inner = (void*)(this_arg & (~1));
29747         this_arg_conv.is_owned = false;
29748         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
29749         *ret_conv = Invoice_check_signature(&this_arg_conv);
29750         return (uint64_t)ret_conv;
29751 }
29752
29753 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
29754         LDKSignedRawInvoice signed_invoice_conv;
29755         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
29756         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
29757         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
29758         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
29759         *ret_conv = Invoice_from_signed(signed_invoice_conv);
29760         return (uint64_t)ret_conv;
29761 }
29762
29763 int64_t  __attribute__((visibility("default"))) TS_Invoice_timestamp(uint32_t this_arg) {
29764         LDKInvoice this_arg_conv;
29765         this_arg_conv.inner = (void*)(this_arg & (~1));
29766         this_arg_conv.is_owned = false;
29767         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
29768         return ret_val;
29769 }
29770
29771 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_hash(uint32_t this_arg) {
29772         LDKInvoice this_arg_conv;
29773         this_arg_conv.inner = (void*)(this_arg & (~1));
29774         this_arg_conv.is_owned = false;
29775         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
29776         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_hash(&this_arg_conv), 32);
29777         return ret_arr;
29778 }
29779
29780 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
29781         LDKInvoice this_arg_conv;
29782         this_arg_conv.inner = (void*)(this_arg & (~1));
29783         this_arg_conv.is_owned = false;
29784         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29785         memcpy((uint8_t*)(ret_arr + 4), Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
29786         return ret_arr;
29787 }
29788
29789 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(uint32_t this_arg) {
29790         LDKInvoice this_arg_conv;
29791         this_arg_conv.inner = (void*)(this_arg & (~1));
29792         this_arg_conv.is_owned = false;
29793         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
29794         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_secret(&this_arg_conv), 32);
29795         return ret_arr;
29796 }
29797
29798 uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t this_arg) {
29799         LDKInvoice this_arg_conv;
29800         this_arg_conv.inner = (void*)(this_arg & (~1));
29801         this_arg_conv.is_owned = false;
29802         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
29803         uint64_t ret_ref = 0;
29804         if ((uint64_t)ret_var.inner > 4096) {
29805                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29806                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29807                 ret_ref = (uint64_t)ret_var.inner;
29808                 if (ret_var.is_owned) {
29809                         ret_ref |= 1;
29810                 }
29811         }
29812         return ret_ref;
29813 }
29814
29815 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
29816         LDKInvoice this_arg_conv;
29817         this_arg_conv.inner = (void*)(this_arg & (~1));
29818         this_arg_conv.is_owned = false;
29819         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29820         memcpy((uint8_t*)(ret_arr + 4), Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
29821         return ret_arr;
29822 }
29823
29824 int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t this_arg) {
29825         LDKInvoice this_arg_conv;
29826         this_arg_conv.inner = (void*)(this_arg & (~1));
29827         this_arg_conv.is_owned = false;
29828         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
29829         return ret_val;
29830 }
29831
29832 jboolean  __attribute__((visibility("default"))) TS_Invoice_is_expired(uint32_t this_arg) {
29833         LDKInvoice this_arg_conv;
29834         this_arg_conv.inner = (void*)(this_arg & (~1));
29835         this_arg_conv.is_owned = false;
29836         jboolean ret_val = Invoice_is_expired(&this_arg_conv);
29837         return ret_val;
29838 }
29839
29840 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
29841         LDKInvoice this_arg_conv;
29842         this_arg_conv.inner = (void*)(this_arg & (~1));
29843         this_arg_conv.is_owned = false;
29844         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
29845         return ret_val;
29846 }
29847
29848 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(uint32_t this_arg) {
29849         LDKInvoice this_arg_conv;
29850         this_arg_conv.inner = (void*)(this_arg & (~1));
29851         this_arg_conv.is_owned = false;
29852         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
29853         uint32_tArray ret_arr = NULL;
29854         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
29855         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
29856         for (size_t o = 0; o < ret_var.datalen; o++) {
29857                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
29858                 uint64_t ret_conv_14_ref = 0;
29859                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29860                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29861                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
29862                 if (ret_conv_14_var.is_owned) {
29863                         ret_conv_14_ref |= 1;
29864                 }
29865                 ret_arr_ptr[o] = ret_conv_14_ref;
29866         }
29867         
29868         FREE(ret_var.data);
29869         return ret_arr;
29870 }
29871
29872 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uint32_t this_arg) {
29873         LDKInvoice this_arg_conv;
29874         this_arg_conv.inner = (void*)(this_arg & (~1));
29875         this_arg_conv.is_owned = false;
29876         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
29877         uint32_tArray ret_arr = NULL;
29878         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
29879         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
29880         for (size_t l = 0; l < ret_var.datalen; l++) {
29881                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
29882                 uint64_t ret_conv_11_ref = 0;
29883                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29884                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29885                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
29886                 if (ret_conv_11_var.is_owned) {
29887                         ret_conv_11_ref |= 1;
29888                 }
29889                 ret_arr_ptr[l] = ret_conv_11_ref;
29890         }
29891         
29892         FREE(ret_var.data);
29893         return ret_arr;
29894 }
29895
29896 uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t this_arg) {
29897         LDKInvoice this_arg_conv;
29898         this_arg_conv.inner = (void*)(this_arg & (~1));
29899         this_arg_conv.is_owned = false;
29900         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
29901         return ret_conv;
29902 }
29903
29904 uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
29905         LDKInvoice this_arg_conv;
29906         this_arg_conv.inner = (void*)(this_arg & (~1));
29907         this_arg_conv.is_owned = false;
29908         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29909         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
29910         uint64_t ret_ref = (uint64_t)ret_copy;
29911         return ret_ref;
29912 }
29913
29914 uint32_t  __attribute__((visibility("default"))) TS_Description_new(jstring description) {
29915         LDKStr description_conv = str_ref_to_owned_c(description);
29916         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
29917         *ret_conv = Description_new(description_conv);
29918         return (uint64_t)ret_conv;
29919 }
29920
29921 jstring  __attribute__((visibility("default"))) TS_Description_into_inner(uint32_t this_arg) {
29922         LDKDescription this_arg_conv;
29923         this_arg_conv.inner = (void*)(this_arg & (~1));
29924         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
29925         this_arg_conv = Description_clone(&this_arg_conv);
29926         LDKStr ret_str = Description_into_inner(this_arg_conv);
29927         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
29928         Str_free(ret_str);
29929         return ret_conv;
29930 }
29931
29932 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
29933         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
29934         *ret_conv = ExpiryTime_from_seconds(seconds);
29935         return (uint64_t)ret_conv;
29936 }
29937
29938 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_duration(int64_t duration) {
29939         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
29940         *ret_conv = ExpiryTime_from_duration(duration);
29941         return (uint64_t)ret_conv;
29942 }
29943
29944 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
29945         LDKExpiryTime this_arg_conv;
29946         this_arg_conv.inner = (void*)(this_arg & (~1));
29947         this_arg_conv.is_owned = false;
29948         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
29949         return ret_val;
29950 }
29951
29952 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
29953         LDKExpiryTime this_arg_conv;
29954         this_arg_conv.inner = (void*)(this_arg & (~1));
29955         this_arg_conv.is_owned = false;
29956         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
29957         return ret_val;
29958 }
29959
29960 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_new(uint32_t hops) {
29961         LDKRouteHint hops_conv;
29962         hops_conv.inner = (void*)(hops & (~1));
29963         hops_conv.is_owned = (hops & 1) || (hops == 0);
29964         hops_conv = RouteHint_clone(&hops_conv);
29965         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
29966         *ret_conv = PrivateRoute_new(hops_conv);
29967         return (uint64_t)ret_conv;
29968 }
29969
29970 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
29971         LDKPrivateRoute this_arg_conv;
29972         this_arg_conv.inner = (void*)(this_arg & (~1));
29973         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
29974         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
29975         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
29976         uint64_t ret_ref = 0;
29977         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29978         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29979         ret_ref = (uint64_t)ret_var.inner;
29980         if (ret_var.is_owned) {
29981                 ret_ref |= 1;
29982         }
29983         return ret_ref;
29984 }
29985
29986 uint32_t  __attribute__((visibility("default"))) TS_CreationError_clone(uint32_t orig) {
29987         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
29988         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
29989         return ret_conv;
29990 }
29991
29992 uint32_t  __attribute__((visibility("default"))) TS_CreationError_description_too_long() {
29993         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
29994         return ret_conv;
29995 }
29996
29997 uint32_t  __attribute__((visibility("default"))) TS_CreationError_route_too_long() {
29998         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
29999         return ret_conv;
30000 }
30001
30002 uint32_t  __attribute__((visibility("default"))) TS_CreationError_timestamp_out_of_bounds() {
30003         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
30004         return ret_conv;
30005 }
30006
30007 uint32_t  __attribute__((visibility("default"))) TS_CreationError_expiry_time_out_of_bounds() {
30008         uint32_t ret_conv = LDKCreationError_to_js(CreationError_expiry_time_out_of_bounds());
30009         return ret_conv;
30010 }
30011
30012 jboolean  __attribute__((visibility("default"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
30013         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
30014         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
30015         jboolean ret_val = CreationError_eq(a_conv, b_conv);
30016         return ret_val;
30017 }
30018
30019 jstring  __attribute__((visibility("default"))) TS_CreationError_to_str(uint32_t o) {
30020         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
30021         LDKStr ret_str = CreationError_to_str(o_conv);
30022         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
30023         Str_free(ret_str);
30024         return ret_conv;
30025 }
30026
30027 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_clone(uint32_t orig) {
30028         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
30029         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
30030         return ret_conv;
30031 }
30032
30033 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_hash() {
30034         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
30035         return ret_conv;
30036 }
30037
30038 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_hashes() {
30039         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
30040         return ret_conv;
30041 }
30042
30043 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_description() {
30044         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
30045         return ret_conv;
30046 }
30047
30048 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_descriptions() {
30049         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
30050         return ret_conv;
30051 }
30052
30053 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_secret() {
30054         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
30055         return ret_conv;
30056 }
30057
30058 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_secrets() {
30059         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
30060         return ret_conv;
30061 }
30062
30063 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_features() {
30064         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
30065         return ret_conv;
30066 }
30067
30068 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_recovery_id() {
30069         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
30070         return ret_conv;
30071 }
30072
30073 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_signature() {
30074         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
30075         return ret_conv;
30076 }
30077
30078 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_imprecise_amount() {
30079         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
30080         return ret_conv;
30081 }
30082
30083 jboolean  __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
30084         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
30085         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
30086         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
30087         return ret_val;
30088 }
30089
30090 jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t o) {
30091         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
30092         LDKStr ret_str = SemanticError_to_str(o_conv);
30093         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
30094         Str_free(ret_str);
30095         return ret_conv;
30096 }
30097
30098 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
30099         if ((this_ptr & 1) != 0) return;
30100         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
30101         CHECK_ACCESS(this_ptr_ptr);
30102         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
30103         FREE((void*)this_ptr);
30104         SignOrCreationError_free(this_ptr_conv);
30105 }
30106
30107 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone(uint32_t orig) {
30108         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
30109         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
30110         *ret_copy = SignOrCreationError_clone(orig_conv);
30111         uint64_t ret_ref = (uint64_t)ret_copy;
30112         return ret_ref;
30113 }
30114
30115 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_sign_error() {
30116         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
30117         *ret_copy = SignOrCreationError_sign_error();
30118         uint64_t ret_ref = (uint64_t)ret_copy;
30119         return ret_ref;
30120 }
30121
30122 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_creation_error(uint32_t a) {
30123         LDKCreationError a_conv = LDKCreationError_from_js(a);
30124         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
30125         *ret_copy = SignOrCreationError_creation_error(a_conv);
30126         uint64_t ret_ref = (uint64_t)ret_copy;
30127         return ret_ref;
30128 }
30129
30130 jboolean  __attribute__((visibility("default"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
30131         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
30132         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
30133         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
30134         return ret_val;
30135 }
30136
30137 jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(uint32_t o) {
30138         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
30139         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
30140         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
30141         Str_free(ret_str);
30142         return ret_conv;
30143 }
30144
30145 void  __attribute__((visibility("default"))) TS_InvoicePayer_free(uint32_t this_obj) {
30146         LDKInvoicePayer this_obj_conv;
30147         this_obj_conv.inner = (void*)(this_obj & (~1));
30148         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30149         InvoicePayer_free(this_obj_conv);
30150 }
30151
30152 void  __attribute__((visibility("default"))) TS_Payer_free(uint32_t this_ptr) {
30153         if ((this_ptr & 1) != 0) return;
30154         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
30155         CHECK_ACCESS(this_ptr_ptr);
30156         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
30157         FREE((void*)this_ptr);
30158         Payer_free(this_ptr_conv);
30159 }
30160
30161 void  __attribute__((visibility("default"))) TS_Router_free(uint32_t this_ptr) {
30162         if ((this_ptr & 1) != 0) return;
30163         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
30164         CHECK_ACCESS(this_ptr_ptr);
30165         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
30166         FREE((void*)this_ptr);
30167         Router_free(this_ptr_conv);
30168 }
30169
30170 void  __attribute__((visibility("default"))) TS_RetryAttempts_free(uint32_t this_obj) {
30171         LDKRetryAttempts this_obj_conv;
30172         this_obj_conv.inner = (void*)(this_obj & (~1));
30173         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30174         RetryAttempts_free(this_obj_conv);
30175 }
30176
30177 int64_t  __attribute__((visibility("default"))) TS_RetryAttempts_get_a(uint32_t this_ptr) {
30178         LDKRetryAttempts this_ptr_conv;
30179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30180         this_ptr_conv.is_owned = false;
30181         int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
30182         return ret_val;
30183 }
30184
30185 void  __attribute__((visibility("default"))) TS_RetryAttempts_set_a(uint32_t this_ptr, int64_t val) {
30186         LDKRetryAttempts this_ptr_conv;
30187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30188         this_ptr_conv.is_owned = false;
30189         RetryAttempts_set_a(&this_ptr_conv, val);
30190 }
30191
30192 uint32_t  __attribute__((visibility("default"))) TS_RetryAttempts_new(int64_t a_arg) {
30193         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
30194         uint64_t ret_ref = 0;
30195         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30196         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30197         ret_ref = (uint64_t)ret_var.inner;
30198         if (ret_var.is_owned) {
30199                 ret_ref |= 1;
30200         }
30201         return ret_ref;
30202 }
30203
30204 uint32_t  __attribute__((visibility("default"))) TS_RetryAttempts_clone(uint32_t orig) {
30205         LDKRetryAttempts orig_conv;
30206         orig_conv.inner = (void*)(orig & (~1));
30207         orig_conv.is_owned = false;
30208         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
30209         uint64_t ret_ref = 0;
30210         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30211         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30212         ret_ref = (uint64_t)ret_var.inner;
30213         if (ret_var.is_owned) {
30214                 ret_ref |= 1;
30215         }
30216         return ret_ref;
30217 }
30218
30219 jboolean  __attribute__((visibility("default"))) TS_RetryAttempts_eq(uint32_t a, uint32_t b) {
30220         LDKRetryAttempts a_conv;
30221         a_conv.inner = (void*)(a & (~1));
30222         a_conv.is_owned = false;
30223         LDKRetryAttempts b_conv;
30224         b_conv.inner = (void*)(b & (~1));
30225         b_conv.is_owned = false;
30226         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
30227         return ret_val;
30228 }
30229
30230 int64_t  __attribute__((visibility("default"))) TS_RetryAttempts_hash(uint32_t o) {
30231         LDKRetryAttempts o_conv;
30232         o_conv.inner = (void*)(o & (~1));
30233         o_conv.is_owned = false;
30234         int64_t ret_val = RetryAttempts_hash(&o_conv);
30235         return ret_val;
30236 }
30237
30238 void  __attribute__((visibility("default"))) TS_PaymentError_free(uint32_t this_ptr) {
30239         if ((this_ptr & 1) != 0) return;
30240         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
30241         CHECK_ACCESS(this_ptr_ptr);
30242         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
30243         FREE((void*)this_ptr);
30244         PaymentError_free(this_ptr_conv);
30245 }
30246
30247 uint32_t  __attribute__((visibility("default"))) TS_PaymentError_clone(uint32_t orig) {
30248         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
30249         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
30250         *ret_copy = PaymentError_clone(orig_conv);
30251         uint64_t ret_ref = (uint64_t)ret_copy;
30252         return ret_ref;
30253 }
30254
30255 uint32_t  __attribute__((visibility("default"))) TS_PaymentError_invoice(jstring a) {
30256         LDKStr a_conv = str_ref_to_owned_c(a);
30257         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
30258         *ret_copy = PaymentError_invoice(a_conv);
30259         uint64_t ret_ref = (uint64_t)ret_copy;
30260         return ret_ref;
30261 }
30262
30263 uint32_t  __attribute__((visibility("default"))) TS_PaymentError_routing(uint32_t a) {
30264         LDKLightningError a_conv;
30265         a_conv.inner = (void*)(a & (~1));
30266         a_conv.is_owned = (a & 1) || (a == 0);
30267         a_conv = LightningError_clone(&a_conv);
30268         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
30269         *ret_copy = PaymentError_routing(a_conv);
30270         uint64_t ret_ref = (uint64_t)ret_copy;
30271         return ret_ref;
30272 }
30273
30274 uint32_t  __attribute__((visibility("default"))) TS_PaymentError_sending(uint32_t a) {
30275         void* a_ptr = (void*)(((uint64_t)a) & ~1);
30276         CHECK_ACCESS(a_ptr);
30277         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
30278         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)a) & ~1));
30279         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
30280         *ret_copy = PaymentError_sending(a_conv);
30281         uint64_t ret_ref = (uint64_t)ret_copy;
30282         return ret_ref;
30283 }
30284
30285 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_new(uint32_t payer, uint32_t router, uint32_t scorer, uint32_t logger, uint32_t event_handler, uint32_t retry_attempts) {
30286         void* payer_ptr = (void*)(((uint64_t)payer) & ~1);
30287         CHECK_ACCESS(payer_ptr);
30288         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
30289         void* router_ptr = (void*)(((uint64_t)router) & ~1);
30290         CHECK_ACCESS(router_ptr);
30291         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
30292         LDKLockableScore scorer_conv;
30293         scorer_conv.inner = (void*)(scorer & (~1));
30294         scorer_conv.is_owned = false;
30295         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
30296         CHECK_ACCESS(logger_ptr);
30297         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30298         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
30299         CHECK_ACCESS(event_handler_ptr);
30300         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
30301         LDKRetryAttempts retry_attempts_conv;
30302         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
30303         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
30304         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
30305         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
30306         uint64_t ret_ref = 0;
30307         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30308         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30309         ret_ref = (uint64_t)ret_var.inner;
30310         if (ret_var.is_owned) {
30311                 ret_ref |= 1;
30312         }
30313         return ret_ref;
30314 }
30315
30316 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
30317         LDKInvoicePayer this_arg_conv;
30318         this_arg_conv.inner = (void*)(this_arg & (~1));
30319         this_arg_conv.is_owned = false;
30320         LDKInvoice invoice_conv;
30321         invoice_conv.inner = (void*)(invoice & (~1));
30322         invoice_conv.is_owned = false;
30323         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
30324         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
30325         return (uint64_t)ret_conv;
30326 }
30327
30328 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_pay_zero_value_invoice(uint32_t this_arg, uint32_t invoice, int64_t amount_msats) {
30329         LDKInvoicePayer this_arg_conv;
30330         this_arg_conv.inner = (void*)(this_arg & (~1));
30331         this_arg_conv.is_owned = false;
30332         LDKInvoice invoice_conv;
30333         invoice_conv.inner = (void*)(invoice & (~1));
30334         invoice_conv.is_owned = false;
30335         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
30336         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
30337         return (uint64_t)ret_conv;
30338 }
30339
30340 void  __attribute__((visibility("default"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
30341         LDKInvoicePayer this_arg_conv;
30342         this_arg_conv.inner = (void*)(this_arg & (~1));
30343         this_arg_conv.is_owned = false;
30344         unsigned char payment_hash_arr[32];
30345         CHECK(*((uint32_t*)payment_hash) == 32);
30346         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
30347         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
30348         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
30349 }
30350
30351 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
30352         LDKInvoicePayer this_arg_conv;
30353         this_arg_conv.inner = (void*)(this_arg & (~1));
30354         this_arg_conv.is_owned = false;
30355         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
30356         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
30357         return (uint64_t)ret_ret;
30358 }
30359
30360 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) {
30361         LDKChannelManager channelmanager_conv;
30362         channelmanager_conv.inner = (void*)(channelmanager & (~1));
30363         channelmanager_conv.is_owned = false;
30364         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
30365         CHECK_ACCESS(keys_manager_ptr);
30366         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
30367         LDKCurrency network_conv = LDKCurrency_from_js(network);
30368         void* amt_msat_ptr = (void*)(((uint64_t)amt_msat) & ~1);
30369         CHECK_ACCESS(amt_msat_ptr);
30370         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
30371         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
30372         LDKStr description_conv = str_ref_to_owned_c(description);
30373         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
30374         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
30375         return (uint64_t)ret_conv;
30376 }
30377
30378 void  __attribute__((visibility("default"))) TS_DefaultRouter_free(uint32_t this_obj) {
30379         LDKDefaultRouter this_obj_conv;
30380         this_obj_conv.inner = (void*)(this_obj & (~1));
30381         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30382         DefaultRouter_free(this_obj_conv);
30383 }
30384
30385 uint32_t  __attribute__((visibility("default"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger) {
30386         LDKNetworkGraph network_graph_conv;
30387         network_graph_conv.inner = (void*)(network_graph & (~1));
30388         network_graph_conv.is_owned = false;
30389         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
30390         CHECK_ACCESS(logger_ptr);
30391         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30392         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
30393         uint64_t ret_ref = 0;
30394         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30395         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30396         ret_ref = (uint64_t)ret_var.inner;
30397         if (ret_var.is_owned) {
30398                 ret_ref |= 1;
30399         }
30400         return ret_ref;
30401 }
30402
30403 uint32_t  __attribute__((visibility("default"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
30404         LDKDefaultRouter this_arg_conv;
30405         this_arg_conv.inner = (void*)(this_arg & (~1));
30406         this_arg_conv.is_owned = false;
30407         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
30408         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
30409         return (uint64_t)ret_ret;
30410 }
30411
30412 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
30413         LDKChannelManager this_arg_conv;
30414         this_arg_conv.inner = (void*)(this_arg & (~1));
30415         this_arg_conv.is_owned = false;
30416         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
30417         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
30418         return (uint64_t)ret_ret;
30419 }
30420
30421 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
30422         LDKStr s_conv = str_ref_to_owned_c(s);
30423         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
30424         *ret_conv = SiPrefix_from_str(s_conv);
30425         return (uint64_t)ret_conv;
30426 }
30427
30428 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_str(jstring s) {
30429         LDKStr s_conv = str_ref_to_owned_c(s);
30430         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
30431         *ret_conv = Invoice_from_str(s_conv);
30432         return (uint64_t)ret_conv;
30433 }
30434
30435 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_from_str(jstring s) {
30436         LDKStr s_conv = str_ref_to_owned_c(s);
30437         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
30438         *ret_conv = SignedRawInvoice_from_str(s_conv);
30439         return (uint64_t)ret_conv;
30440 }
30441
30442 jstring  __attribute__((visibility("default"))) TS_Invoice_to_str(uint32_t o) {
30443         LDKInvoice o_conv;
30444         o_conv.inner = (void*)(o & (~1));
30445         o_conv.is_owned = false;
30446         LDKStr ret_str = Invoice_to_str(&o_conv);
30447         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
30448         Str_free(ret_str);
30449         return ret_conv;
30450 }
30451
30452 jstring  __attribute__((visibility("default"))) TS_SignedRawInvoice_to_str(uint32_t o) {
30453         LDKSignedRawInvoice o_conv;
30454         o_conv.inner = (void*)(o & (~1));
30455         o_conv.is_owned = false;
30456         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
30457         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
30458         Str_free(ret_str);
30459         return ret_conv;
30460 }
30461
30462 jstring  __attribute__((visibility("default"))) TS_Currency_to_str(uint32_t o) {
30463         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
30464         LDKStr ret_str = Currency_to_str(o_conv);
30465         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
30466         Str_free(ret_str);
30467         return ret_conv;
30468 }
30469
30470 jstring  __attribute__((visibility("default"))) TS_SiPrefix_to_str(uint32_t o) {
30471         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
30472         LDKStr ret_str = SiPrefix_to_str(o_conv);
30473         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
30474         Str_free(ret_str);
30475         return ret_conv;
30476 }
30477