Merge pull request #39 from TheBlueMatt/main
[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 ((long)(p) > 1024) { free(p); }
22 #define DO_ASSERT(a) (void)(a)
23 #define CHECK(a)
24
25 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
26 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
27 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
28 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
29
30 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
31
32 typedef uint32_t int64_tArray;
33 typedef uint32_t int8_tArray;
34 typedef uint32_t uint32_tArray;
35 typedef uint32_t ptrArray;
36 typedef uint32_t jstring;
37
38 static inline uint32_t init_arr(size_t arr_len, size_t elem_size, const char *type_desc) {
39         uint32_t *elems = (uint32_t*)MALLOC(arr_len * elem_size + 4, type_desc);
40         elems[0] = arr_len;
41         return (uint32_t)elems;
42 }
43
44 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
45         char* err_buf = MALLOC(len + 4, "str conv buf");
46         *((uint32_t*)err_buf) = len;
47         memcpy(err_buf + 4, chars, len);
48         return (uint32_t) err_buf;
49 }
50 static inline LDKStr str_ref_to_owned_c(jstring str) {
51         uint32_t *str_len = (uint32_t*)str;
52         char* newchars = MALLOC(*str_len + 1, "String chars");
53         memcpy(newchars, (const char*)(str + 4), *str_len);
54         newchars[*str_len] = 0;
55         LDKStr res= {
56                 .chars = newchars,
57                 .len = *str_len,
58                 .chars_is_owned = true
59         };
60         return res;
61 }
62
63 typedef bool jboolean;
64
65 uint32_t __attribute__((visibility("default"))) TS_malloc(uint32_t size) {
66         return (uint32_t)MALLOC(size, "JS-Called malloc");
67 }
68 void __attribute__((visibility("default"))) TS_free(uint32_t ptr) {
69         FREE((void*)ptr);
70 }
71 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
72 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
73         switch (ord) {
74                 case 0: return LDKAccessError_UnknownChain;
75                 case 1: return LDKAccessError_UnknownTx;
76         }
77         abort();
78 }
79 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
80         switch (val) {
81                 case LDKAccessError_UnknownChain: return 0;
82                 case LDKAccessError_UnknownTx: return 1;
83                 default: abort();
84         }
85 }
86 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
87         switch (ord) {
88                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
89                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
90         }
91         abort();
92 }
93 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
94         switch (val) {
95                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
96                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
97                 default: abort();
98         }
99 }
100 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
101         switch (ord) {
102                 case 0: return LDKConfirmationTarget_Background;
103                 case 1: return LDKConfirmationTarget_Normal;
104                 case 2: return LDKConfirmationTarget_HighPriority;
105         }
106         abort();
107 }
108 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
109         switch (val) {
110                 case LDKConfirmationTarget_Background: return 0;
111                 case LDKConfirmationTarget_Normal: return 1;
112                 case LDKConfirmationTarget_HighPriority: return 2;
113                 default: abort();
114         }
115 }
116 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
117         switch (ord) {
118                 case 0: return LDKCreationError_DescriptionTooLong;
119                 case 1: return LDKCreationError_RouteTooLong;
120                 case 2: return LDKCreationError_TimestampOutOfBounds;
121                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
122         }
123         abort();
124 }
125 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
126         switch (val) {
127                 case LDKCreationError_DescriptionTooLong: return 0;
128                 case LDKCreationError_RouteTooLong: return 1;
129                 case LDKCreationError_TimestampOutOfBounds: return 2;
130                 case LDKCreationError_ExpiryTimeOutOfBounds: return 3;
131                 default: abort();
132         }
133 }
134 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
135         switch (ord) {
136                 case 0: return LDKCurrency_Bitcoin;
137                 case 1: return LDKCurrency_BitcoinTestnet;
138                 case 2: return LDKCurrency_Regtest;
139                 case 3: return LDKCurrency_Simnet;
140                 case 4: return LDKCurrency_Signet;
141         }
142         abort();
143 }
144 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
145         switch (val) {
146                 case LDKCurrency_Bitcoin: return 0;
147                 case LDKCurrency_BitcoinTestnet: return 1;
148                 case LDKCurrency_Regtest: return 2;
149                 case LDKCurrency_Simnet: return 3;
150                 case LDKCurrency_Signet: return 4;
151                 default: abort();
152         }
153 }
154 static inline LDKIOError LDKIOError_from_js(int32_t ord) {
155         switch (ord) {
156                 case 0: return LDKIOError_NotFound;
157                 case 1: return LDKIOError_PermissionDenied;
158                 case 2: return LDKIOError_ConnectionRefused;
159                 case 3: return LDKIOError_ConnectionReset;
160                 case 4: return LDKIOError_ConnectionAborted;
161                 case 5: return LDKIOError_NotConnected;
162                 case 6: return LDKIOError_AddrInUse;
163                 case 7: return LDKIOError_AddrNotAvailable;
164                 case 8: return LDKIOError_BrokenPipe;
165                 case 9: return LDKIOError_AlreadyExists;
166                 case 10: return LDKIOError_WouldBlock;
167                 case 11: return LDKIOError_InvalidInput;
168                 case 12: return LDKIOError_InvalidData;
169                 case 13: return LDKIOError_TimedOut;
170                 case 14: return LDKIOError_WriteZero;
171                 case 15: return LDKIOError_Interrupted;
172                 case 16: return LDKIOError_Other;
173                 case 17: return LDKIOError_UnexpectedEof;
174         }
175         abort();
176 }
177 static inline int32_t LDKIOError_to_js(LDKIOError val) {
178         switch (val) {
179                 case LDKIOError_NotFound: return 0;
180                 case LDKIOError_PermissionDenied: return 1;
181                 case LDKIOError_ConnectionRefused: return 2;
182                 case LDKIOError_ConnectionReset: return 3;
183                 case LDKIOError_ConnectionAborted: return 4;
184                 case LDKIOError_NotConnected: return 5;
185                 case LDKIOError_AddrInUse: return 6;
186                 case LDKIOError_AddrNotAvailable: return 7;
187                 case LDKIOError_BrokenPipe: return 8;
188                 case LDKIOError_AlreadyExists: return 9;
189                 case LDKIOError_WouldBlock: return 10;
190                 case LDKIOError_InvalidInput: return 11;
191                 case LDKIOError_InvalidData: return 12;
192                 case LDKIOError_TimedOut: return 13;
193                 case LDKIOError_WriteZero: return 14;
194                 case LDKIOError_Interrupted: return 15;
195                 case LDKIOError_Other: return 16;
196                 case LDKIOError_UnexpectedEof: return 17;
197                 default: abort();
198         }
199 }
200 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
201         switch (ord) {
202                 case 0: return LDKLevel_Trace;
203                 case 1: return LDKLevel_Debug;
204                 case 2: return LDKLevel_Info;
205                 case 3: return LDKLevel_Warn;
206                 case 4: return LDKLevel_Error;
207         }
208         abort();
209 }
210 static inline int32_t LDKLevel_to_js(LDKLevel val) {
211         switch (val) {
212                 case LDKLevel_Trace: return 0;
213                 case LDKLevel_Debug: return 1;
214                 case LDKLevel_Info: return 2;
215                 case LDKLevel_Warn: return 3;
216                 case LDKLevel_Error: return 4;
217                 default: abort();
218         }
219 }
220 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
221         switch (ord) {
222                 case 0: return LDKNetwork_Bitcoin;
223                 case 1: return LDKNetwork_Testnet;
224                 case 2: return LDKNetwork_Regtest;
225                 case 3: return LDKNetwork_Signet;
226         }
227         abort();
228 }
229 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
230         switch (val) {
231                 case LDKNetwork_Bitcoin: return 0;
232                 case LDKNetwork_Testnet: return 1;
233                 case LDKNetwork_Regtest: return 2;
234                 case LDKNetwork_Signet: return 3;
235                 default: abort();
236         }
237 }
238 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
239         switch (ord) {
240                 case 0: return LDKSecp256k1Error_IncorrectSignature;
241                 case 1: return LDKSecp256k1Error_InvalidMessage;
242                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
243                 case 3: return LDKSecp256k1Error_InvalidSignature;
244                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
245                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
246                 case 6: return LDKSecp256k1Error_InvalidTweak;
247                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
248                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
249         }
250         abort();
251 }
252 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
253         switch (val) {
254                 case LDKSecp256k1Error_IncorrectSignature: return 0;
255                 case LDKSecp256k1Error_InvalidMessage: return 1;
256                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
257                 case LDKSecp256k1Error_InvalidSignature: return 3;
258                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
259                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
260                 case LDKSecp256k1Error_InvalidTweak: return 6;
261                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
262                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
263                 default: abort();
264         }
265 }
266 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
267         switch (ord) {
268                 case 0: return LDKSemanticError_NoPaymentHash;
269                 case 1: return LDKSemanticError_MultiplePaymentHashes;
270                 case 2: return LDKSemanticError_NoDescription;
271                 case 3: return LDKSemanticError_MultipleDescriptions;
272                 case 4: return LDKSemanticError_MultiplePaymentSecrets;
273                 case 5: return LDKSemanticError_InvalidFeatures;
274                 case 6: return LDKSemanticError_InvalidRecoveryId;
275                 case 7: return LDKSemanticError_InvalidSignature;
276         }
277         abort();
278 }
279 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
280         switch (val) {
281                 case LDKSemanticError_NoPaymentHash: return 0;
282                 case LDKSemanticError_MultiplePaymentHashes: return 1;
283                 case LDKSemanticError_NoDescription: return 2;
284                 case LDKSemanticError_MultipleDescriptions: return 3;
285                 case LDKSemanticError_MultiplePaymentSecrets: return 4;
286                 case LDKSemanticError_InvalidFeatures: return 5;
287                 case LDKSemanticError_InvalidRecoveryId: return 6;
288                 case LDKSemanticError_InvalidSignature: return 7;
289                 default: abort();
290         }
291 }
292 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
293         switch (ord) {
294                 case 0: return LDKSiPrefix_Milli;
295                 case 1: return LDKSiPrefix_Micro;
296                 case 2: return LDKSiPrefix_Nano;
297                 case 3: return LDKSiPrefix_Pico;
298         }
299         abort();
300 }
301 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
302         switch (val) {
303                 case LDKSiPrefix_Milli: return 0;
304                 case LDKSiPrefix_Micro: return 1;
305                 case LDKSiPrefix_Nano: return 2;
306                 case LDKSiPrefix_Pico: return 3;
307                 default: abort();
308         }
309 }
310 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
311         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
312         ret->datalen = *((uint32_t*)elems);
313         if (ret->datalen == 0) {
314                 ret->data = NULL;
315         } else {
316                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
317                 int8_t *java_elems = (int8_t*)(elems + 4);
318                 for (size_t i = 0; i < ret->datalen; i++) {
319                         ret->data[i] = java_elems[i];
320                 }
321         }
322         return (uint64_t)ret;
323 }
324 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
325         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
326         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
327         return ret;
328 }
329 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) {
330         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
331         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
332         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
333         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
334         CVec_u8Z_free(ret_var);
335         return ret_arr;
336 }
337
338 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}int64_t  __attribute__((visibility("default"))) TS_TxOut_get_value(uint32_t thing) {
339         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
340         int64_t ret_val = TxOut_get_value(thing_conv);
341         return ret_val;
342 }
343
344 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_result_ok(uint32_t arg) {
345         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
346 }
347 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
348         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
349         CHECK(val->result_ok);
350         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
351         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
352         return res_arr;
353 }
354 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
355         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
356         CHECK(!val->result_ok);
357         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
358         return err_conv;
359 }
360 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_result_ok(uint32_t arg) {
361         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
362 }
363 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
364         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
365         CHECK(val->result_ok);
366         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
367         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
368         return res_arr;
369 }
370 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
371         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
372         CHECK(!val->result_ok);
373         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
374         return err_conv;
375 }
376 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_result_ok(uint32_t arg) {
377         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
378 }
379 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
380         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
381         CHECK(val->result_ok);
382         LDKTxCreationKeys res_var = (*val->contents.result);
383         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
384         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
385         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
386         return res_ref;
387 }
388 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
389         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
390         CHECK(!val->result_ok);
391         LDKDecodeError err_var = (*val->contents.err);
392         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
393         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
394         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
395         return err_ref;
396 }
397 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
398         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
399 }
400 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
401         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
402         CHECK(val->result_ok);
403         LDKChannelPublicKeys res_var = (*val->contents.result);
404         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
405         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
406         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
407         return res_ref;
408 }
409 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
410         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
411         CHECK(!val->result_ok);
412         LDKDecodeError err_var = (*val->contents.err);
413         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
414         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
415         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
416         return err_ref;
417 }
418 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
419         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
420 }
421 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
422         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
423         CHECK(val->result_ok);
424         LDKTxCreationKeys res_var = (*val->contents.result);
425         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
426         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
427         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
428         return res_ref;
429 }
430 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
431         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
432         CHECK(!val->result_ok);
433         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
434         return err_conv;
435 }
436 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u32Z_ref_from_ptr(uint32_t ptr) {
437         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
438         switch(obj->tag) {
439                 case LDKCOption_u32Z_Some: {
440                         return 0 /* LDKCOption_u32Z - Some */; (void) obj->some;
441                 }
442                 case LDKCOption_u32Z_None: {
443                         return 0 /* LDKCOption_u32Z - None */;
444                 }
445                 default: abort();
446         }
447 }
448 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_result_ok(uint32_t arg) {
449         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
450 }
451 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
452         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
453         CHECK(val->result_ok);
454         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
455         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
456         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
457         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
458         return res_ref;
459 }
460 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
461         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
462         CHECK(!val->result_ok);
463         LDKDecodeError err_var = (*val->contents.err);
464         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
465         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
466         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
467         return err_ref;
468 }
469 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
470         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
471 }
472 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
473         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
474         CHECK(val->result_ok);
475         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
476         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
477         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
478         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
479         return res_ref;
480 }
481 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
482         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
483         CHECK(!val->result_ok);
484         LDKDecodeError err_var = (*val->contents.err);
485         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
486         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
487         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
488         return err_ref;
489 }
490 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
491         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
492 }
493 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
494         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
495         CHECK(val->result_ok);
496         LDKChannelTransactionParameters res_var = (*val->contents.result);
497         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
498         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
499         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
500         return res_ref;
501 }
502 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
503         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
504         CHECK(!val->result_ok);
505         LDKDecodeError err_var = (*val->contents.err);
506         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
507         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
508         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
509         return err_ref;
510 }
511 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
512         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
513 }
514 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
515         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
516         CHECK(val->result_ok);
517         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
518         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
519         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
520         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
521         return res_ref;
522 }
523 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
524         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
525         CHECK(!val->result_ok);
526         LDKDecodeError err_var = (*val->contents.err);
527         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
528         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
529         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
530         return err_ref;
531 }
532 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
533         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
534 }
535 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
536         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
537         CHECK(val->result_ok);
538         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
539         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
540         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
541         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
542         return res_ref;
543 }
544 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
545         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
546         CHECK(!val->result_ok);
547         LDKDecodeError err_var = (*val->contents.err);
548         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
549         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
550         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
551         return err_ref;
552 }
553 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
554         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
555 }
556 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
557         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
558         CHECK(val->result_ok);
559         LDKCommitmentTransaction res_var = (*val->contents.result);
560         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
561         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
562         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
563         return res_ref;
564 }
565 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
566         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
567         CHECK(!val->result_ok);
568         LDKDecodeError err_var = (*val->contents.err);
569         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
570         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
571         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
572         return err_ref;
573 }
574 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
575         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
576 }
577 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
578         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
579         CHECK(val->result_ok);
580         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
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         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
584         return res_ref;
585 }
586 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
587         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
588         CHECK(!val->result_ok);
589         return *val->contents.err;
590 }
591 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
592         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
593 }
594 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
595         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
596         CHECK(val->result_ok);
597         LDKCVec_SignatureZ res_var = (*val->contents.result);
598         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
599         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
600         for (size_t m = 0; m < res_var.datalen; m++) {
601                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
602                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
603                 res_arr_ptr[m] = res_conv_12_arr;
604         }
605         return res_arr;
606 }
607 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
608         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
609         CHECK(!val->result_ok);
610         return *val->contents.err;
611 }
612 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_result_ok(uint32_t arg) {
613         return ((LDKCResult_ShutdownScriptDecodeErrorZ*)arg)->result_ok;
614 }
615 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t arg) {
616         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
617         CHECK(val->result_ok);
618         LDKShutdownScript res_var = (*val->contents.result);
619         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
620         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
621         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
622         return res_ref;
623 }
624 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t arg) {
625         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
626         CHECK(!val->result_ok);
627         LDKDecodeError err_var = (*val->contents.err);
628         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
629         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
630         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
631         return err_ref;
632 }
633 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_result_ok(uint32_t arg) {
634         return ((LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)arg)->result_ok;
635 }
636 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t arg) {
637         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
638         CHECK(val->result_ok);
639         LDKShutdownScript res_var = (*val->contents.result);
640         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
641         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
642         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
643         return res_ref;
644 }
645 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t arg) {
646         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
647         CHECK(!val->result_ok);
648         LDKInvalidShutdownScript err_var = (*val->contents.err);
649         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
650         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
651         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
652         return err_ref;
653 }
654 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_result_ok(uint32_t arg) {
655         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
656 }
657 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_ok(uint32_t arg) {
658         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
659         CHECK(val->result_ok);
660         return *val->contents.result;
661 }
662 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_err(uint32_t arg) {
663         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
664         CHECK(!val->result_ok);
665         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
666         return err_conv;
667 }
668 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_result_ok(uint32_t arg) {
669         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
670 }
671 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_ok(uint32_t arg) {
672         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
673         CHECK(val->result_ok);
674         LDKRouteHop res_var = (*val->contents.result);
675         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
676         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
677         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
678         return res_ref;
679 }
680 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_err(uint32_t arg) {
681         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
682         CHECK(!val->result_ok);
683         LDKDecodeError err_var = (*val->contents.err);
684         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
685         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
686         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
687         return err_ref;
688 }
689 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
690         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
691         ret->datalen = *((uint32_t*)elems);
692         if (ret->datalen == 0) {
693                 ret->data = NULL;
694         } else {
695                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
696                 uint32_t *java_elems = (uint32_t*)(elems + 4);
697                 for (size_t i = 0; i < ret->datalen; i++) {
698                         uint32_t arr_elem = java_elems[i];
699                         LDKRouteHop arr_elem_conv;
700                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
701                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
702                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
703                         ret->data[i] = arr_elem_conv;
704                 }
705         }
706         return (uint64_t)ret;
707 }
708 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
709         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
710         for (size_t i = 0; i < ret.datalen; i++) {
711                 ret.data[i] = RouteHop_clone(&orig->data[i]);
712         }
713         return ret;
714 }
715 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
716         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
717         for (size_t i = 0; i < ret.datalen; i++) {
718                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
719         }
720         return ret;
721 }
722 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
723         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
724 }
725 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
726         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
727         CHECK(val->result_ok);
728         LDKRoute res_var = (*val->contents.result);
729         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
730         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
731         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
732         return res_ref;
733 }
734 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
735         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
736         CHECK(!val->result_ok);
737         LDKDecodeError err_var = (*val->contents.err);
738         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
739         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
740         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
741         return err_ref;
742 }
743 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
744         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
745         switch(obj->tag) {
746                 case LDKCOption_u64Z_Some: {
747                         return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
748                 }
749                 case LDKCOption_u64Z_None: {
750                         return 0 /* LDKCOption_u64Z - None */;
751                 }
752                 default: abort();
753         }
754 }
755 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
756         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
757         ret->datalen = *((uint32_t*)elems);
758         if (ret->datalen == 0) {
759                 ret->data = NULL;
760         } else {
761                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
762                 uint32_t *java_elems = (uint32_t*)(elems + 4);
763                 for (size_t i = 0; i < ret->datalen; i++) {
764                         uint32_t arr_elem = java_elems[i];
765                         LDKChannelDetails arr_elem_conv;
766                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
767                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
768                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
769                         ret->data[i] = arr_elem_conv;
770                 }
771         }
772         return (uint64_t)ret;
773 }
774 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
775         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
776         for (size_t i = 0; i < ret.datalen; i++) {
777                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
778         }
779         return ret;
780 }
781 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
782         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
783         ret->datalen = *((uint32_t*)elems);
784         if (ret->datalen == 0) {
785                 ret->data = NULL;
786         } else {
787                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
788                 uint32_t *java_elems = (uint32_t*)(elems + 4);
789                 for (size_t i = 0; i < ret->datalen; i++) {
790                         uint32_t arr_elem = java_elems[i];
791                         LDKRouteHint arr_elem_conv;
792                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
793                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
794                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
795                         ret->data[i] = arr_elem_conv;
796                 }
797         }
798         return (uint64_t)ret;
799 }
800 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
801         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
802         for (size_t i = 0; i < ret.datalen; i++) {
803                 ret.data[i] = RouteHint_clone(&orig->data[i]);
804         }
805         return ret;
806 }
807 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
808         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
809 }
810 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
811         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
812         CHECK(val->result_ok);
813         LDKRoute res_var = (*val->contents.result);
814         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
815         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
816         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
817         return res_ref;
818 }
819 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
820         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
821         CHECK(!val->result_ok);
822         LDKLightningError err_var = (*val->contents.err);
823         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
824         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
825         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
826         return err_ref;
827 }
828 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
829         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
830 }
831 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
832         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
833         CHECK(val->result_ok);
834         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
835         return (uint64_t)res_ref;
836 }
837 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
838         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
839         CHECK(!val->result_ok);
840         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
841         return err_conv;
842 }
843 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
844         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
845         ret->a = a;
846         LDKTransaction b_ref;
847         b_ref.datalen = *((uint32_t*)b);
848         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
849         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
850         b_ref.data_is_owned = false;
851         ret->b = b_ref;
852         return (uint64_t)ret;
853 }
854 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
855         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
856         return tuple->a;
857 }
858 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
859         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
860         LDKTransaction b_var = tuple->b;
861         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
862         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
863         return b_arr;
864 }
865 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
866         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
867         ret->datalen = *((uint32_t*)elems);
868         if (ret->datalen == 0) {
869                 ret->data = NULL;
870         } else {
871                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
872                 uint32_t *java_elems = (uint32_t*)(elems + 4);
873                 for (size_t i = 0; i < ret->datalen; i++) {
874                         uint32_t arr_elem = java_elems[i];
875                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
876                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
877                         ret->data[i] = arr_elem_conv;
878                 }
879         }
880         return (uint64_t)ret;
881 }
882 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
883         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
884         for (size_t i = 0; i < ret.datalen; i++) {
885                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
886         }
887         return ret;
888 }
889 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
890         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
891         for (size_t i = 0; i < ret.datalen; i++) {
892                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
893         }
894         return ret;
895 }
896 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
897         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
898 }
899 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
900         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
901         CHECK(val->result_ok);
902         return *val->contents.result;
903 }
904 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
905         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
906         CHECK(!val->result_ok);
907         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
908         return err_conv;
909 }
910 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
911         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
912         switch(obj->tag) {
913                 case LDKMonitorEvent_HTLCEvent: {
914                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
915                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
916                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
917                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
918                         return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
919                 }
920                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
921                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
922                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
923                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
924                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
925                         return 0 /* LDKMonitorEvent - CommitmentTxBroadcasted */; (void) commitment_tx_broadcasted_ref;
926                 }
927                 default: abort();
928         }
929 }
930 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
931         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
932         ret->datalen = *((uint32_t*)elems);
933         if (ret->datalen == 0) {
934                 ret->data = NULL;
935         } else {
936                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
937                 uint32_t *java_elems = (uint32_t*)(elems + 4);
938                 for (size_t i = 0; i < ret->datalen; i++) {
939                         uint32_t arr_elem = java_elems[i];
940                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
941                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
942                         ret->data[i] = arr_elem_conv;
943                 }
944         }
945         return (uint64_t)ret;
946 }
947 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
948         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
949         for (size_t i = 0; i < ret.datalen; i++) {
950                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
951         }
952         return ret;
953 }
954 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(uint32_t ptr) {
955         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
956         switch(obj->tag) {
957                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
958                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
959                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - Some */; (void) some_ref;
960                 }
961                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
962                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - None */;
963                 }
964                 default: abort();
965         }
966 }
967 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
968         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
969         switch(obj->tag) {
970                 case LDKSpendableOutputDescriptor_StaticOutput: {
971                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
972                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
973                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
974                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
975                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
976                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
977                 }
978                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
979                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
980                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
981                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
982                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
983                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
984                 }
985                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
986                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
987                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
988                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
989                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
990                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
991                 }
992                 default: abort();
993         }
994 }
995 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
996         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
997         ret->datalen = *((uint32_t*)elems);
998         if (ret->datalen == 0) {
999                 ret->data = NULL;
1000         } else {
1001                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1002                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1003                 for (size_t i = 0; i < ret->datalen; i++) {
1004                         uint32_t arr_elem = java_elems[i];
1005                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1006                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1007                         ret->data[i] = arr_elem_conv;
1008                 }
1009         }
1010         return (uint64_t)ret;
1011 }
1012 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1013         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1014         for (size_t i = 0; i < ret.datalen; i++) {
1015                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1016         }
1017         return ret;
1018 }
1019 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
1020         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1021         switch(obj->tag) {
1022                 case LDKErrorAction_DisconnectPeer: {
1023                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1024                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1025                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1026                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1027                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
1028                 }
1029                 case LDKErrorAction_IgnoreError: {
1030                         return 0 /* LDKErrorAction - IgnoreError */;
1031                 }
1032                 case LDKErrorAction_IgnoreAndLog: {
1033                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1034                         return 0 /* LDKErrorAction - IgnoreAndLog */; (void) ignore_and_log_conv;
1035                 }
1036                 case LDKErrorAction_SendErrorMessage: {
1037                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1038                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1039                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1040                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1041                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
1042                 }
1043                 default: abort();
1044         }
1045 }
1046 uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) {
1047         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1048         switch(obj->tag) {
1049                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1050                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1051                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1052                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1053                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1054                         return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
1055                 }
1056                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1057                         return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
1058                 }
1059                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1060                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1061                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
1062                         return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
1063                 }
1064                 default: abort();
1065         }
1066 }
1067 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
1068         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1069         switch(obj->tag) {
1070                 case LDKMessageSendEvent_SendAcceptChannel: {
1071                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1072                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
1073                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1074                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1075                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1076                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1077                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
1078                 }
1079                 case LDKMessageSendEvent_SendOpenChannel: {
1080                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1081                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
1082                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1083                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1084                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1085                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1086                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
1087                 }
1088                 case LDKMessageSendEvent_SendFundingCreated: {
1089                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1090                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
1091                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1092                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1093                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1094                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1095                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
1096                 }
1097                 case LDKMessageSendEvent_SendFundingSigned: {
1098                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1099                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
1100                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1101                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1102                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1103                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1104                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
1105                 }
1106                 case LDKMessageSendEvent_SendFundingLocked: {
1107                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1108                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
1109                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1110                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1111                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1112                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1113                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
1114                 }
1115                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1116                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1117                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
1118                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1119                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1120                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1121                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1122                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
1123                 }
1124                 case LDKMessageSendEvent_UpdateHTLCs: {
1125                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1126                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
1127                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1128                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1129                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1130                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1131                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
1132                 }
1133                 case LDKMessageSendEvent_SendRevokeAndACK: {
1134                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1135                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
1136                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1137                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1138                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1139                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1140                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
1141                 }
1142                 case LDKMessageSendEvent_SendClosingSigned: {
1143                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1144                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
1145                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1146                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1147                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1148                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1149                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
1150                 }
1151                 case LDKMessageSendEvent_SendShutdown: {
1152                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1153                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
1154                         LDKShutdown msg_var = obj->send_shutdown.msg;
1155                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1156                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1157                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1158                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
1159                 }
1160                 case LDKMessageSendEvent_SendChannelReestablish: {
1161                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1162                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
1163                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1164                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1165                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1166                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1167                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
1168                 }
1169                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1170                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1171                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1172                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1173                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1174                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1175                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1176                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1177                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1178                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
1179                 }
1180                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1181                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1182                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1183                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1184                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1185                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
1186                 }
1187                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1188                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1189                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1190                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1191                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1192                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
1193                 }
1194                 case LDKMessageSendEvent_SendChannelUpdate: {
1195                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1196                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_update.node_id.compressed_form, 33);
1197                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1198                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1199                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1200                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1201                         return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref;
1202                 }
1203                 case LDKMessageSendEvent_HandleError: {
1204                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1205                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
1206                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1207                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
1208                 }
1209                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1210                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1211                         return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref;
1212                 }
1213                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1214                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1215                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
1216                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1217                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1218                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1219                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1220                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
1221                 }
1222                 case LDKMessageSendEvent_SendShortIdsQuery: {
1223                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1224                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
1225                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1226                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1227                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1228                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1229                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
1230                 }
1231                 case LDKMessageSendEvent_SendReplyChannelRange: {
1232                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1233                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
1234                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1235                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1236                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1237                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1238                         return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
1239                 }
1240                 default: abort();
1241         }
1242 }
1243 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
1244         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1245         ret->datalen = *((uint32_t*)elems);
1246         if (ret->datalen == 0) {
1247                 ret->data = NULL;
1248         } else {
1249                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1250                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1251                 for (size_t i = 0; i < ret->datalen; i++) {
1252                         uint32_t arr_elem = java_elems[i];
1253                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1254                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1255                         ret->data[i] = arr_elem_conv;
1256                 }
1257         }
1258         return (uint64_t)ret;
1259 }
1260 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1261         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1262         for (size_t i = 0; i < ret.datalen; i++) {
1263                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1264         }
1265         return ret;
1266 }
1267 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1268         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1269 }
1270 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1271         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1272         CHECK(val->result_ok);
1273         LDKInitFeatures res_var = (*val->contents.result);
1274         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1275         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1276         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1277         return res_ref;
1278 }
1279 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1280         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1281         CHECK(!val->result_ok);
1282         LDKDecodeError err_var = (*val->contents.err);
1283         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1284         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1285         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1286         return err_ref;
1287 }
1288 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1289         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1290 }
1291 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1292         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1293         CHECK(val->result_ok);
1294         LDKNodeFeatures res_var = (*val->contents.result);
1295         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1296         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1297         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1298         return res_ref;
1299 }
1300 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1301         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1302         CHECK(!val->result_ok);
1303         LDKDecodeError err_var = (*val->contents.err);
1304         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1305         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1306         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1307         return err_ref;
1308 }
1309 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1310         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1311 }
1312 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1313         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1314         CHECK(val->result_ok);
1315         LDKChannelFeatures res_var = (*val->contents.result);
1316         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1317         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1318         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1319         return res_ref;
1320 }
1321 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1322         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1323         CHECK(!val->result_ok);
1324         LDKDecodeError err_var = (*val->contents.err);
1325         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1326         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1327         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1328         return err_ref;
1329 }
1330 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1331         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1332 }
1333 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1334         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1335         CHECK(val->result_ok);
1336         LDKInvoiceFeatures res_var = (*val->contents.result);
1337         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1338         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1339         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1340         return res_ref;
1341 }
1342 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1343         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1344         CHECK(!val->result_ok);
1345         LDKDecodeError err_var = (*val->contents.err);
1346         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1347         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1348         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1349         return err_ref;
1350 }
1351 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1352         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1353 }
1354 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1355         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1356         CHECK(val->result_ok);
1357         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1358         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1359         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1360         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1361         return res_ref;
1362 }
1363 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1364         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1365         CHECK(!val->result_ok);
1366         LDKDecodeError err_var = (*val->contents.err);
1367         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1368         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1369         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1370         return err_ref;
1371 }
1372 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1373         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1374 }
1375 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1376         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1377         CHECK(val->result_ok);
1378         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1379         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1380         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1381         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1382         return res_ref;
1383 }
1384 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1385         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1386         CHECK(!val->result_ok);
1387         LDKDecodeError err_var = (*val->contents.err);
1388         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1389         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1390         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1391         return err_ref;
1392 }
1393 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1394         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1395 }
1396 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1397         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1398         CHECK(val->result_ok);
1399         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1400         return res_ref;
1401 }
1402 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1403         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1404         CHECK(!val->result_ok);
1405         LDKDecodeError err_var = (*val->contents.err);
1406         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1407         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1408         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1409         return err_ref;
1410 }
1411 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
1412         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1413         LDKSignature a_ref;
1414         CHECK(*((uint32_t*)a) == 64);
1415         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
1416         ret->a = a_ref;
1417         LDKCVec_SignatureZ b_constr;
1418         b_constr.datalen = *((uint32_t*)b);
1419         if (b_constr.datalen > 0)
1420                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1421         else
1422                 b_constr.data = NULL;
1423         int8_tArray* b_vals = (int8_tArray*)(b + 4);
1424         for (size_t m = 0; m < b_constr.datalen; m++) {
1425                 int8_tArray b_conv_12 = b_vals[m];
1426                 LDKSignature b_conv_12_ref;
1427                 CHECK(*((uint32_t*)b_conv_12) == 64);
1428                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
1429                 b_constr.data[m] = b_conv_12_ref;
1430         }
1431         ret->b = b_constr;
1432         return (uint64_t)ret;
1433 }
1434 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
1435         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1436         int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1437         memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
1438         return a_arr;
1439 }
1440 ptrArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
1441         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1442         LDKCVec_SignatureZ b_var = tuple->b;
1443         ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1444         int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
1445         for (size_t m = 0; m < b_var.datalen; m++) {
1446                 int8_tArray b_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1447                 memcpy((uint8_t*)(b_conv_12_arr + 4), b_var.data[m].compact_form, 64);
1448                 b_arr_ptr[m] = b_conv_12_arr;
1449         }
1450         return b_arr;
1451 }
1452 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
1453         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1454 }
1455 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1456         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1457         CHECK(val->result_ok);
1458         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
1459         return res_ref;
1460 }
1461 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1462         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1463         CHECK(!val->result_ok);
1464         return *val->contents.err;
1465 }
1466 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
1467         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1468 }
1469 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1470         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1471         CHECK(val->result_ok);
1472         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1473         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1474         return res_arr;
1475 }
1476 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1477         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1478         CHECK(!val->result_ok);
1479         return *val->contents.err;
1480 }
1481 typedef struct LDKBaseSign_JCalls {
1482         atomic_size_t refcnt;
1483         uint32_t get_per_commitment_point_meth;
1484         uint32_t release_commitment_secret_meth;
1485         uint32_t channel_keys_id_meth;
1486         uint32_t sign_counterparty_commitment_meth;
1487         uint32_t sign_holder_commitment_and_htlcs_meth;
1488         uint32_t sign_justice_revoked_output_meth;
1489         uint32_t sign_justice_revoked_htlc_meth;
1490         uint32_t sign_counterparty_htlc_transaction_meth;
1491         uint32_t sign_closing_transaction_meth;
1492         uint32_t sign_channel_announcement_meth;
1493         uint32_t ready_channel_meth;
1494 } LDKBaseSign_JCalls;
1495 static void LDKBaseSign_JCalls_free(void* this_arg) {
1496         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1497         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1498                 js_free(j_calls->get_per_commitment_point_meth);
1499                 js_free(j_calls->release_commitment_secret_meth);
1500                 js_free(j_calls->channel_keys_id_meth);
1501                 js_free(j_calls->sign_counterparty_commitment_meth);
1502                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1503                 js_free(j_calls->sign_justice_revoked_output_meth);
1504                 js_free(j_calls->sign_justice_revoked_htlc_meth);
1505                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1506                 js_free(j_calls->sign_closing_transaction_meth);
1507                 js_free(j_calls->sign_channel_announcement_meth);
1508                 js_free(j_calls->ready_channel_meth);
1509                 FREE(j_calls);
1510         }
1511 }
1512 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1513         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1514         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1515         LDKPublicKey ret_ref;
1516         CHECK(*((uint32_t*)ret) == 33);
1517         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1518         return ret_ref;
1519 }
1520 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1521         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1522         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1523         LDKThirtyTwoBytes ret_ref;
1524         CHECK(*((uint32_t*)ret) == 32);
1525         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1526         return ret_ref;
1527 }
1528 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1529         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1530         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1531         LDKThirtyTwoBytes ret_ref;
1532         CHECK(*((uint32_t*)ret) == 32);
1533         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1534         return ret_ref;
1535 }
1536 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1537         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1538         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1539         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1540         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1541         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1542         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1543         if (commitment_tx_var.is_owned) {
1544                 commitment_tx_ref |= 1;
1545         }
1546         uint32_t ret = js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1547         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1548         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1549         return ret_conv;
1550 }
1551 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1552         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1553         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1554         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1555         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1556         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1557         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1558         if (commitment_tx_var.is_owned) {
1559                 commitment_tx_ref |= 1;
1560         }
1561         uint32_t ret = js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1562         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1563         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1564         return ret_conv;
1565 }
1566 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]) {
1567         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1568         LDKTransaction justice_tx_var = justice_tx;
1569         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1570         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1571         Transaction_free(justice_tx_var);
1572         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1573         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1574         uint32_t ret = js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
1575         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1576         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1577         return ret_conv;
1578 }
1579 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) {
1580         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1581         LDKTransaction justice_tx_var = justice_tx;
1582         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1583         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1584         Transaction_free(justice_tx_var);
1585         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1586         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1587         LDKHTLCOutputInCommitment htlc_var = *htlc;
1588         htlc_var = HTLCOutputInCommitment_clone(htlc);
1589         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1590         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1591         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1592         if (htlc_var.is_owned) {
1593                 htlc_ref |= 1;
1594         }
1595         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);
1596         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1597         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1598         return ret_conv;
1599 }
1600 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) {
1601         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1602         LDKTransaction htlc_tx_var = htlc_tx;
1603         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1604         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1605         Transaction_free(htlc_tx_var);
1606         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1607         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1608         LDKHTLCOutputInCommitment htlc_var = *htlc;
1609         htlc_var = HTLCOutputInCommitment_clone(htlc);
1610         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1611         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1612         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1613         if (htlc_var.is_owned) {
1614                 htlc_ref |= 1;
1615         }
1616         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);
1617         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1618         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1619         return ret_conv;
1620 }
1621 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
1622         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1623         LDKTransaction closing_tx_var = closing_tx;
1624         int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1625         memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
1626         Transaction_free(closing_tx_var);
1627         uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
1628         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1629         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1630         return ret_conv;
1631 }
1632 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1633         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1634         LDKUnsignedChannelAnnouncement msg_var = *msg;
1635         msg_var = UnsignedChannelAnnouncement_clone(msg);
1636         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1637         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1638         uint64_t msg_ref = (uint64_t)msg_var.inner;
1639         if (msg_var.is_owned) {
1640                 msg_ref |= 1;
1641         }
1642         uint32_t ret = js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1643         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1644         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1645         return ret_conv;
1646 }
1647 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1648         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1649         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1650         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1651         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1652         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1653         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
1654         if (channel_parameters_var.is_owned) {
1655                 channel_parameters_ref |= 1;
1656         }
1657         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1658 }
1659 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
1660         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
1661         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1662 }
1663 static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1664         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
1665         atomic_init(&calls->refcnt, 1);
1666         //TODO: Assign calls->o from o
1667
1668         LDKChannelPublicKeys pubkeys_conv;
1669         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1670         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1671         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1672
1673         LDKBaseSign ret = {
1674                 .this_arg = (void*) calls,
1675                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
1676                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
1677                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
1678                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
1679                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
1680                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
1681                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
1682                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
1683                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
1684                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
1685                 .ready_channel = ready_channel_LDKBaseSign_jcall,
1686                 .free = LDKBaseSign_JCalls_free,
1687                 .pubkeys = pubkeys_conv,
1688                 .set_pubkeys = NULL,
1689         };
1690         return ret;
1691 }
1692 long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1693         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
1694         *res_ptr = LDKBaseSign_init(o, pubkeys);
1695         return (long)res_ptr;
1696 }
1697 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1698         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1699         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1700         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1701         return ret_arr;
1702 }
1703
1704 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1705         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1706         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1707         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1708         return ret_arr;
1709 }
1710
1711 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
1712         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1713         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1714         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
1715         return ret_arr;
1716 }
1717
1718 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1719         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1720         LDKCommitmentTransaction commitment_tx_conv;
1721         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1722         commitment_tx_conv.is_owned = false;
1723         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1724         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1725         return (uint64_t)ret_conv;
1726 }
1727
1728 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
1729         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1730         LDKHolderCommitmentTransaction commitment_tx_conv;
1731         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1732         commitment_tx_conv.is_owned = false;
1733         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1734         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1735         return (uint64_t)ret_conv;
1736 }
1737
1738 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) {
1739         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1740         LDKTransaction justice_tx_ref;
1741         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1742         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1743         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1744         justice_tx_ref.data_is_owned = true;
1745         unsigned char per_commitment_key_arr[32];
1746         CHECK(*((uint32_t*)per_commitment_key) == 32);
1747         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1748         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1749         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1750         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
1751         return (uint64_t)ret_conv;
1752 }
1753
1754 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) {
1755         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1756         LDKTransaction justice_tx_ref;
1757         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1758         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1759         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1760         justice_tx_ref.data_is_owned = true;
1761         unsigned char per_commitment_key_arr[32];
1762         CHECK(*((uint32_t*)per_commitment_key) == 32);
1763         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1764         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1765         LDKHTLCOutputInCommitment htlc_conv;
1766         htlc_conv.inner = (void*)(htlc & (~1));
1767         htlc_conv.is_owned = false;
1768         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1769         *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);
1770         return (uint64_t)ret_conv;
1771 }
1772
1773 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) {
1774         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1775         LDKTransaction htlc_tx_ref;
1776         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
1777         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1778         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
1779         htlc_tx_ref.data_is_owned = true;
1780         LDKPublicKey per_commitment_point_ref;
1781         CHECK(*((uint32_t*)per_commitment_point) == 33);
1782         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
1783         LDKHTLCOutputInCommitment htlc_conv;
1784         htlc_conv.inner = (void*)(htlc & (~1));
1785         htlc_conv.is_owned = false;
1786         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1787         *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);
1788         return (uint64_t)ret_conv;
1789 }
1790
1791 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) {
1792         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1793         LDKTransaction closing_tx_ref;
1794         closing_tx_ref.datalen = *((uint32_t*)closing_tx);
1795         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1796         memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen);
1797         closing_tx_ref.data_is_owned = true;
1798         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1799         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1800         return (uint64_t)ret_conv;
1801 }
1802
1803 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
1804         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1805         LDKUnsignedChannelAnnouncement msg_conv;
1806         msg_conv.inner = (void*)(msg & (~1));
1807         msg_conv.is_owned = false;
1808         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1809         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1810         return (uint64_t)ret_conv;
1811 }
1812
1813 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
1814         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1815         LDKChannelTransactionParameters channel_parameters_conv;
1816         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1817         channel_parameters_conv.is_owned = false;
1818         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1819 }
1820
1821 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
1822         if (this_arg->set_pubkeys != NULL)
1823                 this_arg->set_pubkeys(this_arg);
1824         return this_arg->pubkeys;
1825 }
1826 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
1827         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1828         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
1829         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1830         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1831         uint64_t ret_ref = (uint64_t)ret_var.inner;
1832         if (ret_var.is_owned) {
1833                 ret_ref |= 1;
1834         }
1835         return ret_ref;
1836 }
1837
1838 typedef struct LDKSign_JCalls {
1839         atomic_size_t refcnt;
1840         LDKBaseSign_JCalls* BaseSign;
1841         uint32_t write_meth;
1842 } LDKSign_JCalls;
1843 static void LDKSign_JCalls_free(void* this_arg) {
1844         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1845         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1846                 js_free(j_calls->write_meth);
1847                 FREE(j_calls);
1848         }
1849 }
1850 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
1851         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1852         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
1853         LDKCVec_u8Z ret_ref;
1854         ret_ref.datalen = *((uint32_t*)ret);
1855         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1856         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
1857         return ret_ref;
1858 }
1859 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
1860         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
1861         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1862         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
1863 }
1864 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
1865         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1866         atomic_init(&calls->refcnt, 1);
1867         //TODO: Assign calls->o from o
1868
1869         LDKChannelPublicKeys pubkeys_conv;
1870         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1871         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1872         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1873
1874         LDKSign ret = {
1875                 .this_arg = (void*) calls,
1876                 .write = write_LDKSign_jcall,
1877                 .cloned = LDKSign_JCalls_cloned,
1878                 .free = LDKSign_JCalls_free,
1879                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
1880         };
1881         calls->BaseSign = ret.BaseSign.this_arg;
1882         return ret;
1883 }
1884 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
1885         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
1886         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
1887         return (long)res_ptr;
1888 }
1889 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
1890         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1891         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1892         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1893         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
1894         CVec_u8Z_free(ret_var);
1895         return ret_arr;
1896 }
1897
1898 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
1899         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
1900 }
1901 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
1902         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
1903         CHECK(val->result_ok);
1904         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
1905         *ret = Sign_clone(&(*val->contents.result));
1906         return (uint64_t)ret;
1907 }
1908 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
1909         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
1910         CHECK(!val->result_ok);
1911         LDKDecodeError err_var = (*val->contents.err);
1912         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1913         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1914         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1915         return err_ref;
1916 }
1917 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_result_ok(uint32_t arg) {
1918         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
1919 }
1920 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_ok(uint32_t arg) {
1921         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
1922         CHECK(val->result_ok);
1923         int8_tArray es_arr = init_arr(68, sizeof(uint8_t), "Native int8_tArray Bytes");
1924         memcpy((uint8_t*)(es_arr + 4), (*val->contents.result).serialized_form, 68);
1925         return es_arr;
1926 }
1927 void  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_err(uint32_t arg) {
1928         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
1929         CHECK(!val->result_ok);
1930         return *val->contents.err;
1931 }
1932 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
1933         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
1934         for (size_t i = 0; i < ret.datalen; i++) {
1935                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
1936         }
1937         return ret;
1938 }
1939 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
1940         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
1941 }
1942 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
1943         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
1944         CHECK(val->result_ok);
1945         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
1946         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1947         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
1948         for (size_t m = 0; m < res_var.datalen; m++) {
1949                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
1950                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1951                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
1952                 res_arr_ptr[m] = res_conv_12_arr;
1953         }
1954         return res_arr;
1955 }
1956 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
1957         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
1958         CHECK(!val->result_ok);
1959         return *val->contents.err;
1960 }
1961 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
1962         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
1963 }
1964 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
1965         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
1966         CHECK(val->result_ok);
1967         LDKInMemorySigner res_var = (*val->contents.result);
1968         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1969         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1970         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1971         return res_ref;
1972 }
1973 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
1974         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
1975         CHECK(!val->result_ok);
1976         LDKDecodeError err_var = (*val->contents.err);
1977         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1978         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1979         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1980         return err_ref;
1981 }
1982 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
1983         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
1984         ret->datalen = *((uint32_t*)elems);
1985         if (ret->datalen == 0) {
1986                 ret->data = NULL;
1987         } else {
1988                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
1989                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1990                 for (size_t i = 0; i < ret->datalen; i++) {
1991                         uint32_t arr_elem = java_elems[i];
1992                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
1993                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
1994                         ret->data[i] = arr_elem_conv;
1995                 }
1996         }
1997         return (uint64_t)ret;
1998 }
1999 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2000         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2001         for (size_t i = 0; i < ret.datalen; i++) {
2002                 ret.data[i] = TxOut_clone(&orig->data[i]);
2003         }
2004         return ret;
2005 }
2006 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
2007         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2008 }
2009 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
2010         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2011         CHECK(val->result_ok);
2012         LDKTransaction res_var = (*val->contents.result);
2013         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2014         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
2015         return res_arr;
2016 }
2017 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
2018         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2019         CHECK(!val->result_ok);
2020         return *val->contents.err;
2021 }
2022 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
2023         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2024         LDKThirtyTwoBytes a_ref;
2025         CHECK(*((uint32_t*)a) == 32);
2026         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2027         ret->a = a_ref;
2028         LDKChannelMonitor b_conv;
2029         b_conv.inner = (void*)(b & (~1));
2030         b_conv.is_owned = (b & 1) || (b == 0);
2031         b_conv = ChannelMonitor_clone(&b_conv);
2032         ret->b = b_conv;
2033         return (uint64_t)ret;
2034 }
2035 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
2036         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2037         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2038         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2039         return a_arr;
2040 }
2041 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
2042         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2043         LDKChannelMonitor b_var = tuple->b;
2044         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2045         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2046         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2047         return b_ref;
2048 }
2049 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_BlockHashChannelMonitorZZ_new(uint32_tArray elems) {
2050         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2051         ret->datalen = *((uint32_t*)elems);
2052         if (ret->datalen == 0) {
2053                 ret->data = NULL;
2054         } else {
2055                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2056                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2057                 for (size_t i = 0; i < ret->datalen; i++) {
2058                         uint32_t arr_elem = java_elems[i];
2059                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2060                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2061                         ret->data[i] = arr_elem_conv;
2062                 }
2063         }
2064         return (uint64_t)ret;
2065 }
2066 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(uint32_t arg) {
2067         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2068 }
2069 uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(uint32_t arg) {
2070         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2071         CHECK(val->result_ok);
2072         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2073         uint32_tArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2074         uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
2075         for (size_t m = 0; m < res_var.datalen; m++) {
2076                 uint64_t res_conv_38_ref = (uint64_t)(&res_var.data[m]) | 1;
2077                 res_arr_ptr[m] = res_conv_38_ref;
2078         }
2079         return res_arr;
2080 }
2081 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
2082         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2083         CHECK(!val->result_ok);
2084         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
2085         return err_conv;
2086 }
2087 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) {
2088         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2089         switch(obj->tag) {
2090                 case LDKCOption_u16Z_Some: {
2091                         return 0 /* LDKCOption_u16Z - Some */; (void) obj->some;
2092                 }
2093                 case LDKCOption_u16Z_None: {
2094                         return 0 /* LDKCOption_u16Z - None */;
2095                 }
2096                 default: abort();
2097         }
2098 }
2099 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2100         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2101         switch(obj->tag) {
2102                 case LDKAPIError_APIMisuseError: {
2103                         LDKStr err_str = obj->api_misuse_error.err;
2104                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2105                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_conv;
2106                 }
2107                 case LDKAPIError_FeeRateTooHigh: {
2108                         LDKStr err_str = obj->fee_rate_too_high.err;
2109                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2110                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_conv; (void) obj->fee_rate_too_high.feerate;
2111                 }
2112                 case LDKAPIError_RouteError: {
2113                         LDKStr err_str = obj->route_error.err;
2114                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2115                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2116                 }
2117                 case LDKAPIError_ChannelUnavailable: {
2118                         LDKStr err_str = obj->channel_unavailable.err;
2119                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2120                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_conv;
2121                 }
2122                 case LDKAPIError_MonitorUpdateFailed: {
2123                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2124                 }
2125                 case LDKAPIError_IncompatibleShutdownScript: {
2126                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
2127                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2128                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2129                         uint64_t script_ref = (uint64_t)script_var.inner & ~1;
2130                         return 0 /* LDKAPIError - IncompatibleShutdownScript */; (void) script_ref;
2131                 }
2132                 default: abort();
2133         }
2134 }
2135 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
2136         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2137 }
2138 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2139         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2140         CHECK(val->result_ok);
2141         return *val->contents.result;
2142 }
2143 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2144         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2145         CHECK(!val->result_ok);
2146         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2147         return err_ref;
2148 }
2149 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
2150         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2151         ret->datalen = *((uint32_t*)elems);
2152         if (ret->datalen == 0) {
2153                 ret->data = NULL;
2154         } else {
2155                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2156                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2157                 for (size_t i = 0; i < ret->datalen; i++) {
2158                         uint32_t arr_elem = java_elems[i];
2159                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2160                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2161                         ret->data[i] = arr_elem_conv;
2162                 }
2163         }
2164         return (uint64_t)ret;
2165 }
2166 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2167         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2168         for (size_t i = 0; i < ret.datalen; i++) {
2169                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2170         }
2171         return ret;
2172 }
2173 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
2174         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2175         ret->datalen = *((uint32_t*)elems);
2176         if (ret->datalen == 0) {
2177                 ret->data = NULL;
2178         } else {
2179                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2180                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2181                 for (size_t i = 0; i < ret->datalen; i++) {
2182                         uint32_t arr_elem = java_elems[i];
2183                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2184                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
2185                         ret->data[i] = arr_elem_conv;
2186                 }
2187         }
2188         return (uint64_t)ret;
2189 }
2190 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2191         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2192         for (size_t i = 0; i < ret.datalen; i++) {
2193                 ret.data[i] = APIError_clone(&orig->data[i]);
2194         }
2195         return ret;
2196 }
2197 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2198         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
2199         switch(obj->tag) {
2200                 case LDKPaymentSendFailure_ParameterError: {
2201                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
2202                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
2203                 }
2204                 case LDKPaymentSendFailure_PathParameterError: {
2205                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
2206                         uint32_tArray path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2207                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
2208                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
2209                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2210                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
2211                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
2212                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
2213                         }
2214                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
2215                 }
2216                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2217                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
2218                         uint32_tArray all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2219                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
2220                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
2221                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
2222                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
2223                         }
2224                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
2225                 }
2226                 case LDKPaymentSendFailure_PartialFailure: {
2227                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
2228                         uint32_tArray partial_failure_arr = init_arr(partial_failure_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2229                         uint32_t *partial_failure_arr_ptr = (uint32_t*)(partial_failure_arr + 4);
2230                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
2231                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2232                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
2233                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
2234                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
2235                         }
2236                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) partial_failure_arr;
2237                 }
2238                 default: abort();
2239         }
2240 }
2241 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
2242         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2243 }
2244 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2245         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2246         CHECK(val->result_ok);
2247         return *val->contents.result;
2248 }
2249 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2250         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2251         CHECK(!val->result_ok);
2252         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2253         return err_ref;
2254 }
2255 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentHashPaymentSendFailureZ_result_ok(uint32_t arg) {
2256         return ((LDKCResult_PaymentHashPaymentSendFailureZ*)arg)->result_ok;
2257 }
2258 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentHashPaymentSendFailureZ_get_ok(uint32_t arg) {
2259         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
2260         CHECK(val->result_ok);
2261         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2262         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2263         return res_arr;
2264 }
2265 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentHashPaymentSendFailureZ_get_err(uint32_t arg) {
2266         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
2267         CHECK(!val->result_ok);
2268         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2269         return err_ref;
2270 }
2271 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
2272         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2273         switch(obj->tag) {
2274                 case LDKNetAddress_IPv4: {
2275                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
2276                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
2277                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
2278                 }
2279                 case LDKNetAddress_IPv6: {
2280                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
2281                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
2282                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
2283                 }
2284                 case LDKNetAddress_OnionV2: {
2285                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
2286                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
2287                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
2288                 }
2289                 case LDKNetAddress_OnionV3: {
2290                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2291                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
2292                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
2293                 }
2294                 default: abort();
2295         }
2296 }
2297 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
2298         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
2299         ret->datalen = *((uint32_t*)elems);
2300         if (ret->datalen == 0) {
2301                 ret->data = NULL;
2302         } else {
2303                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
2304                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2305                 for (size_t i = 0; i < ret->datalen; i++) {
2306                         uint32_t arr_elem = java_elems[i];
2307                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
2308                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
2309                         ret->data[i] = arr_elem_conv;
2310                 }
2311         }
2312         return (uint64_t)ret;
2313 }
2314 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2315         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2316         for (size_t i = 0; i < ret.datalen; i++) {
2317                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2318         }
2319         return ret;
2320 }
2321 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
2322         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
2323         LDKThirtyTwoBytes a_ref;
2324         CHECK(*((uint32_t*)a) == 32);
2325         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2326         ret->a = a_ref;
2327         LDKThirtyTwoBytes b_ref;
2328         CHECK(*((uint32_t*)b) == 32);
2329         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2330         ret->b = b_ref;
2331         return (uint64_t)ret;
2332 }
2333 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t ptr) {
2334         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
2335         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2336         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2337         return a_arr;
2338 }
2339 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t ptr) {
2340         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
2341         int8_tArray b_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2342         memcpy((uint8_t*)(b_arr + 4), tuple->b.data, 32);
2343         return b_arr;
2344 }
2345 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_result_ok(uint32_t arg) {
2346         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
2347 }
2348 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_ok(uint32_t arg) {
2349         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2350         CHECK(val->result_ok);
2351         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2352         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2353         return res_arr;
2354 }
2355 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_err(uint32_t arg) {
2356         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2357         CHECK(!val->result_ok);
2358         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2359         return err_ref;
2360 }
2361 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
2362         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2363         ret->datalen = *((uint32_t*)elems);
2364         if (ret->datalen == 0) {
2365                 ret->data = NULL;
2366         } else {
2367                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2368                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2369                 for (size_t i = 0; i < ret->datalen; i++) {
2370                         uint32_t arr_elem = java_elems[i];
2371                         LDKChannelMonitor arr_elem_conv;
2372                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2373                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2374                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2375                         ret->data[i] = arr_elem_conv;
2376                 }
2377         }
2378         return (uint64_t)ret;
2379 }
2380 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2381         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2382         for (size_t i = 0; i < ret.datalen; i++) {
2383                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2384         }
2385         return ret;
2386 }
2387 typedef struct LDKWatch_JCalls {
2388         atomic_size_t refcnt;
2389         uint32_t watch_channel_meth;
2390         uint32_t update_channel_meth;
2391         uint32_t release_pending_monitor_events_meth;
2392 } LDKWatch_JCalls;
2393 static void LDKWatch_JCalls_free(void* this_arg) {
2394         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2395         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2396                 js_free(j_calls->watch_channel_meth);
2397                 js_free(j_calls->update_channel_meth);
2398                 js_free(j_calls->release_pending_monitor_events_meth);
2399                 FREE(j_calls);
2400         }
2401 }
2402 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2403         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2404         LDKOutPoint funding_txo_var = funding_txo;
2405         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2406         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2407         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2408         if (funding_txo_var.is_owned) {
2409                 funding_txo_ref |= 1;
2410         }
2411         LDKChannelMonitor monitor_var = monitor;
2412         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2413         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2414         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
2415         if (monitor_var.is_owned) {
2416                 monitor_ref |= 1;
2417         }
2418         uint32_t ret = js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2419         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2420         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2421         return ret_conv;
2422 }
2423 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2424         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2425         LDKOutPoint funding_txo_var = funding_txo;
2426         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2427         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2428         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2429         if (funding_txo_var.is_owned) {
2430                 funding_txo_ref |= 1;
2431         }
2432         LDKChannelMonitorUpdate update_var = update;
2433         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2434         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2435         uint64_t update_ref = (uint64_t)update_var.inner;
2436         if (update_var.is_owned) {
2437                 update_ref |= 1;
2438         }
2439         uint32_t ret = js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2440         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2441         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2442         return ret_conv;
2443 }
2444 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
2445         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2446         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2447         LDKCVec_MonitorEventZ ret_constr;
2448         ret_constr.datalen = *((uint32_t*)ret);
2449         if (ret_constr.datalen > 0)
2450                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2451         else
2452                 ret_constr.data = NULL;
2453         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2454         for (size_t o = 0; o < ret_constr.datalen; o++) {
2455                 uint32_t ret_conv_14 = ret_vals[o];
2456                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
2457                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
2458                 ret_constr.data[o] = ret_conv_14_conv;
2459         }
2460         return ret_constr;
2461 }
2462 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
2463         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
2464         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2465 }
2466 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2467         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2468         atomic_init(&calls->refcnt, 1);
2469         //TODO: Assign calls->o from o
2470
2471         LDKWatch ret = {
2472                 .this_arg = (void*) calls,
2473                 .watch_channel = watch_channel_LDKWatch_jcall,
2474                 .update_channel = update_channel_LDKWatch_jcall,
2475                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
2476                 .free = LDKWatch_JCalls_free,
2477         };
2478         return ret;
2479 }
2480 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2481         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2482         *res_ptr = LDKWatch_init(o);
2483         return (long)res_ptr;
2484 }
2485 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2486         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2487         LDKOutPoint funding_txo_conv;
2488         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2489         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2490         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2491         LDKChannelMonitor monitor_conv;
2492         monitor_conv.inner = (void*)(monitor & (~1));
2493         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2494         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2495         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2496         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2497         return (uint64_t)ret_conv;
2498 }
2499
2500 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
2501         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2502         LDKOutPoint funding_txo_conv;
2503         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2504         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2505         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2506         LDKChannelMonitorUpdate update_conv;
2507         update_conv.inner = (void*)(update & (~1));
2508         update_conv.is_owned = (update & 1) || (update == 0);
2509         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2510         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2511         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2512         return (uint64_t)ret_conv;
2513 }
2514
2515 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
2516         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2517         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2518         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2519         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2520         for (size_t o = 0; o < ret_var.datalen; o++) {
2521                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2522                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
2523                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
2524                 ret_arr_ptr[o] = ret_conv_14_ref;
2525         }
2526         FREE(ret_var.data);
2527         return ret_arr;
2528 }
2529
2530 typedef struct LDKBroadcasterInterface_JCalls {
2531         atomic_size_t refcnt;
2532         uint32_t broadcast_transaction_meth;
2533 } LDKBroadcasterInterface_JCalls;
2534 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2535         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2536         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2537                 js_free(j_calls->broadcast_transaction_meth);
2538                 FREE(j_calls);
2539         }
2540 }
2541 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
2542         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2543         LDKTransaction tx_var = tx;
2544         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2545         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
2546         Transaction_free(tx_var);
2547         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
2548 }
2549 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
2550         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
2551         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2552 }
2553 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
2554         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2555         atomic_init(&calls->refcnt, 1);
2556         //TODO: Assign calls->o from o
2557
2558         LDKBroadcasterInterface ret = {
2559                 .this_arg = (void*) calls,
2560                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
2561                 .free = LDKBroadcasterInterface_JCalls_free,
2562         };
2563         return ret;
2564 }
2565 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
2566         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2567         *res_ptr = LDKBroadcasterInterface_init(o);
2568         return (long)res_ptr;
2569 }
2570 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
2571         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
2572         LDKTransaction tx_ref;
2573         tx_ref.datalen = *((uint32_t*)tx);
2574         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2575         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
2576         tx_ref.data_is_owned = true;
2577         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2578 }
2579
2580 typedef struct LDKKeysInterface_JCalls {
2581         atomic_size_t refcnt;
2582         uint32_t get_node_secret_meth;
2583         uint32_t get_destination_script_meth;
2584         uint32_t get_shutdown_scriptpubkey_meth;
2585         uint32_t get_channel_signer_meth;
2586         uint32_t get_secure_random_bytes_meth;
2587         uint32_t read_chan_signer_meth;
2588         uint32_t sign_invoice_meth;
2589 } LDKKeysInterface_JCalls;
2590 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2591         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2592         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2593                 js_free(j_calls->get_node_secret_meth);
2594                 js_free(j_calls->get_destination_script_meth);
2595                 js_free(j_calls->get_shutdown_scriptpubkey_meth);
2596                 js_free(j_calls->get_channel_signer_meth);
2597                 js_free(j_calls->get_secure_random_bytes_meth);
2598                 js_free(j_calls->read_chan_signer_meth);
2599                 js_free(j_calls->sign_invoice_meth);
2600                 FREE(j_calls);
2601         }
2602 }
2603 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
2604         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2605         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
2606         LDKSecretKey ret_ref;
2607         CHECK(*((uint32_t*)ret) == 32);
2608         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
2609         return ret_ref;
2610 }
2611 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
2612         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2613         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
2614         LDKCVec_u8Z ret_ref;
2615         ret_ref.datalen = *((uint32_t*)ret);
2616         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2617         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2618         return ret_ref;
2619 }
2620 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
2621         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2622         uint32_t ret = js_invoke_function_0(j_calls->get_shutdown_scriptpubkey_meth);
2623         LDKShutdownScript ret_conv;
2624         ret_conv.inner = (void*)(ret & (~1));
2625         ret_conv.is_owned = (ret & 1) || (ret == 0);
2626         ret_conv = ShutdownScript_clone(&ret_conv);
2627         return ret_conv;
2628 }
2629 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2630         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2631         uint32_t ret = js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
2632         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
2633         ret_conv = Sign_clone(&ret_conv);
2634         return ret_conv;
2635 }
2636 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
2637         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2638         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
2639         LDKThirtyTwoBytes ret_ref;
2640         CHECK(*((uint32_t*)ret) == 32);
2641         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
2642         return ret_ref;
2643 }
2644 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
2645         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2646         LDKu8slice reader_var = reader;
2647         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2648         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
2649         uint32_t ret = js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
2650         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
2651         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
2652         return ret_conv;
2653 }
2654 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
2655         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2656         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
2657         int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2658         memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
2659         CVec_u8Z_free(invoice_preimage_var);
2660         uint32_t ret = js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
2661         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
2662         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
2663         return ret_conv;
2664 }
2665 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
2666         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
2667         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2668 }
2669 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
2670         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2671         atomic_init(&calls->refcnt, 1);
2672         //TODO: Assign calls->o from o
2673
2674         LDKKeysInterface ret = {
2675                 .this_arg = (void*) calls,
2676                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
2677                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
2678                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
2679                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
2680                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
2681                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
2682                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
2683                 .free = LDKKeysInterface_JCalls_free,
2684         };
2685         return ret;
2686 }
2687 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
2688         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2689         *res_ptr = LDKKeysInterface_init(o);
2690         return (long)res_ptr;
2691 }
2692 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
2693         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2694         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2695         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
2696         return ret_arr;
2697 }
2698
2699 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
2700         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2701         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2702         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2703         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2704         CVec_u8Z_free(ret_var);
2705         return ret_arr;
2706 }
2707
2708 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
2709         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2710         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
2711         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2712         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2713         uint64_t ret_ref = (uint64_t)ret_var.inner;
2714         if (ret_var.is_owned) {
2715                 ret_ref |= 1;
2716         }
2717         return ret_ref;
2718 }
2719
2720 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
2721         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2722         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2723         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2724         return (uint64_t)ret;
2725 }
2726
2727 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2728         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2729         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2730         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2731         return ret_arr;
2732 }
2733
2734 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2735         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2736         LDKu8slice reader_ref;
2737         reader_ref.datalen = *((uint32_t*)reader);
2738         reader_ref.data = (int8_t*)(reader + 4);
2739         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
2740         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2741         return (uint64_t)ret_conv;
2742 }
2743
2744 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
2745         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2746         LDKCVec_u8Z invoice_preimage_ref;
2747         invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
2748         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
2749         memcpy(invoice_preimage_ref.data, (uint8_t*)(invoice_preimage + 4), invoice_preimage_ref.datalen);
2750         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
2751         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
2752         return (uint64_t)ret_conv;
2753 }
2754
2755 typedef struct LDKFeeEstimator_JCalls {
2756         atomic_size_t refcnt;
2757         uint32_t get_est_sat_per_1000_weight_meth;
2758 } LDKFeeEstimator_JCalls;
2759 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2760         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2761         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2762                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
2763                 FREE(j_calls);
2764         }
2765 }
2766 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2767         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2768         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
2769         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2770 }
2771 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
2772         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
2773         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2774 }
2775 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
2776         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2777         atomic_init(&calls->refcnt, 1);
2778         //TODO: Assign calls->o from o
2779
2780         LDKFeeEstimator ret = {
2781                 .this_arg = (void*) calls,
2782                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
2783                 .free = LDKFeeEstimator_JCalls_free,
2784         };
2785         return ret;
2786 }
2787 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
2788         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2789         *res_ptr = LDKFeeEstimator_init(o);
2790         return (long)res_ptr;
2791 }
2792 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
2793         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
2794         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
2795         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2796         return ret_val;
2797 }
2798
2799 typedef struct LDKLogger_JCalls {
2800         atomic_size_t refcnt;
2801         uint32_t log_meth;
2802 } LDKLogger_JCalls;
2803 static void LDKLogger_JCalls_free(void* this_arg) {
2804         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2805         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2806                 js_free(j_calls->log_meth);
2807                 FREE(j_calls);
2808         }
2809 }
2810 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
2811         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2812         const char* record_str = record;
2813         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
2814         js_invoke_function_1(j_calls->log_meth, record_conv);
2815 }
2816 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
2817         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
2818         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2819 }
2820 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
2821         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2822         atomic_init(&calls->refcnt, 1);
2823         //TODO: Assign calls->o from o
2824
2825         LDKLogger ret = {
2826                 .this_arg = (void*) calls,
2827                 .log = log_LDKLogger_jcall,
2828                 .free = LDKLogger_JCalls_free,
2829         };
2830         return ret;
2831 }
2832 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
2833         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2834         *res_ptr = LDKLogger_init(o);
2835         return (long)res_ptr;
2836 }
2837 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
2838         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
2839         LDKThirtyTwoBytes a_ref;
2840         CHECK(*((uint32_t*)a) == 32);
2841         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2842         ret->a = a_ref;
2843         LDKChannelManager b_conv;
2844         b_conv.inner = (void*)(b & (~1));
2845         b_conv.is_owned = (b & 1) || (b == 0);
2846         // Warning: we need a move here but no clone is available for LDKChannelManager
2847         ret->b = b_conv;
2848         return (uint64_t)ret;
2849 }
2850 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
2851         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2852         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2853         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2854         return a_arr;
2855 }
2856 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
2857         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2858         LDKChannelManager b_var = tuple->b;
2859         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2860         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2861         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2862         return b_ref;
2863 }
2864 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
2865         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
2866 }
2867 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
2868         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2869         CHECK(val->result_ok);
2870         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2871         return res_ref;
2872 }
2873 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
2874         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2875         CHECK(!val->result_ok);
2876         LDKDecodeError err_var = (*val->contents.err);
2877         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2878         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2879         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2880         return err_ref;
2881 }
2882 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
2883         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
2884 }
2885 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
2886         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
2887         CHECK(val->result_ok);
2888         LDKChannelConfig res_var = (*val->contents.result);
2889         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2890         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2891         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2892         return res_ref;
2893 }
2894 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
2895         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
2896         CHECK(!val->result_ok);
2897         LDKDecodeError err_var = (*val->contents.err);
2898         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2899         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2900         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2901         return err_ref;
2902 }
2903 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
2904         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
2905 }
2906 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
2907         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
2908         CHECK(val->result_ok);
2909         LDKOutPoint res_var = (*val->contents.result);
2910         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2911         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2912         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2913         return res_ref;
2914 }
2915 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
2916         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
2917         CHECK(!val->result_ok);
2918         LDKDecodeError err_var = (*val->contents.err);
2919         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2920         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2921         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2922         return err_ref;
2923 }
2924 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) {
2925         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
2926 }
2927 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_ok(uint32_t arg) {
2928         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
2929         CHECK(val->result_ok);
2930         uint32_t res_conv = LDKSiPrefix_to_js((*val->contents.result));
2931         return res_conv;
2932 }
2933 void  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_err(uint32_t arg) {
2934         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
2935         CHECK(!val->result_ok);
2936         return *val->contents.err;
2937 }
2938 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_result_ok(uint32_t arg) {
2939         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
2940 }
2941 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_ok(uint32_t arg) {
2942         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
2943         CHECK(val->result_ok);
2944         LDKInvoice res_var = (*val->contents.result);
2945         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2946         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2947         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2948         return res_ref;
2949 }
2950 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
2951         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
2952         CHECK(!val->result_ok);
2953         return *val->contents.err;
2954 }
2955 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_result_ok(uint32_t arg) {
2956         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
2957 }
2958 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_ok(uint32_t arg) {
2959         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
2960         CHECK(val->result_ok);
2961         LDKSignedRawInvoice res_var = (*val->contents.result);
2962         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2963         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2964         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2965         return res_ref;
2966 }
2967 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
2968         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
2969         CHECK(!val->result_ok);
2970         return *val->contents.err;
2971 }
2972 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
2973         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
2974         LDKRawInvoice a_conv;
2975         a_conv.inner = (void*)(a & (~1));
2976         a_conv.is_owned = (a & 1) || (a == 0);
2977         a_conv = RawInvoice_clone(&a_conv);
2978         ret->a = a_conv;
2979         LDKThirtyTwoBytes b_ref;
2980         CHECK(*((uint32_t*)b) == 32);
2981         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2982         ret->b = b_ref;
2983         LDKInvoiceSignature c_conv;
2984         c_conv.inner = (void*)(c & (~1));
2985         c_conv.is_owned = (c & 1) || (c == 0);
2986         c_conv = InvoiceSignature_clone(&c_conv);
2987         ret->c = c_conv;
2988         return (uint64_t)ret;
2989 }
2990 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t ptr) {
2991         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2992         LDKRawInvoice a_var = tuple->a;
2993         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2994         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2995         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
2996         return a_ref;
2997 }
2998 int8_tArray  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t ptr) {
2999         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
3000         int8_tArray b_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3001         memcpy((uint8_t*)(b_arr + 4), tuple->b.data, 32);
3002         return b_arr;
3003 }
3004 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t ptr) {
3005         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
3006         LDKInvoiceSignature c_var = tuple->c;
3007         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3008         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3009         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
3010         return c_ref;
3011 }
3012 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_result_ok(uint32_t arg) {
3013         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
3014 }
3015 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_ok(uint32_t arg) {
3016         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3017         CHECK(val->result_ok);
3018         LDKPayeePubKey res_var = (*val->contents.result);
3019         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3020         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3021         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3022         return res_ref;
3023 }
3024 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
3025         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3026         CHECK(!val->result_ok);
3027         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3028         return err_conv;
3029 }
3030 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_PrivateRouteZ_new(uint32_tArray elems) {
3031         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
3032         ret->datalen = *((uint32_t*)elems);
3033         if (ret->datalen == 0) {
3034                 ret->data = NULL;
3035         } else {
3036                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
3037                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3038                 for (size_t i = 0; i < ret->datalen; i++) {
3039                         uint32_t arr_elem = java_elems[i];
3040                         LDKPrivateRoute arr_elem_conv;
3041                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3042                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3043                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
3044                         ret->data[i] = arr_elem_conv;
3045                 }
3046         }
3047         return (uint64_t)ret;
3048 }
3049 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
3050         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
3051         for (size_t i = 0; i < ret.datalen; i++) {
3052                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
3053         }
3054         return ret;
3055 }
3056 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_result_ok(uint32_t arg) {
3057         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
3058 }
3059 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t arg) {
3060         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3061         CHECK(val->result_ok);
3062         LDKPositiveTimestamp res_var = (*val->contents.result);
3063         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3064         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3065         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3066         return res_ref;
3067 }
3068 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
3069         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3070         CHECK(!val->result_ok);
3071         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3072         return err_conv;
3073 }
3074 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_result_ok(uint32_t arg) {
3075         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
3076 }
3077 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_ok(uint32_t arg) {
3078         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3079         CHECK(val->result_ok);
3080         return *val->contents.result;
3081 }
3082 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_err(uint32_t arg) {
3083         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3084         CHECK(!val->result_ok);
3085         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3086         return err_conv;
3087 }
3088 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_result_ok(uint32_t arg) {
3089         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
3090 }
3091 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_ok(uint32_t arg) {
3092         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3093         CHECK(val->result_ok);
3094         LDKInvoice res_var = (*val->contents.result);
3095         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3096         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3097         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3098         return res_ref;
3099 }
3100 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
3101         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3102         CHECK(!val->result_ok);
3103         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3104         return err_conv;
3105 }
3106 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_result_ok(uint32_t arg) {
3107         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
3108 }
3109 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_ok(uint32_t arg) {
3110         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3111         CHECK(val->result_ok);
3112         LDKDescription res_var = (*val->contents.result);
3113         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3114         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3115         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3116         return res_ref;
3117 }
3118 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
3119         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3120         CHECK(!val->result_ok);
3121         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3122         return err_conv;
3123 }
3124 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_result_ok(uint32_t arg) {
3125         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
3126 }
3127 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_ok(uint32_t arg) {
3128         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3129         CHECK(val->result_ok);
3130         LDKExpiryTime res_var = (*val->contents.result);
3131         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3132         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3133         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3134         return res_ref;
3135 }
3136 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
3137         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3138         CHECK(!val->result_ok);
3139         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3140         return err_conv;
3141 }
3142 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_result_ok(uint32_t arg) {
3143         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
3144 }
3145 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_ok(uint32_t arg) {
3146         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3147         CHECK(val->result_ok);
3148         LDKPrivateRoute res_var = (*val->contents.result);
3149         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3150         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3151         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3152         return res_ref;
3153 }
3154 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
3155         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3156         CHECK(!val->result_ok);
3157         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3158         return err_conv;
3159 }
3160 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_result_ok(uint32_t arg) {
3161         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
3162 }
3163 jstring  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_ok(uint32_t arg) {
3164         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3165         CHECK(val->result_ok);
3166         LDKStr res_str = (*val->contents.result);
3167         jstring res_conv = str_ref_to_ts(res_str.chars, res_str.len);
3168         return res_conv;
3169 }
3170 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_err(uint32_t arg) {
3171         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3172         CHECK(!val->result_ok);
3173         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3174         return err_conv;
3175 }
3176 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3177         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
3178 }
3179 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3180         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3181         CHECK(val->result_ok);
3182         LDKChannelMonitorUpdate res_var = (*val->contents.result);
3183         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3184         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3185         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3186         return res_ref;
3187 }
3188 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
3189         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3190         CHECK(!val->result_ok);
3191         LDKDecodeError err_var = (*val->contents.err);
3192         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3193         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3194         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3195         return err_ref;
3196 }
3197 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3198         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
3199 }
3200 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3201         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3202         CHECK(val->result_ok);
3203         LDKHTLCUpdate res_var = (*val->contents.result);
3204         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3205         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3206         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3207         return res_ref;
3208 }
3209 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
3210         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3211         CHECK(!val->result_ok);
3212         LDKDecodeError err_var = (*val->contents.err);
3213         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3214         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3215         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3216         return err_ref;
3217 }
3218 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
3219         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
3220 }
3221 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
3222         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3223         CHECK(val->result_ok);
3224         return *val->contents.result;
3225 }
3226 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
3227         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3228         CHECK(!val->result_ok);
3229         LDKMonitorUpdateError err_var = (*val->contents.err);
3230         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3231         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3232         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3233         return err_ref;
3234 }
3235 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
3236         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
3237         LDKOutPoint a_conv;
3238         a_conv.inner = (void*)(a & (~1));
3239         a_conv.is_owned = (a & 1) || (a == 0);
3240         a_conv = OutPoint_clone(&a_conv);
3241         ret->a = a_conv;
3242         LDKCVec_u8Z b_ref;
3243         b_ref.datalen = *((uint32_t*)b);
3244         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3245         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3246         ret->b = b_ref;
3247         return (uint64_t)ret;
3248 }
3249 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
3250         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
3251         LDKOutPoint a_var = tuple->a;
3252         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3253         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3254         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3255         return a_ref;
3256 }
3257 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
3258         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
3259         LDKCVec_u8Z b_var = tuple->b;
3260         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3261         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
3262         return b_arr;
3263 }
3264 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
3265         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
3266         ret->a = a;
3267         LDKCVec_u8Z b_ref;
3268         b_ref.datalen = *((uint32_t*)b);
3269         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3270         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3271         ret->b = b_ref;
3272         return (uint64_t)ret;
3273 }
3274 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_a(uint32_t ptr) {
3275         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
3276         return tuple->a;
3277 }
3278 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_b(uint32_t ptr) {
3279         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
3280         LDKCVec_u8Z b_var = tuple->b;
3281         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3282         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
3283         return b_arr;
3284 }
3285 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
3286         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
3287         ret->datalen = *((uint32_t*)elems);
3288         if (ret->datalen == 0) {
3289                 ret->data = NULL;
3290         } else {
3291                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
3292                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3293                 for (size_t i = 0; i < ret->datalen; i++) {
3294                         uint32_t arr_elem = java_elems[i];
3295                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
3296                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
3297                         ret->data[i] = arr_elem_conv;
3298                 }
3299         }
3300         return (uint64_t)ret;
3301 }
3302 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
3303         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
3304         for (size_t i = 0; i < ret.datalen; i++) {
3305                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
3306         }
3307         return ret;
3308 }
3309 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
3310         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
3311         LDKThirtyTwoBytes a_ref;
3312         CHECK(*((uint32_t*)a) == 32);
3313         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3314         ret->a = a_ref;
3315         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
3316         b_constr.datalen = *((uint32_t*)b);
3317         if (b_constr.datalen > 0)
3318                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
3319         else
3320                 b_constr.data = NULL;
3321         uint32_t* b_vals = (uint32_t*)(b + 4);
3322         for (size_t e = 0; e < b_constr.datalen; e++) {
3323                 uint32_t b_conv_30 = b_vals[e];
3324                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
3325                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
3326                 b_constr.data[e] = b_conv_30_conv;
3327         }
3328         ret->b = b_constr;
3329         return (uint64_t)ret;
3330 }
3331 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t ptr) {
3332         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
3333         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3334         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
3335         return a_arr;
3336 }
3337 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t ptr) {
3338         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
3339         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
3340         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3341         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
3342         for (size_t e = 0; e < b_var.datalen; e++) {
3343                 uint64_t b_conv_30_ref = (uint64_t)(&b_var.data[e]) | 1;
3344                 b_arr_ptr[e] = b_conv_30_ref;
3345         }
3346         return b_arr;
3347 }
3348 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
3349         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
3350         ret->datalen = *((uint32_t*)elems);
3351         if (ret->datalen == 0) {
3352                 ret->data = NULL;
3353         } else {
3354                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
3355                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3356                 for (size_t i = 0; i < ret->datalen; i++) {
3357                         uint32_t arr_elem = java_elems[i];
3358                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
3359                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
3360                         ret->data[i] = arr_elem_conv;
3361                 }
3362         }
3363         return (uint64_t)ret;
3364 }
3365 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
3366         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 };
3367         for (size_t i = 0; i < ret.datalen; i++) {
3368                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
3369         }
3370         return ret;
3371 }
3372 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentPurpose_ref_from_ptr(uint32_t ptr) {
3373         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
3374         switch(obj->tag) {
3375                 case LDKPaymentPurpose_InvoicePayment: {
3376                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3377                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->invoice_payment.payment_preimage.data, 32);
3378                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3379                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->invoice_payment.payment_secret.data, 32);
3380                         return 0 /* LDKPaymentPurpose - InvoicePayment */; (void) payment_preimage_arr; (void) payment_secret_arr; (void) obj->invoice_payment.user_payment_id;
3381                 }
3382                 case LDKPaymentPurpose_SpontaneousPayment: {
3383                         int8_tArray spontaneous_payment_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3384                         memcpy((uint8_t*)(spontaneous_payment_arr + 4), obj->spontaneous_payment.data, 32);
3385                         return 0 /* LDKPaymentPurpose - SpontaneousPayment */; (void) spontaneous_payment_arr;
3386                 }
3387                 default: abort();
3388         }
3389 }
3390 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
3391         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
3392         switch(obj->tag) {
3393                 case LDKEvent_FundingGenerationReady: {
3394                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3395                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
3396                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3397                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3398                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
3399                         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;
3400                 }
3401                 case LDKEvent_PaymentReceived: {
3402                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3403                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
3404                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
3405                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) obj->payment_received.amt; (void) purpose_ref;
3406                 }
3407                 case LDKEvent_PaymentSent: {
3408                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3409                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
3410                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
3411                 }
3412                 case LDKEvent_PaymentFailed: {
3413                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3414                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
3415                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
3416                 }
3417                 case LDKEvent_PendingHTLCsForwardable: {
3418                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
3419                 }
3420                 case LDKEvent_SpendableOutputs: {
3421                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3422                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3423                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
3424                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3425                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
3426                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3427                         }
3428                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
3429                 }
3430                 case LDKEvent_PaymentForwarded: {
3431                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
3432                         return 0 /* LDKEvent - PaymentForwarded */; (void) fee_earned_msat_ref; (void) obj->payment_forwarded.claim_from_onchain_tx;
3433                 }
3434                 default: abort();
3435         }
3436 }
3437 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
3438         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
3439         ret->datalen = *((uint32_t*)elems);
3440         if (ret->datalen == 0) {
3441                 ret->data = NULL;
3442         } else {
3443                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
3444                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3445                 for (size_t i = 0; i < ret->datalen; i++) {
3446                         uint32_t arr_elem = java_elems[i];
3447                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
3448                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
3449                         ret->data[i] = arr_elem_conv;
3450                 }
3451         }
3452         return (uint64_t)ret;
3453 }
3454 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
3455         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
3456         for (size_t i = 0; i < ret.datalen; i++) {
3457                 ret.data[i] = Event_clone(&orig->data[i]);
3458         }
3459         return ret;
3460 }
3461 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
3462         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
3463         ret->a = a;
3464         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
3465         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
3466         ret->b = b_conv;
3467         return (uint64_t)ret;
3468 }
3469 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
3470         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
3471         return tuple->a;
3472 }
3473 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
3474         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
3475         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
3476         return (uint64_t)b_ref;
3477 }
3478 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
3479         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
3480         ret->datalen = *((uint32_t*)elems);
3481         if (ret->datalen == 0) {
3482                 ret->data = NULL;
3483         } else {
3484                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
3485                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3486                 for (size_t i = 0; i < ret->datalen; i++) {
3487                         uint32_t arr_elem = java_elems[i];
3488                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
3489                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
3490                         ret->data[i] = arr_elem_conv;
3491                 }
3492         }
3493         return (uint64_t)ret;
3494 }
3495 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
3496         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
3497         for (size_t i = 0; i < ret.datalen; i++) {
3498                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
3499         }
3500         return ret;
3501 }
3502 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
3503         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
3504         LDKThirtyTwoBytes a_ref;
3505         CHECK(*((uint32_t*)a) == 32);
3506         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3507         ret->a = a_ref;
3508         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
3509         b_constr.datalen = *((uint32_t*)b);
3510         if (b_constr.datalen > 0)
3511                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
3512         else
3513                 b_constr.data = NULL;
3514         uint32_t* b_vals = (uint32_t*)(b + 4);
3515         for (size_t z = 0; z < b_constr.datalen; z++) {
3516                 uint32_t b_conv_25 = b_vals[z];
3517                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
3518                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
3519                 b_constr.data[z] = b_conv_25_conv;
3520         }
3521         ret->b = b_constr;
3522         return (uint64_t)ret;
3523 }
3524 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
3525         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
3526         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3527         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
3528         return a_arr;
3529 }
3530 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
3531         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
3532         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
3533         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3534         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
3535         for (size_t z = 0; z < b_var.datalen; z++) {
3536                 uint64_t b_conv_25_ref = (uint64_t)(&b_var.data[z]) | 1;
3537                 b_arr_ptr[z] = b_conv_25_ref;
3538         }
3539         return b_arr;
3540 }
3541 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
3542         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
3543         ret->datalen = *((uint32_t*)elems);
3544         if (ret->datalen == 0) {
3545                 ret->data = NULL;
3546         } else {
3547                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
3548                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3549                 for (size_t i = 0; i < ret->datalen; i++) {
3550                         uint32_t arr_elem = java_elems[i];
3551                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
3552                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
3553                         ret->data[i] = arr_elem_conv;
3554                 }
3555         }
3556         return (uint64_t)ret;
3557 }
3558 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
3559         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 };
3560         for (size_t i = 0; i < ret.datalen; i++) {
3561                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
3562         }
3563         return ret;
3564 }
3565 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
3566         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
3567 }
3568 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
3569         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
3570         CHECK(val->result_ok);
3571         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
3572         return res_ref;
3573 }
3574 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
3575         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
3576         CHECK(!val->result_ok);
3577         LDKDecodeError err_var = (*val->contents.err);
3578         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3579         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3580         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3581         return err_ref;
3582 }
3583 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
3584         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3585 }
3586 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
3587         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
3588         CHECK(val->result_ok);
3589         return *val->contents.result;
3590 }
3591 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
3592         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
3593         CHECK(!val->result_ok);
3594         LDKLightningError err_var = (*val->contents.err);
3595         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3596         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3597         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3598         return err_ref;
3599 }
3600 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
3601         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
3602         LDKChannelAnnouncement a_conv;
3603         a_conv.inner = (void*)(a & (~1));
3604         a_conv.is_owned = (a & 1) || (a == 0);
3605         a_conv = ChannelAnnouncement_clone(&a_conv);
3606         ret->a = a_conv;
3607         LDKChannelUpdate b_conv;
3608         b_conv.inner = (void*)(b & (~1));
3609         b_conv.is_owned = (b & 1) || (b == 0);
3610         b_conv = ChannelUpdate_clone(&b_conv);
3611         ret->b = b_conv;
3612         LDKChannelUpdate c_conv;
3613         c_conv.inner = (void*)(c & (~1));
3614         c_conv.is_owned = (c & 1) || (c == 0);
3615         c_conv = ChannelUpdate_clone(&c_conv);
3616         ret->c = c_conv;
3617         return (uint64_t)ret;
3618 }
3619 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t ptr) {
3620         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3621         LDKChannelAnnouncement a_var = tuple->a;
3622         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3623         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3624         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3625         return a_ref;
3626 }
3627 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t ptr) {
3628         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3629         LDKChannelUpdate b_var = tuple->b;
3630         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3631         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3632         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
3633         return b_ref;
3634 }
3635 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t ptr) {
3636         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3637         LDKChannelUpdate c_var = tuple->c;
3638         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3639         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3640         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
3641         return c_ref;
3642 }
3643 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
3644         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
3645         ret->datalen = *((uint32_t*)elems);
3646         if (ret->datalen == 0) {
3647                 ret->data = NULL;
3648         } else {
3649                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
3650                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3651                 for (size_t i = 0; i < ret->datalen; i++) {
3652                         uint32_t arr_elem = java_elems[i];
3653                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
3654                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
3655                         ret->data[i] = arr_elem_conv;
3656                 }
3657         }
3658         return (uint64_t)ret;
3659 }
3660 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3661         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3662         for (size_t i = 0; i < ret.datalen; i++) {
3663                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3664         }
3665         return ret;
3666 }
3667 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
3668         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
3669         ret->datalen = *((uint32_t*)elems);
3670         if (ret->datalen == 0) {
3671                 ret->data = NULL;
3672         } else {
3673                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
3674                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3675                 for (size_t i = 0; i < ret->datalen; i++) {
3676                         uint32_t arr_elem = java_elems[i];
3677                         LDKNodeAnnouncement arr_elem_conv;
3678                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3679                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3680                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
3681                         ret->data[i] = arr_elem_conv;
3682                 }
3683         }
3684         return (uint64_t)ret;
3685 }
3686 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3687         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3688         for (size_t i = 0; i < ret.datalen; i++) {
3689                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3690         }
3691         return ret;
3692 }
3693 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
3694         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
3695 }
3696 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
3697         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
3698         CHECK(val->result_ok);
3699         return *val->contents.result;
3700 }
3701 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
3702         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
3703         CHECK(!val->result_ok);
3704         LDKLightningError err_var = (*val->contents.err);
3705         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3706         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3707         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3708         return err_ref;
3709 }
3710 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
3711         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
3712 }
3713 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
3714         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
3715         CHECK(val->result_ok);
3716         LDKCVec_u8Z res_var = (*val->contents.result);
3717         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3718         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
3719         return res_arr;
3720 }
3721 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
3722         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
3723         CHECK(!val->result_ok);
3724         LDKPeerHandleError err_var = (*val->contents.err);
3725         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3726         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3727         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3728         return err_ref;
3729 }
3730 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
3731         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
3732 }
3733 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
3734         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
3735         CHECK(val->result_ok);
3736         return *val->contents.result;
3737 }
3738 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
3739         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
3740         CHECK(!val->result_ok);
3741         LDKPeerHandleError err_var = (*val->contents.err);
3742         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3743         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3744         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3745         return err_ref;
3746 }
3747 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
3748         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
3749 }
3750 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
3751         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
3752         CHECK(val->result_ok);
3753         return *val->contents.result;
3754 }
3755 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
3756         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
3757         CHECK(!val->result_ok);
3758         LDKPeerHandleError err_var = (*val->contents.err);
3759         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3760         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3761         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3762         return err_ref;
3763 }
3764 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
3765         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
3766 }
3767 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
3768         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
3769         CHECK(val->result_ok);
3770         LDKDirectionalChannelInfo res_var = (*val->contents.result);
3771         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3772         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3773         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3774         return res_ref;
3775 }
3776 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
3777         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
3778         CHECK(!val->result_ok);
3779         LDKDecodeError err_var = (*val->contents.err);
3780         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3781         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3782         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3783         return err_ref;
3784 }
3785 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
3786         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
3787 }
3788 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
3789         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
3790         CHECK(val->result_ok);
3791         LDKChannelInfo res_var = (*val->contents.result);
3792         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3793         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3794         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3795         return res_ref;
3796 }
3797 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
3798         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
3799         CHECK(!val->result_ok);
3800         LDKDecodeError err_var = (*val->contents.err);
3801         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3802         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3803         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3804         return err_ref;
3805 }
3806 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
3807         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
3808 }
3809 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
3810         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
3811         CHECK(val->result_ok);
3812         LDKRoutingFees res_var = (*val->contents.result);
3813         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3814         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3815         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3816         return res_ref;
3817 }
3818 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
3819         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
3820         CHECK(!val->result_ok);
3821         LDKDecodeError err_var = (*val->contents.err);
3822         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3823         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3824         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3825         return err_ref;
3826 }
3827 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
3828         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
3829 }
3830 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
3831         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
3832         CHECK(val->result_ok);
3833         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
3834         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3835         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3836         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3837         return res_ref;
3838 }
3839 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
3840         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
3841         CHECK(!val->result_ok);
3842         LDKDecodeError err_var = (*val->contents.err);
3843         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3844         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3845         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3846         return err_ref;
3847 }
3848 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
3849         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
3850         ret->datalen = *((uint32_t*)elems);
3851         if (ret->datalen == 0) {
3852                 ret->data = NULL;
3853         } else {
3854                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
3855                 int64_t *java_elems = (int64_t*)(elems + 4);
3856                 for (size_t i = 0; i < ret->datalen; i++) {
3857                         ret->data[i] = java_elems[i];
3858                 }
3859         }
3860         return (uint64_t)ret;
3861 }
3862 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3863         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3864         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3865         return ret;
3866 }
3867 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
3868         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
3869 }
3870 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
3871         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3872         CHECK(val->result_ok);
3873         LDKNodeInfo res_var = (*val->contents.result);
3874         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3875         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3876         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3877         return res_ref;
3878 }
3879 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
3880         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3881         CHECK(!val->result_ok);
3882         LDKDecodeError err_var = (*val->contents.err);
3883         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3884         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3885         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3886         return err_ref;
3887 }
3888 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
3889         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
3890 }
3891 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
3892         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3893         CHECK(val->result_ok);
3894         LDKNetworkGraph res_var = (*val->contents.result);
3895         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3896         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3897         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3898         return res_ref;
3899 }
3900 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
3901         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3902         CHECK(!val->result_ok);
3903         LDKDecodeError err_var = (*val->contents.err);
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         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3907         return err_ref;
3908 }
3909 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
3910         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3911 }
3912 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
3913         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3914         CHECK(val->result_ok);
3915         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3916         return res_ref;
3917 }
3918 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
3919         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3920         CHECK(!val->result_ok);
3921         return *val->contents.err;
3922 }
3923 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
3924         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3925 }
3926 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
3927         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3928         CHECK(val->result_ok);
3929         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3930         *res_conv = (*val->contents.result);
3931         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3932         return (uint64_t)res_conv;
3933 }
3934 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
3935         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3936         CHECK(!val->result_ok);
3937         LDKDecodeError err_var = (*val->contents.err);
3938         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3939         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3940         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3941         return err_ref;
3942 }
3943 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_result_ok(uint32_t arg) {
3944         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
3945 }
3946 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_ok(uint32_t arg) {
3947         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
3948         CHECK(val->result_ok);
3949         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3950         return res_ref;
3951 }
3952 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_err(uint32_t arg) {
3953         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
3954         CHECK(!val->result_ok);
3955         LDKDecodeError err_var = (*val->contents.err);
3956         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3957         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3958         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3959         return err_ref;
3960 }
3961 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
3962         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3963         ret->datalen = *((uint32_t*)elems);
3964         if (ret->datalen == 0) {
3965                 ret->data = NULL;
3966         } else {
3967                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3968                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3969                 for (size_t i = 0; i < ret->datalen; i++) {
3970                         uint32_t arr_elem = java_elems[i];
3971                         LDKUpdateAddHTLC arr_elem_conv;
3972                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3973                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3974                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3975                         ret->data[i] = arr_elem_conv;
3976                 }
3977         }
3978         return (uint64_t)ret;
3979 }
3980 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3981         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3982         for (size_t i = 0; i < ret.datalen; i++) {
3983                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3984         }
3985         return ret;
3986 }
3987 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
3988         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3989         ret->datalen = *((uint32_t*)elems);
3990         if (ret->datalen == 0) {
3991                 ret->data = NULL;
3992         } else {
3993                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3994                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3995                 for (size_t i = 0; i < ret->datalen; i++) {
3996                         uint32_t arr_elem = java_elems[i];
3997                         LDKUpdateFulfillHTLC arr_elem_conv;
3998                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3999                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4000                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
4001                         ret->data[i] = arr_elem_conv;
4002                 }
4003         }
4004         return (uint64_t)ret;
4005 }
4006 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
4007         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
4008         for (size_t i = 0; i < ret.datalen; i++) {
4009                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
4010         }
4011         return ret;
4012 }
4013 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
4014         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
4015         ret->datalen = *((uint32_t*)elems);
4016         if (ret->datalen == 0) {
4017                 ret->data = NULL;
4018         } else {
4019                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
4020                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4021                 for (size_t i = 0; i < ret->datalen; i++) {
4022                         uint32_t arr_elem = java_elems[i];
4023                         LDKUpdateFailHTLC arr_elem_conv;
4024                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4025                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4026                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
4027                         ret->data[i] = arr_elem_conv;
4028                 }
4029         }
4030         return (uint64_t)ret;
4031 }
4032 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
4033         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
4034         for (size_t i = 0; i < ret.datalen; i++) {
4035                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
4036         }
4037         return ret;
4038 }
4039 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
4040         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
4041         ret->datalen = *((uint32_t*)elems);
4042         if (ret->datalen == 0) {
4043                 ret->data = NULL;
4044         } else {
4045                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
4046                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4047                 for (size_t i = 0; i < ret->datalen; i++) {
4048                         uint32_t arr_elem = java_elems[i];
4049                         LDKUpdateFailMalformedHTLC arr_elem_conv;
4050                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4051                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4052                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
4053                         ret->data[i] = arr_elem_conv;
4054                 }
4055         }
4056         return (uint64_t)ret;
4057 }
4058 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
4059         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
4060         for (size_t i = 0; i < ret.datalen; i++) {
4061                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
4062         }
4063         return ret;
4064 }
4065 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
4066         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
4067 }
4068 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
4069         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4070         CHECK(val->result_ok);
4071         LDKAcceptChannel res_var = (*val->contents.result);
4072         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4073         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4074         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4075         return res_ref;
4076 }
4077 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
4078         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4079         CHECK(!val->result_ok);
4080         LDKDecodeError err_var = (*val->contents.err);
4081         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4082         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4083         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4084         return err_ref;
4085 }
4086 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
4087         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
4088 }
4089 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
4090         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4091         CHECK(val->result_ok);
4092         LDKAnnouncementSignatures res_var = (*val->contents.result);
4093         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4094         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4095         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4096         return res_ref;
4097 }
4098 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
4099         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4100         CHECK(!val->result_ok);
4101         LDKDecodeError err_var = (*val->contents.err);
4102         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4103         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4104         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4105         return err_ref;
4106 }
4107 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
4108         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
4109 }
4110 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
4111         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4112         CHECK(val->result_ok);
4113         LDKChannelReestablish res_var = (*val->contents.result);
4114         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4115         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4116         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4117         return res_ref;
4118 }
4119 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
4120         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4121         CHECK(!val->result_ok);
4122         LDKDecodeError err_var = (*val->contents.err);
4123         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4124         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4125         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4126         return err_ref;
4127 }
4128 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4129         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
4130 }
4131 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4132         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4133         CHECK(val->result_ok);
4134         LDKClosingSigned res_var = (*val->contents.result);
4135         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4136         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4137         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4138         return res_ref;
4139 }
4140 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
4141         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4142         CHECK(!val->result_ok);
4143         LDKDecodeError err_var = (*val->contents.err);
4144         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4145         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4146         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4147         return err_ref;
4148 }
4149 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_result_ok(uint32_t arg) {
4150         return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok;
4151 }
4152 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t arg) {
4153         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
4154         CHECK(val->result_ok);
4155         LDKClosingSignedFeeRange res_var = (*val->contents.result);
4156         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4157         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4158         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4159         return res_ref;
4160 }
4161 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t arg) {
4162         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
4163         CHECK(!val->result_ok);
4164         LDKDecodeError err_var = (*val->contents.err);
4165         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4166         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4167         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4168         return err_ref;
4169 }
4170 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
4171         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
4172 }
4173 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
4174         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4175         CHECK(val->result_ok);
4176         LDKCommitmentSigned res_var = (*val->contents.result);
4177         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4178         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4179         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4180         return res_ref;
4181 }
4182 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
4183         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4184         CHECK(!val->result_ok);
4185         LDKDecodeError err_var = (*val->contents.err);
4186         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4187         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4188         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4189         return err_ref;
4190 }
4191 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
4192         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
4193 }
4194 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
4195         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4196         CHECK(val->result_ok);
4197         LDKFundingCreated res_var = (*val->contents.result);
4198         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4199         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4200         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4201         return res_ref;
4202 }
4203 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
4204         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4205         CHECK(!val->result_ok);
4206         LDKDecodeError err_var = (*val->contents.err);
4207         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4208         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4209         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4210         return err_ref;
4211 }
4212 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4213         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
4214 }
4215 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4216         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4217         CHECK(val->result_ok);
4218         LDKFundingSigned res_var = (*val->contents.result);
4219         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4220         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4221         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4222         return res_ref;
4223 }
4224 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
4225         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4226         CHECK(!val->result_ok);
4227         LDKDecodeError err_var = (*val->contents.err);
4228         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4229         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4230         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4231         return err_ref;
4232 }
4233 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
4234         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
4235 }
4236 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
4237         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4238         CHECK(val->result_ok);
4239         LDKFundingLocked res_var = (*val->contents.result);
4240         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4241         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4242         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4243         return res_ref;
4244 }
4245 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
4246         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4247         CHECK(!val->result_ok);
4248         LDKDecodeError err_var = (*val->contents.err);
4249         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4250         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4251         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4252         return err_ref;
4253 }
4254 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
4255         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
4256 }
4257 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
4258         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4259         CHECK(val->result_ok);
4260         LDKInit res_var = (*val->contents.result);
4261         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4262         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4263         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4264         return res_ref;
4265 }
4266 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
4267         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4268         CHECK(!val->result_ok);
4269         LDKDecodeError err_var = (*val->contents.err);
4270         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4271         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4272         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4273         return err_ref;
4274 }
4275 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
4276         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
4277 }
4278 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
4279         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4280         CHECK(val->result_ok);
4281         LDKOpenChannel res_var = (*val->contents.result);
4282         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4283         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4284         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4285         return res_ref;
4286 }
4287 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
4288         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4289         CHECK(!val->result_ok);
4290         LDKDecodeError err_var = (*val->contents.err);
4291         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4292         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4293         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4294         return err_ref;
4295 }
4296 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
4297         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
4298 }
4299 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
4300         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4301         CHECK(val->result_ok);
4302         LDKRevokeAndACK res_var = (*val->contents.result);
4303         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4304         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4305         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4306         return res_ref;
4307 }
4308 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
4309         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4310         CHECK(!val->result_ok);
4311         LDKDecodeError err_var = (*val->contents.err);
4312         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4313         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4314         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4315         return err_ref;
4316 }
4317 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
4318         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
4319 }
4320 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
4321         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4322         CHECK(val->result_ok);
4323         LDKShutdown res_var = (*val->contents.result);
4324         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4325         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4326         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4327         return res_ref;
4328 }
4329 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
4330         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4331         CHECK(!val->result_ok);
4332         LDKDecodeError err_var = (*val->contents.err);
4333         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4334         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4335         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4336         return err_ref;
4337 }
4338 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4339         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
4340 }
4341 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4342         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4343         CHECK(val->result_ok);
4344         LDKUpdateFailHTLC res_var = (*val->contents.result);
4345         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4346         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4347         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4348         return res_ref;
4349 }
4350 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
4351         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4352         CHECK(!val->result_ok);
4353         LDKDecodeError err_var = (*val->contents.err);
4354         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4355         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4356         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4357         return err_ref;
4358 }
4359 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4360         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
4361 }
4362 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4363         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4364         CHECK(val->result_ok);
4365         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
4366         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4367         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4368         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4369         return res_ref;
4370 }
4371 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
4372         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4373         CHECK(!val->result_ok);
4374         LDKDecodeError err_var = (*val->contents.err);
4375         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4376         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4377         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4378         return err_ref;
4379 }
4380 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
4381         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
4382 }
4383 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
4384         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4385         CHECK(val->result_ok);
4386         LDKUpdateFee res_var = (*val->contents.result);
4387         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4388         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4389         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4390         return res_ref;
4391 }
4392 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
4393         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4394         CHECK(!val->result_ok);
4395         LDKDecodeError err_var = (*val->contents.err);
4396         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4397         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4398         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4399         return err_ref;
4400 }
4401 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4402         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
4403 }
4404 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4405         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4406         CHECK(val->result_ok);
4407         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
4408         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4409         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4410         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4411         return res_ref;
4412 }
4413 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
4414         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4415         CHECK(!val->result_ok);
4416         LDKDecodeError err_var = (*val->contents.err);
4417         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4418         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4419         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4420         return err_ref;
4421 }
4422 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4423         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
4424 }
4425 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4426         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4427         CHECK(val->result_ok);
4428         LDKUpdateAddHTLC res_var = (*val->contents.result);
4429         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4430         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4431         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4432         return res_ref;
4433 }
4434 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
4435         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4436         CHECK(!val->result_ok);
4437         LDKDecodeError err_var = (*val->contents.err);
4438         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4439         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4440         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4441         return err_ref;
4442 }
4443 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
4444         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
4445 }
4446 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
4447         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4448         CHECK(val->result_ok);
4449         LDKPing res_var = (*val->contents.result);
4450         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4451         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4452         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4453         return res_ref;
4454 }
4455 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
4456         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4457         CHECK(!val->result_ok);
4458         LDKDecodeError err_var = (*val->contents.err);
4459         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4460         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4461         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4462         return err_ref;
4463 }
4464 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
4465         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
4466 }
4467 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
4468         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4469         CHECK(val->result_ok);
4470         LDKPong res_var = (*val->contents.result);
4471         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4472         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4473         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4474         return res_ref;
4475 }
4476 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
4477         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4478         CHECK(!val->result_ok);
4479         LDKDecodeError err_var = (*val->contents.err);
4480         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4481         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4482         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4483         return err_ref;
4484 }
4485 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4486         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4487 }
4488 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4489         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4490         CHECK(val->result_ok);
4491         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
4492         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4493         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4494         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4495         return res_ref;
4496 }
4497 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4498         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4499         CHECK(!val->result_ok);
4500         LDKDecodeError err_var = (*val->contents.err);
4501         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4502         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4503         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4504         return err_ref;
4505 }
4506 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4507         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4508 }
4509 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4510         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4511         CHECK(val->result_ok);
4512         LDKChannelAnnouncement res_var = (*val->contents.result);
4513         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4514         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4515         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4516         return res_ref;
4517 }
4518 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4519         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4520         CHECK(!val->result_ok);
4521         LDKDecodeError err_var = (*val->contents.err);
4522         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4523         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4524         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4525         return err_ref;
4526 }
4527 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
4528         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
4529 }
4530 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
4531         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4532         CHECK(val->result_ok);
4533         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
4534         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4535         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4536         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4537         return res_ref;
4538 }
4539 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
4540         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4541         CHECK(!val->result_ok);
4542         LDKDecodeError err_var = (*val->contents.err);
4543         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4544         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4545         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4546         return err_ref;
4547 }
4548 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
4549         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
4550 }
4551 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
4552         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4553         CHECK(val->result_ok);
4554         LDKChannelUpdate res_var = (*val->contents.result);
4555         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4556         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4557         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4558         return res_ref;
4559 }
4560 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
4561         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4562         CHECK(!val->result_ok);
4563         LDKDecodeError err_var = (*val->contents.err);
4564         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4565         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4566         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4567         return err_ref;
4568 }
4569 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
4570         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
4571 }
4572 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
4573         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4574         CHECK(val->result_ok);
4575         LDKErrorMessage res_var = (*val->contents.result);
4576         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4577         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4578         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4579         return res_ref;
4580 }
4581 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
4582         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4583         CHECK(!val->result_ok);
4584         LDKDecodeError err_var = (*val->contents.err);
4585         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4586         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4587         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4588         return err_ref;
4589 }
4590 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4591         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4592 }
4593 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4594         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4595         CHECK(val->result_ok);
4596         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
4597         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4598         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4599         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4600         return res_ref;
4601 }
4602 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4603         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4604         CHECK(!val->result_ok);
4605         LDKDecodeError err_var = (*val->contents.err);
4606         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4607         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4608         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4609         return err_ref;
4610 }
4611 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4612         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4613 }
4614 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4615         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4616         CHECK(val->result_ok);
4617         LDKNodeAnnouncement res_var = (*val->contents.result);
4618         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4619         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4620         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4621         return res_ref;
4622 }
4623 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4624         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4625         CHECK(!val->result_ok);
4626         LDKDecodeError err_var = (*val->contents.err);
4627         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4628         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4629         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4630         return err_ref;
4631 }
4632 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
4633         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
4634 }
4635 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
4636         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4637         CHECK(val->result_ok);
4638         LDKQueryShortChannelIds res_var = (*val->contents.result);
4639         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4640         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4641         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4642         return res_ref;
4643 }
4644 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
4645         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4646         CHECK(!val->result_ok);
4647         LDKDecodeError err_var = (*val->contents.err);
4648         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4649         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4650         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4651         return err_ref;
4652 }
4653 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
4654         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
4655 }
4656 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
4657         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4658         CHECK(val->result_ok);
4659         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
4660         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4661         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4662         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4663         return res_ref;
4664 }
4665 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
4666         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4667         CHECK(!val->result_ok);
4668         LDKDecodeError err_var = (*val->contents.err);
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         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4672         return err_ref;
4673 }
4674 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
4675         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
4676 }
4677 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
4678         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4679         CHECK(val->result_ok);
4680         LDKQueryChannelRange res_var = (*val->contents.result);
4681         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4682         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4683         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4684         return res_ref;
4685 }
4686 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
4687         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4688         CHECK(!val->result_ok);
4689         LDKDecodeError err_var = (*val->contents.err);
4690         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4691         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4692         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4693         return err_ref;
4694 }
4695 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
4696         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
4697 }
4698 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
4699         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4700         CHECK(val->result_ok);
4701         LDKReplyChannelRange res_var = (*val->contents.result);
4702         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4703         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4704         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4705         return res_ref;
4706 }
4707 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
4708         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4709         CHECK(!val->result_ok);
4710         LDKDecodeError err_var = (*val->contents.err);
4711         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4712         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4713         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4714         return err_ref;
4715 }
4716 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
4717         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
4718 }
4719 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
4720         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4721         CHECK(val->result_ok);
4722         LDKGossipTimestampFilter res_var = (*val->contents.result);
4723         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4724         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4725         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4726         return res_ref;
4727 }
4728 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
4729         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4730         CHECK(!val->result_ok);
4731         LDKDecodeError err_var = (*val->contents.err);
4732         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4733         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4734         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4735         return err_ref;
4736 }
4737 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
4738         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
4739         switch(obj->tag) {
4740                 case LDKSignOrCreationError_SignError: {
4741                         return 0 /* LDKSignOrCreationError - SignError */;
4742                 }
4743                 case LDKSignOrCreationError_CreationError: {
4744                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
4745                         return 0 /* LDKSignOrCreationError - CreationError */; (void) creation_error_conv;
4746                 }
4747                 default: abort();
4748         }
4749 }
4750 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_result_ok(uint32_t arg) {
4751         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
4752 }
4753 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t arg) {
4754         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
4755         CHECK(val->result_ok);
4756         LDKInvoice res_var = (*val->contents.result);
4757         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4758         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4759         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4760         return res_ref;
4761 }
4762 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
4763         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
4764         CHECK(!val->result_ok);
4765         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4766         return err_ref;
4767 }
4768 typedef struct LDKMessageSendEventsProvider_JCalls {
4769         atomic_size_t refcnt;
4770         uint32_t get_and_clear_pending_msg_events_meth;
4771 } LDKMessageSendEventsProvider_JCalls;
4772 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
4773         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4774         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4775                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
4776                 FREE(j_calls);
4777         }
4778 }
4779 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
4780         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4781         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
4782         LDKCVec_MessageSendEventZ ret_constr;
4783         ret_constr.datalen = *((uint32_t*)ret);
4784         if (ret_constr.datalen > 0)
4785                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4786         else
4787                 ret_constr.data = NULL;
4788         uint32_t* ret_vals = (uint32_t*)(ret + 4);
4789         for (size_t s = 0; s < ret_constr.datalen; s++) {
4790                 uint32_t ret_conv_18 = ret_vals[s];
4791                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
4792                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
4793                 ret_constr.data[s] = ret_conv_18_conv;
4794         }
4795         return ret_constr;
4796 }
4797 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
4798         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
4799         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4800 }
4801 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
4802         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
4803         atomic_init(&calls->refcnt, 1);
4804         //TODO: Assign calls->o from o
4805
4806         LDKMessageSendEventsProvider ret = {
4807                 .this_arg = (void*) calls,
4808                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
4809                 .free = LDKMessageSendEventsProvider_JCalls_free,
4810         };
4811         return ret;
4812 }
4813 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4814         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
4815         *res_ptr = LDKMessageSendEventsProvider_init(o);
4816         return (long)res_ptr;
4817 }
4818 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
4819         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
4820         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
4821         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4822         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4823         for (size_t s = 0; s < ret_var.datalen; s++) {
4824                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
4825                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
4826                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
4827                 ret_arr_ptr[s] = ret_conv_18_ref;
4828         }
4829         FREE(ret_var.data);
4830         return ret_arr;
4831 }
4832
4833 typedef struct LDKEventHandler_JCalls {
4834         atomic_size_t refcnt;
4835         uint32_t handle_event_meth;
4836 } LDKEventHandler_JCalls;
4837 static void LDKEventHandler_JCalls_free(void* this_arg) {
4838         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4839         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4840                 js_free(j_calls->handle_event_meth);
4841                 FREE(j_calls);
4842         }
4843 }
4844 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
4845         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4846         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
4847         *event_copy = event;
4848         uint64_t event_ref = (uint64_t)event_copy;
4849         js_invoke_function_1(j_calls->handle_event_meth, event_ref);
4850 }
4851 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
4852         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
4853         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4854 }
4855 static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) {
4856         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
4857         atomic_init(&calls->refcnt, 1);
4858         //TODO: Assign calls->o from o
4859
4860         LDKEventHandler ret = {
4861                 .this_arg = (void*) calls,
4862                 .handle_event = handle_event_LDKEventHandler_jcall,
4863                 .free = LDKEventHandler_JCalls_free,
4864         };
4865         return ret;
4866 }
4867 long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS Object Reference */void* o) {
4868         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
4869         *res_ptr = LDKEventHandler_init(o);
4870         return (long)res_ptr;
4871 }
4872 void  __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
4873         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
4874         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
4875         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
4876 }
4877
4878 typedef struct LDKEventsProvider_JCalls {
4879         atomic_size_t refcnt;
4880         uint32_t process_pending_events_meth;
4881 } LDKEventsProvider_JCalls;
4882 static void LDKEventsProvider_JCalls_free(void* this_arg) {
4883         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4884         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4885                 js_free(j_calls->process_pending_events_meth);
4886                 FREE(j_calls);
4887         }
4888 }
4889 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
4890         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4891         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
4892         *ret = handler;
4893         js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)ret);
4894 }
4895 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
4896         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
4897         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4898 }
4899 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
4900         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
4901         atomic_init(&calls->refcnt, 1);
4902         //TODO: Assign calls->o from o
4903
4904         LDKEventsProvider ret = {
4905                 .this_arg = (void*) calls,
4906                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
4907                 .free = LDKEventsProvider_JCalls_free,
4908         };
4909         return ret;
4910 }
4911 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4912         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4913         *res_ptr = LDKEventsProvider_init(o);
4914         return (long)res_ptr;
4915 }
4916 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
4917         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
4918         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
4919         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
4920 }
4921
4922 typedef struct LDKAccess_JCalls {
4923         atomic_size_t refcnt;
4924         uint32_t get_utxo_meth;
4925 } LDKAccess_JCalls;
4926 static void LDKAccess_JCalls_free(void* this_arg) {
4927         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4928         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4929                 js_free(j_calls->get_utxo_meth);
4930                 FREE(j_calls);
4931         }
4932 }
4933 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4934         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4935         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4936         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4937         uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4938         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4939         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
4940         return ret_conv;
4941 }
4942 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
4943         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
4944         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4945 }
4946 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4947         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4948         atomic_init(&calls->refcnt, 1);
4949         //TODO: Assign calls->o from o
4950
4951         LDKAccess ret = {
4952                 .this_arg = (void*) calls,
4953                 .get_utxo = get_utxo_LDKAccess_jcall,
4954                 .free = LDKAccess_JCalls_free,
4955         };
4956         return ret;
4957 }
4958 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4959         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4960         *res_ptr = LDKAccess_init(o);
4961         return (long)res_ptr;
4962 }
4963 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4964         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
4965         unsigned char genesis_hash_arr[32];
4966         CHECK(*((uint32_t*)genesis_hash) == 32);
4967         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4968         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4969         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4970         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4971         return (uint64_t)ret_conv;
4972 }
4973
4974 typedef struct LDKListen_JCalls {
4975         atomic_size_t refcnt;
4976         uint32_t block_connected_meth;
4977         uint32_t block_disconnected_meth;
4978 } LDKListen_JCalls;
4979 static void LDKListen_JCalls_free(void* this_arg) {
4980         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4981         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4982                 js_free(j_calls->block_connected_meth);
4983                 js_free(j_calls->block_disconnected_meth);
4984                 FREE(j_calls);
4985         }
4986 }
4987 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
4988         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4989         LDKu8slice block_var = block;
4990         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4991         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
4992         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
4993 }
4994 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4995         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4996         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4997         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4998         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
4999 }
5000 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
5001         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
5002         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5003 }
5004 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
5005         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
5006         atomic_init(&calls->refcnt, 1);
5007         //TODO: Assign calls->o from o
5008
5009         LDKListen ret = {
5010                 .this_arg = (void*) calls,
5011                 .block_connected = block_connected_LDKListen_jcall,
5012                 .block_disconnected = block_disconnected_LDKListen_jcall,
5013                 .free = LDKListen_JCalls_free,
5014         };
5015         return ret;
5016 }
5017 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
5018         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
5019         *res_ptr = LDKListen_init(o);
5020         return (long)res_ptr;
5021 }
5022 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
5023         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5024         LDKu8slice block_ref;
5025         block_ref.datalen = *((uint32_t*)block);
5026         block_ref.data = (int8_t*)(block + 4);
5027         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
5028 }
5029
5030 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
5031         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5032         unsigned char header_arr[80];
5033         CHECK(*((uint32_t*)header) == 80);
5034         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5035         unsigned char (*header_ref)[80] = &header_arr;
5036         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
5037 }
5038
5039 typedef struct LDKConfirm_JCalls {
5040         atomic_size_t refcnt;
5041         uint32_t transactions_confirmed_meth;
5042         uint32_t transaction_unconfirmed_meth;
5043         uint32_t best_block_updated_meth;
5044         uint32_t get_relevant_txids_meth;
5045 } LDKConfirm_JCalls;
5046 static void LDKConfirm_JCalls_free(void* this_arg) {
5047         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5048         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5049                 js_free(j_calls->transactions_confirmed_meth);
5050                 js_free(j_calls->transaction_unconfirmed_meth);
5051                 js_free(j_calls->best_block_updated_meth);
5052                 js_free(j_calls->get_relevant_txids_meth);
5053                 FREE(j_calls);
5054         }
5055 }
5056 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
5057         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5058         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5059         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5060         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
5061         uint32_tArray txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5062         uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
5063         for (size_t e = 0; e < txdata_var.datalen; e++) {
5064                 LDKC2Tuple_usizeTransactionZ* txdata_conv_30_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
5065                 *txdata_conv_30_ref = txdata_var.data[e];
5066                 txdata_arr_ptr[e] = (uint64_t)txdata_conv_30_ref;
5067         }
5068         FREE(txdata_var.data);
5069         js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
5070 }
5071 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
5072         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5073         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5074         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5075         js_invoke_function_1(j_calls->transaction_unconfirmed_meth, txid_arr);
5076 }
5077 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5078         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5079         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5080         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5081         js_invoke_function_2(j_calls->best_block_updated_meth, header_arr, height);
5082 }
5083 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
5084         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5085         ptrArray ret = js_invoke_function_0(j_calls->get_relevant_txids_meth);
5086         LDKCVec_TxidZ ret_constr;
5087         ret_constr.datalen = *((uint32_t*)ret);
5088         if (ret_constr.datalen > 0)
5089                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
5090         else
5091                 ret_constr.data = NULL;
5092         int8_tArray* ret_vals = (int8_tArray*)(ret + 4);
5093         for (size_t m = 0; m < ret_constr.datalen; m++) {
5094                 int8_tArray ret_conv_12 = ret_vals[m];
5095                 LDKThirtyTwoBytes ret_conv_12_ref;
5096                 CHECK(*((uint32_t*)ret_conv_12) == 32);
5097                 memcpy(ret_conv_12_ref.data, (uint8_t*)(ret_conv_12 + 4), 32);
5098                 ret_constr.data[m] = ret_conv_12_ref;
5099         }
5100         return ret_constr;
5101 }
5102 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
5103         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
5104         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5105 }
5106 static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) {
5107         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
5108         atomic_init(&calls->refcnt, 1);
5109         //TODO: Assign calls->o from o
5110
5111         LDKConfirm ret = {
5112                 .this_arg = (void*) calls,
5113                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
5114                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
5115                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
5116                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
5117                 .free = LDKConfirm_JCalls_free,
5118         };
5119         return ret;
5120 }
5121 long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object Reference */void* o) {
5122         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
5123         *res_ptr = LDKConfirm_init(o);
5124         return (long)res_ptr;
5125 }
5126 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
5127         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5128         unsigned char header_arr[80];
5129         CHECK(*((uint32_t*)header) == 80);
5130         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5131         unsigned char (*header_ref)[80] = &header_arr;
5132         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5133         txdata_constr.datalen = *((uint32_t*)txdata);
5134         if (txdata_constr.datalen > 0)
5135                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5136         else
5137                 txdata_constr.data = NULL;
5138         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
5139         for (size_t e = 0; e < txdata_constr.datalen; e++) {
5140                 uint32_t txdata_conv_30 = txdata_vals[e];
5141                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
5142                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
5143                 txdata_constr.data[e] = txdata_conv_30_conv;
5144         }
5145         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
5146 }
5147
5148 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
5149         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5150         unsigned char txid_arr[32];
5151         CHECK(*((uint32_t*)txid) == 32);
5152         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5153         unsigned char (*txid_ref)[32] = &txid_arr;
5154         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
5155 }
5156
5157 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
5158         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5159         unsigned char header_arr[80];
5160         CHECK(*((uint32_t*)header) == 80);
5161         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5162         unsigned char (*header_ref)[80] = &header_arr;
5163         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
5164 }
5165
5166 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
5167         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5168         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
5169         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
5170         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
5171         for (size_t m = 0; m < ret_var.datalen; m++) {
5172                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5173                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
5174                 ret_arr_ptr[m] = ret_conv_12_arr;
5175         }
5176         FREE(ret_var.data);
5177         return ret_arr;
5178 }
5179
5180 typedef struct LDKFilter_JCalls {
5181         atomic_size_t refcnt;
5182         uint32_t register_tx_meth;
5183         uint32_t register_output_meth;
5184 } LDKFilter_JCalls;
5185 static void LDKFilter_JCalls_free(void* this_arg) {
5186         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5187         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5188                 js_free(j_calls->register_tx_meth);
5189                 js_free(j_calls->register_output_meth);
5190                 FREE(j_calls);
5191         }
5192 }
5193 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5194         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5195         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5196         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5197         LDKu8slice script_pubkey_var = script_pubkey;
5198         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5199         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
5200         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5201 }
5202 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5203         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5204         LDKWatchedOutput output_var = output;
5205         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5206         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5207         uint64_t output_ref = (uint64_t)output_var.inner;
5208         if (output_var.is_owned) {
5209                 output_ref |= 1;
5210         }
5211         uint32_t ret = js_invoke_function_1(j_calls->register_output_meth, output_ref);
5212         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
5213         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
5214         return ret_conv;
5215 }
5216 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
5217         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
5218         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5219 }
5220 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
5221         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5222         atomic_init(&calls->refcnt, 1);
5223         //TODO: Assign calls->o from o
5224
5225         LDKFilter ret = {
5226                 .this_arg = (void*) calls,
5227                 .register_tx = register_tx_LDKFilter_jcall,
5228                 .register_output = register_output_LDKFilter_jcall,
5229                 .free = LDKFilter_JCalls_free,
5230         };
5231         return ret;
5232 }
5233 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
5234         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5235         *res_ptr = LDKFilter_init(o);
5236         return (long)res_ptr;
5237 }
5238 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5239         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5240         unsigned char txid_arr[32];
5241         CHECK(*((uint32_t*)txid) == 32);
5242         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5243         unsigned char (*txid_ref)[32] = &txid_arr;
5244         LDKu8slice script_pubkey_ref;
5245         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
5246         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
5247         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5248 }
5249
5250 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5251         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5252         LDKWatchedOutput output_conv;
5253         output_conv.inner = (void*)(output & (~1));
5254         output_conv.is_owned = (output & 1) || (output == 0);
5255         output_conv = WatchedOutput_clone(&output_conv);
5256         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5257         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5258         uint64_t ret_ref = (uint64_t)ret_copy;
5259         return ret_ref;
5260 }
5261
5262 typedef struct LDKPersist_JCalls {
5263         atomic_size_t refcnt;
5264         uint32_t persist_new_channel_meth;
5265         uint32_t update_persisted_channel_meth;
5266 } LDKPersist_JCalls;
5267 static void LDKPersist_JCalls_free(void* this_arg) {
5268         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5269         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5270                 js_free(j_calls->persist_new_channel_meth);
5271                 js_free(j_calls->update_persisted_channel_meth);
5272                 FREE(j_calls);
5273         }
5274 }
5275 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
5276         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5277         LDKOutPoint id_var = id;
5278         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5279         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5280         uint64_t id_ref = (uint64_t)id_var.inner;
5281         if (id_var.is_owned) {
5282                 id_ref |= 1;
5283         }
5284         LDKChannelMonitor data_var = *data;
5285         data_var = ChannelMonitor_clone(data);
5286         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5287         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5288         uint64_t data_ref = (uint64_t)data_var.inner;
5289         if (data_var.is_owned) {
5290                 data_ref |= 1;
5291         }
5292         uint32_t ret = js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
5293         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5294         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5295         return ret_conv;
5296 }
5297 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
5298         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5299         LDKOutPoint id_var = id;
5300         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5301         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5302         uint64_t id_ref = (uint64_t)id_var.inner;
5303         if (id_var.is_owned) {
5304                 id_ref |= 1;
5305         }
5306         LDKChannelMonitorUpdate update_var = *update;
5307         update_var = ChannelMonitorUpdate_clone(update);
5308         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5309         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5310         uint64_t update_ref = (uint64_t)update_var.inner;
5311         if (update_var.is_owned) {
5312                 update_ref |= 1;
5313         }
5314         LDKChannelMonitor data_var = *data;
5315         data_var = ChannelMonitor_clone(data);
5316         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5317         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5318         uint64_t data_ref = (uint64_t)data_var.inner;
5319         if (data_var.is_owned) {
5320                 data_ref |= 1;
5321         }
5322         uint32_t ret = js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
5323         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5324         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5325         return ret_conv;
5326 }
5327 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
5328         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
5329         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5330 }
5331 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
5332         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5333         atomic_init(&calls->refcnt, 1);
5334         //TODO: Assign calls->o from o
5335
5336         LDKPersist ret = {
5337                 .this_arg = (void*) calls,
5338                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
5339                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
5340                 .free = LDKPersist_JCalls_free,
5341         };
5342         return ret;
5343 }
5344 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
5345         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5346         *res_ptr = LDKPersist_init(o);
5347         return (long)res_ptr;
5348 }
5349 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
5350         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5351         LDKOutPoint id_conv;
5352         id_conv.inner = (void*)(id & (~1));
5353         id_conv.is_owned = (id & 1) || (id == 0);
5354         id_conv = OutPoint_clone(&id_conv);
5355         LDKChannelMonitor data_conv;
5356         data_conv.inner = (void*)(data & (~1));
5357         data_conv.is_owned = false;
5358         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5359         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
5360         return (uint64_t)ret_conv;
5361 }
5362
5363 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
5364         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5365         LDKOutPoint id_conv;
5366         id_conv.inner = (void*)(id & (~1));
5367         id_conv.is_owned = (id & 1) || (id == 0);
5368         id_conv = OutPoint_clone(&id_conv);
5369         LDKChannelMonitorUpdate update_conv;
5370         update_conv.inner = (void*)(update & (~1));
5371         update_conv.is_owned = false;
5372         LDKChannelMonitor data_conv;
5373         data_conv.inner = (void*)(data & (~1));
5374         data_conv.is_owned = false;
5375         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5376         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
5377         return (uint64_t)ret_conv;
5378 }
5379
5380 typedef struct LDKChannelMessageHandler_JCalls {
5381         atomic_size_t refcnt;
5382         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5383         uint32_t handle_open_channel_meth;
5384         uint32_t handle_accept_channel_meth;
5385         uint32_t handle_funding_created_meth;
5386         uint32_t handle_funding_signed_meth;
5387         uint32_t handle_funding_locked_meth;
5388         uint32_t handle_shutdown_meth;
5389         uint32_t handle_closing_signed_meth;
5390         uint32_t handle_update_add_htlc_meth;
5391         uint32_t handle_update_fulfill_htlc_meth;
5392         uint32_t handle_update_fail_htlc_meth;
5393         uint32_t handle_update_fail_malformed_htlc_meth;
5394         uint32_t handle_commitment_signed_meth;
5395         uint32_t handle_revoke_and_ack_meth;
5396         uint32_t handle_update_fee_meth;
5397         uint32_t handle_announcement_signatures_meth;
5398         uint32_t peer_disconnected_meth;
5399         uint32_t peer_connected_meth;
5400         uint32_t handle_channel_reestablish_meth;
5401         uint32_t handle_channel_update_meth;
5402         uint32_t handle_error_meth;
5403 } LDKChannelMessageHandler_JCalls;
5404 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5405         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5406         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5407                 js_free(j_calls->handle_open_channel_meth);
5408                 js_free(j_calls->handle_accept_channel_meth);
5409                 js_free(j_calls->handle_funding_created_meth);
5410                 js_free(j_calls->handle_funding_signed_meth);
5411                 js_free(j_calls->handle_funding_locked_meth);
5412                 js_free(j_calls->handle_shutdown_meth);
5413                 js_free(j_calls->handle_closing_signed_meth);
5414                 js_free(j_calls->handle_update_add_htlc_meth);
5415                 js_free(j_calls->handle_update_fulfill_htlc_meth);
5416                 js_free(j_calls->handle_update_fail_htlc_meth);
5417                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
5418                 js_free(j_calls->handle_commitment_signed_meth);
5419                 js_free(j_calls->handle_revoke_and_ack_meth);
5420                 js_free(j_calls->handle_update_fee_meth);
5421                 js_free(j_calls->handle_announcement_signatures_meth);
5422                 js_free(j_calls->peer_disconnected_meth);
5423                 js_free(j_calls->peer_connected_meth);
5424                 js_free(j_calls->handle_channel_reestablish_meth);
5425                 js_free(j_calls->handle_channel_update_meth);
5426                 js_free(j_calls->handle_error_meth);
5427                 FREE(j_calls);
5428         }
5429 }
5430 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5431         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5432         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5433         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5434         LDKInitFeatures their_features_var = their_features;
5435         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5436         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5437         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5438         if (their_features_var.is_owned) {
5439                 their_features_ref |= 1;
5440         }
5441         LDKOpenChannel msg_var = *msg;
5442         msg_var = OpenChannel_clone(msg);
5443         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5444         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5445         uint64_t msg_ref = (uint64_t)msg_var.inner;
5446         if (msg_var.is_owned) {
5447                 msg_ref |= 1;
5448         }
5449         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5450 }
5451 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
5452         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5453         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5454         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5455         LDKInitFeatures their_features_var = their_features;
5456         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5457         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5458         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5459         if (their_features_var.is_owned) {
5460                 their_features_ref |= 1;
5461         }
5462         LDKAcceptChannel msg_var = *msg;
5463         msg_var = AcceptChannel_clone(msg);
5464         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5465         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5466         uint64_t msg_ref = (uint64_t)msg_var.inner;
5467         if (msg_var.is_owned) {
5468                 msg_ref |= 1;
5469         }
5470         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5471 }
5472 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
5473         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5474         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5475         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5476         LDKFundingCreated msg_var = *msg;
5477         msg_var = FundingCreated_clone(msg);
5478         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5479         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5480         uint64_t msg_ref = (uint64_t)msg_var.inner;
5481         if (msg_var.is_owned) {
5482                 msg_ref |= 1;
5483         }
5484         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
5485 }
5486 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
5487         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5488         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5489         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5490         LDKFundingSigned msg_var = *msg;
5491         msg_var = FundingSigned_clone(msg);
5492         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5493         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5494         uint64_t msg_ref = (uint64_t)msg_var.inner;
5495         if (msg_var.is_owned) {
5496                 msg_ref |= 1;
5497         }
5498         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
5499 }
5500 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
5501         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5502         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5503         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5504         LDKFundingLocked msg_var = *msg;
5505         msg_var = FundingLocked_clone(msg);
5506         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5507         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5508         uint64_t msg_ref = (uint64_t)msg_var.inner;
5509         if (msg_var.is_owned) {
5510                 msg_ref |= 1;
5511         }
5512         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
5513 }
5514 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
5515         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5516         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5517         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5518         LDKInitFeatures their_features_var = *their_features;
5519         their_features_var = InitFeatures_clone(their_features);
5520         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5521         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5522         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5523         if (their_features_var.is_owned) {
5524                 their_features_ref |= 1;
5525         }
5526         LDKShutdown msg_var = *msg;
5527         msg_var = Shutdown_clone(msg);
5528         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5529         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5530         uint64_t msg_ref = (uint64_t)msg_var.inner;
5531         if (msg_var.is_owned) {
5532                 msg_ref |= 1;
5533         }
5534         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
5535 }
5536 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
5537         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5538         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5539         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5540         LDKClosingSigned msg_var = *msg;
5541         msg_var = ClosingSigned_clone(msg);
5542         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5543         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5544         uint64_t msg_ref = (uint64_t)msg_var.inner;
5545         if (msg_var.is_owned) {
5546                 msg_ref |= 1;
5547         }
5548         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
5549 }
5550 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
5551         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5552         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5553         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5554         LDKUpdateAddHTLC msg_var = *msg;
5555         msg_var = UpdateAddHTLC_clone(msg);
5556         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5557         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5558         uint64_t msg_ref = (uint64_t)msg_var.inner;
5559         if (msg_var.is_owned) {
5560                 msg_ref |= 1;
5561         }
5562         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
5563 }
5564 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
5565         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5566         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5567         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5568         LDKUpdateFulfillHTLC msg_var = *msg;
5569         msg_var = UpdateFulfillHTLC_clone(msg);
5570         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5571         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5572         uint64_t msg_ref = (uint64_t)msg_var.inner;
5573         if (msg_var.is_owned) {
5574                 msg_ref |= 1;
5575         }
5576         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
5577 }
5578 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
5579         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5580         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5581         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5582         LDKUpdateFailHTLC msg_var = *msg;
5583         msg_var = UpdateFailHTLC_clone(msg);
5584         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5585         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5586         uint64_t msg_ref = (uint64_t)msg_var.inner;
5587         if (msg_var.is_owned) {
5588                 msg_ref |= 1;
5589         }
5590         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
5591 }
5592 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
5593         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5594         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5595         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5596         LDKUpdateFailMalformedHTLC msg_var = *msg;
5597         msg_var = UpdateFailMalformedHTLC_clone(msg);
5598         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5599         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5600         uint64_t msg_ref = (uint64_t)msg_var.inner;
5601         if (msg_var.is_owned) {
5602                 msg_ref |= 1;
5603         }
5604         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
5605 }
5606 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
5607         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5608         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5609         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5610         LDKCommitmentSigned msg_var = *msg;
5611         msg_var = CommitmentSigned_clone(msg);
5612         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5613         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5614         uint64_t msg_ref = (uint64_t)msg_var.inner;
5615         if (msg_var.is_owned) {
5616                 msg_ref |= 1;
5617         }
5618         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
5619 }
5620 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
5621         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5622         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5623         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5624         LDKRevokeAndACK msg_var = *msg;
5625         msg_var = RevokeAndACK_clone(msg);
5626         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5627         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5628         uint64_t msg_ref = (uint64_t)msg_var.inner;
5629         if (msg_var.is_owned) {
5630                 msg_ref |= 1;
5631         }
5632         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
5633 }
5634 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
5635         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5636         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5637         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5638         LDKUpdateFee msg_var = *msg;
5639         msg_var = UpdateFee_clone(msg);
5640         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5641         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5642         uint64_t msg_ref = (uint64_t)msg_var.inner;
5643         if (msg_var.is_owned) {
5644                 msg_ref |= 1;
5645         }
5646         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
5647 }
5648 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
5649         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5650         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5651         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5652         LDKAnnouncementSignatures msg_var = *msg;
5653         msg_var = AnnouncementSignatures_clone(msg);
5654         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5655         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5656         uint64_t msg_ref = (uint64_t)msg_var.inner;
5657         if (msg_var.is_owned) {
5658                 msg_ref |= 1;
5659         }
5660         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
5661 }
5662 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
5663         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5664         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5665         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5666         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
5667 }
5668 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
5669         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5670         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5671         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5672         LDKInit msg_var = *msg;
5673         msg_var = Init_clone(msg);
5674         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5675         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5676         uint64_t msg_ref = (uint64_t)msg_var.inner;
5677         if (msg_var.is_owned) {
5678                 msg_ref |= 1;
5679         }
5680         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
5681 }
5682 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
5683         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5684         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5685         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5686         LDKChannelReestablish msg_var = *msg;
5687         msg_var = ChannelReestablish_clone(msg);
5688         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5689         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5690         uint64_t msg_ref = (uint64_t)msg_var.inner;
5691         if (msg_var.is_owned) {
5692                 msg_ref |= 1;
5693         }
5694         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
5695 }
5696 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
5697         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5698         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5699         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5700         LDKChannelUpdate msg_var = *msg;
5701         msg_var = ChannelUpdate_clone(msg);
5702         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5703         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5704         uint64_t msg_ref = (uint64_t)msg_var.inner;
5705         if (msg_var.is_owned) {
5706                 msg_ref |= 1;
5707         }
5708         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
5709 }
5710 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
5711         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5712         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5713         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5714         LDKErrorMessage msg_var = *msg;
5715         msg_var = ErrorMessage_clone(msg);
5716         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5717         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5718         uint64_t msg_ref = (uint64_t)msg_var.inner;
5719         if (msg_var.is_owned) {
5720                 msg_ref |= 1;
5721         }
5722         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
5723 }
5724 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
5725         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
5726         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5727         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5728 }
5729 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
5730         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
5731         atomic_init(&calls->refcnt, 1);
5732         //TODO: Assign calls->o from o
5733
5734         LDKChannelMessageHandler ret = {
5735                 .this_arg = (void*) calls,
5736                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
5737                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
5738                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
5739                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
5740                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
5741                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
5742                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
5743                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
5744                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
5745                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
5746                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
5747                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
5748                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
5749                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
5750                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
5751                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
5752                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
5753                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
5754                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
5755                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
5756                 .free = LDKChannelMessageHandler_JCalls_free,
5757                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
5758         };
5759         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5760         return ret;
5761 }
5762 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
5763         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5764         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
5765         return (long)res_ptr;
5766 }
5767 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) {
5768         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5769         LDKPublicKey their_node_id_ref;
5770         CHECK(*((uint32_t*)their_node_id) == 33);
5771         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5772         LDKInitFeatures their_features_conv;
5773         their_features_conv.inner = (void*)(their_features & (~1));
5774         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5775         their_features_conv = InitFeatures_clone(&their_features_conv);
5776         LDKOpenChannel msg_conv;
5777         msg_conv.inner = (void*)(msg & (~1));
5778         msg_conv.is_owned = false;
5779         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5780 }
5781
5782 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) {
5783         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5784         LDKPublicKey their_node_id_ref;
5785         CHECK(*((uint32_t*)their_node_id) == 33);
5786         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5787         LDKInitFeatures their_features_conv;
5788         their_features_conv.inner = (void*)(their_features & (~1));
5789         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5790         their_features_conv = InitFeatures_clone(&their_features_conv);
5791         LDKAcceptChannel msg_conv;
5792         msg_conv.inner = (void*)(msg & (~1));
5793         msg_conv.is_owned = false;
5794         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5795 }
5796
5797 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5798         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5799         LDKPublicKey their_node_id_ref;
5800         CHECK(*((uint32_t*)their_node_id) == 33);
5801         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5802         LDKFundingCreated msg_conv;
5803         msg_conv.inner = (void*)(msg & (~1));
5804         msg_conv.is_owned = false;
5805         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5806 }
5807
5808 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5809         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5810         LDKPublicKey their_node_id_ref;
5811         CHECK(*((uint32_t*)their_node_id) == 33);
5812         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5813         LDKFundingSigned msg_conv;
5814         msg_conv.inner = (void*)(msg & (~1));
5815         msg_conv.is_owned = false;
5816         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5817 }
5818
5819 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5820         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5821         LDKPublicKey their_node_id_ref;
5822         CHECK(*((uint32_t*)their_node_id) == 33);
5823         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5824         LDKFundingLocked msg_conv;
5825         msg_conv.inner = (void*)(msg & (~1));
5826         msg_conv.is_owned = false;
5827         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5828 }
5829
5830 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
5831         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5832         LDKPublicKey their_node_id_ref;
5833         CHECK(*((uint32_t*)their_node_id) == 33);
5834         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5835         LDKInitFeatures their_features_conv;
5836         their_features_conv.inner = (void*)(their_features & (~1));
5837         their_features_conv.is_owned = false;
5838         LDKShutdown msg_conv;
5839         msg_conv.inner = (void*)(msg & (~1));
5840         msg_conv.is_owned = false;
5841         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
5842 }
5843
5844 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5845         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5846         LDKPublicKey their_node_id_ref;
5847         CHECK(*((uint32_t*)their_node_id) == 33);
5848         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5849         LDKClosingSigned msg_conv;
5850         msg_conv.inner = (void*)(msg & (~1));
5851         msg_conv.is_owned = false;
5852         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5853 }
5854
5855 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5856         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5857         LDKPublicKey their_node_id_ref;
5858         CHECK(*((uint32_t*)their_node_id) == 33);
5859         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5860         LDKUpdateAddHTLC msg_conv;
5861         msg_conv.inner = (void*)(msg & (~1));
5862         msg_conv.is_owned = false;
5863         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5864 }
5865
5866 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5867         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5868         LDKPublicKey their_node_id_ref;
5869         CHECK(*((uint32_t*)their_node_id) == 33);
5870         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5871         LDKUpdateFulfillHTLC msg_conv;
5872         msg_conv.inner = (void*)(msg & (~1));
5873         msg_conv.is_owned = false;
5874         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5875 }
5876
5877 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5878         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5879         LDKPublicKey their_node_id_ref;
5880         CHECK(*((uint32_t*)their_node_id) == 33);
5881         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5882         LDKUpdateFailHTLC msg_conv;
5883         msg_conv.inner = (void*)(msg & (~1));
5884         msg_conv.is_owned = false;
5885         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5886 }
5887
5888 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5889         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5890         LDKPublicKey their_node_id_ref;
5891         CHECK(*((uint32_t*)their_node_id) == 33);
5892         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5893         LDKUpdateFailMalformedHTLC msg_conv;
5894         msg_conv.inner = (void*)(msg & (~1));
5895         msg_conv.is_owned = false;
5896         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5897 }
5898
5899 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5900         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5901         LDKPublicKey their_node_id_ref;
5902         CHECK(*((uint32_t*)their_node_id) == 33);
5903         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5904         LDKCommitmentSigned msg_conv;
5905         msg_conv.inner = (void*)(msg & (~1));
5906         msg_conv.is_owned = false;
5907         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5908 }
5909
5910 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5911         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5912         LDKPublicKey their_node_id_ref;
5913         CHECK(*((uint32_t*)their_node_id) == 33);
5914         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5915         LDKRevokeAndACK msg_conv;
5916         msg_conv.inner = (void*)(msg & (~1));
5917         msg_conv.is_owned = false;
5918         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5919 }
5920
5921 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5922         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5923         LDKPublicKey their_node_id_ref;
5924         CHECK(*((uint32_t*)their_node_id) == 33);
5925         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5926         LDKUpdateFee msg_conv;
5927         msg_conv.inner = (void*)(msg & (~1));
5928         msg_conv.is_owned = false;
5929         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5930 }
5931
5932 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5933         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5934         LDKPublicKey their_node_id_ref;
5935         CHECK(*((uint32_t*)their_node_id) == 33);
5936         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5937         LDKAnnouncementSignatures msg_conv;
5938         msg_conv.inner = (void*)(msg & (~1));
5939         msg_conv.is_owned = false;
5940         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5941 }
5942
5943 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
5944         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5945         LDKPublicKey their_node_id_ref;
5946         CHECK(*((uint32_t*)their_node_id) == 33);
5947         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5948         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
5949 }
5950
5951 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5952         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5953         LDKPublicKey their_node_id_ref;
5954         CHECK(*((uint32_t*)their_node_id) == 33);
5955         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5956         LDKInit msg_conv;
5957         msg_conv.inner = (void*)(msg & (~1));
5958         msg_conv.is_owned = false;
5959         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5960 }
5961
5962 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5963         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5964         LDKPublicKey their_node_id_ref;
5965         CHECK(*((uint32_t*)their_node_id) == 33);
5966         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5967         LDKChannelReestablish msg_conv;
5968         msg_conv.inner = (void*)(msg & (~1));
5969         msg_conv.is_owned = false;
5970         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5971 }
5972
5973 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5974         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5975         LDKPublicKey their_node_id_ref;
5976         CHECK(*((uint32_t*)their_node_id) == 33);
5977         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5978         LDKChannelUpdate msg_conv;
5979         msg_conv.inner = (void*)(msg & (~1));
5980         msg_conv.is_owned = false;
5981         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5982 }
5983
5984 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5985         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5986         LDKPublicKey their_node_id_ref;
5987         CHECK(*((uint32_t*)their_node_id) == 33);
5988         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5989         LDKErrorMessage msg_conv;
5990         msg_conv.inner = (void*)(msg & (~1));
5991         msg_conv.is_owned = false;
5992         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5993 }
5994
5995 typedef struct LDKRoutingMessageHandler_JCalls {
5996         atomic_size_t refcnt;
5997         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5998         uint32_t handle_node_announcement_meth;
5999         uint32_t handle_channel_announcement_meth;
6000         uint32_t handle_channel_update_meth;
6001         uint32_t handle_htlc_fail_channel_update_meth;
6002         uint32_t get_next_channel_announcements_meth;
6003         uint32_t get_next_node_announcements_meth;
6004         uint32_t sync_routing_table_meth;
6005         uint32_t handle_reply_channel_range_meth;
6006         uint32_t handle_reply_short_channel_ids_end_meth;
6007         uint32_t handle_query_channel_range_meth;
6008         uint32_t handle_query_short_channel_ids_meth;
6009 } LDKRoutingMessageHandler_JCalls;
6010 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
6011         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6012         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6013                 js_free(j_calls->handle_node_announcement_meth);
6014                 js_free(j_calls->handle_channel_announcement_meth);
6015                 js_free(j_calls->handle_channel_update_meth);
6016                 js_free(j_calls->handle_htlc_fail_channel_update_meth);
6017                 js_free(j_calls->get_next_channel_announcements_meth);
6018                 js_free(j_calls->get_next_node_announcements_meth);
6019                 js_free(j_calls->sync_routing_table_meth);
6020                 js_free(j_calls->handle_reply_channel_range_meth);
6021                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
6022                 js_free(j_calls->handle_query_channel_range_meth);
6023                 js_free(j_calls->handle_query_short_channel_ids_meth);
6024                 FREE(j_calls);
6025         }
6026 }
6027 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
6028         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6029         LDKNodeAnnouncement msg_var = *msg;
6030         msg_var = NodeAnnouncement_clone(msg);
6031         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6032         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6033         uint64_t msg_ref = (uint64_t)msg_var.inner;
6034         if (msg_var.is_owned) {
6035                 msg_ref |= 1;
6036         }
6037         uint32_t ret = js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
6038         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6039         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6040         return ret_conv;
6041 }
6042 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
6043         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6044         LDKChannelAnnouncement msg_var = *msg;
6045         msg_var = ChannelAnnouncement_clone(msg);
6046         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6047         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6048         uint64_t msg_ref = (uint64_t)msg_var.inner;
6049         if (msg_var.is_owned) {
6050                 msg_ref |= 1;
6051         }
6052         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
6053         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6054         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6055         return ret_conv;
6056 }
6057 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
6058         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6059         LDKChannelUpdate msg_var = *msg;
6060         msg_var = ChannelUpdate_clone(msg);
6061         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6062         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6063         uint64_t msg_ref = (uint64_t)msg_var.inner;
6064         if (msg_var.is_owned) {
6065                 msg_ref |= 1;
6066         }
6067         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
6068         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6069         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6070         return ret_conv;
6071 }
6072 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
6073         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6074         uint64_t ret_update = (uint64_t)update;
6075         js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
6076 }
6077 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
6078         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6079         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
6080         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
6081         ret_constr.datalen = *((uint32_t*)ret);
6082         if (ret_constr.datalen > 0)
6083                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
6084         else
6085                 ret_constr.data = NULL;
6086         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6087         for (size_t l = 0; l < ret_constr.datalen; l++) {
6088                 uint32_t ret_conv_63 = ret_vals[l];
6089                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
6090                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
6091                 ret_constr.data[l] = ret_conv_63_conv;
6092         }
6093         return ret_constr;
6094 }
6095 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
6096         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6097         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6098         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
6099         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
6100         LDKCVec_NodeAnnouncementZ ret_constr;
6101         ret_constr.datalen = *((uint32_t*)ret);
6102         if (ret_constr.datalen > 0)
6103                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6104         else
6105                 ret_constr.data = NULL;
6106         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6107         for (size_t s = 0; s < ret_constr.datalen; s++) {
6108                 uint32_t ret_conv_18 = ret_vals[s];
6109                 LDKNodeAnnouncement ret_conv_18_conv;
6110                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
6111                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
6112                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
6113                 ret_constr.data[s] = ret_conv_18_conv;
6114         }
6115         return ret_constr;
6116 }
6117 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
6118         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6119         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6120         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6121         LDKInit init_var = *init;
6122         init_var = Init_clone(init);
6123         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6124         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6125         uint64_t init_ref = (uint64_t)init_var.inner;
6126         if (init_var.is_owned) {
6127                 init_ref |= 1;
6128         }
6129         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
6130 }
6131 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
6132         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6133         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6134         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6135         LDKReplyChannelRange msg_var = msg;
6136         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6137         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6138         uint64_t msg_ref = (uint64_t)msg_var.inner;
6139         if (msg_var.is_owned) {
6140                 msg_ref |= 1;
6141         }
6142         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6143         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6144         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6145         return ret_conv;
6146 }
6147 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6148         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6149         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6150         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6151         LDKReplyShortChannelIdsEnd msg_var = msg;
6152         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6153         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6154         uint64_t msg_ref = (uint64_t)msg_var.inner;
6155         if (msg_var.is_owned) {
6156                 msg_ref |= 1;
6157         }
6158         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6159         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6160         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6161         return ret_conv;
6162 }
6163 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6164         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6165         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6166         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6167         LDKQueryChannelRange msg_var = msg;
6168         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6169         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6170         uint64_t msg_ref = (uint64_t)msg_var.inner;
6171         if (msg_var.is_owned) {
6172                 msg_ref |= 1;
6173         }
6174         uint32_t ret = js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6175         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6176         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6177         return ret_conv;
6178 }
6179 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6180         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6181         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6182         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6183         LDKQueryShortChannelIds msg_var = msg;
6184         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6185         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6186         uint64_t msg_ref = (uint64_t)msg_var.inner;
6187         if (msg_var.is_owned) {
6188                 msg_ref |= 1;
6189         }
6190         uint32_t ret = js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6191         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6192         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6193         return ret_conv;
6194 }
6195 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
6196         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
6197         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6198         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6199 }
6200 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6201         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6202         atomic_init(&calls->refcnt, 1);
6203         //TODO: Assign calls->o from o
6204
6205         LDKRoutingMessageHandler ret = {
6206                 .this_arg = (void*) calls,
6207                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
6208                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
6209                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
6210                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
6211                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
6212                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
6213                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
6214                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
6215                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
6216                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
6217                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
6218                 .free = LDKRoutingMessageHandler_JCalls_free,
6219                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6220         };
6221         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6222         return ret;
6223 }
6224 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6225         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6226         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
6227         return (long)res_ptr;
6228 }
6229 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
6230         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6231         LDKNodeAnnouncement msg_conv;
6232         msg_conv.inner = (void*)(msg & (~1));
6233         msg_conv.is_owned = false;
6234         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6235         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6236         return (uint64_t)ret_conv;
6237 }
6238
6239 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
6240         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6241         LDKChannelAnnouncement msg_conv;
6242         msg_conv.inner = (void*)(msg & (~1));
6243         msg_conv.is_owned = false;
6244         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6245         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6246         return (uint64_t)ret_conv;
6247 }
6248
6249 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
6250         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6251         LDKChannelUpdate msg_conv;
6252         msg_conv.inner = (void*)(msg & (~1));
6253         msg_conv.is_owned = false;
6254         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6255         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6256         return (uint64_t)ret_conv;
6257 }
6258
6259 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
6260         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6261         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
6262         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
6263 }
6264
6265 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
6266         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6267         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6268         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6269         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6270         for (size_t l = 0; l < ret_var.datalen; l++) {
6271                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6272                 *ret_conv_63_ref = ret_var.data[l];
6273                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
6274         }
6275         FREE(ret_var.data);
6276         return ret_arr;
6277 }
6278
6279 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
6280         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6281         LDKPublicKey starting_point_ref;
6282         CHECK(*((uint32_t*)starting_point) == 33);
6283         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
6284         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6285         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6286         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6287         for (size_t s = 0; s < ret_var.datalen; s++) {
6288                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6289                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6290                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6291                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
6292                 if (ret_conv_18_var.is_owned) {
6293                         ret_conv_18_ref |= 1;
6294                 }
6295                 ret_arr_ptr[s] = ret_conv_18_ref;
6296         }
6297         FREE(ret_var.data);
6298         return ret_arr;
6299 }
6300
6301 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
6302         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6303         LDKPublicKey their_node_id_ref;
6304         CHECK(*((uint32_t*)their_node_id) == 33);
6305         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6306         LDKInit init_conv;
6307         init_conv.inner = (void*)(init & (~1));
6308         init_conv.is_owned = false;
6309         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
6310 }
6311
6312 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6313         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6314         LDKPublicKey their_node_id_ref;
6315         CHECK(*((uint32_t*)their_node_id) == 33);
6316         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6317         LDKReplyChannelRange msg_conv;
6318         msg_conv.inner = (void*)(msg & (~1));
6319         msg_conv.is_owned = (msg & 1) || (msg == 0);
6320         msg_conv = ReplyChannelRange_clone(&msg_conv);
6321         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6322         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6323         return (uint64_t)ret_conv;
6324 }
6325
6326 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) {
6327         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6328         LDKPublicKey their_node_id_ref;
6329         CHECK(*((uint32_t*)their_node_id) == 33);
6330         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6331         LDKReplyShortChannelIdsEnd msg_conv;
6332         msg_conv.inner = (void*)(msg & (~1));
6333         msg_conv.is_owned = (msg & 1) || (msg == 0);
6334         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
6335         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6336         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6337         return (uint64_t)ret_conv;
6338 }
6339
6340 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6341         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6342         LDKPublicKey their_node_id_ref;
6343         CHECK(*((uint32_t*)their_node_id) == 33);
6344         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6345         LDKQueryChannelRange msg_conv;
6346         msg_conv.inner = (void*)(msg & (~1));
6347         msg_conv.is_owned = (msg & 1) || (msg == 0);
6348         msg_conv = QueryChannelRange_clone(&msg_conv);
6349         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6350         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6351         return (uint64_t)ret_conv;
6352 }
6353
6354 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6355         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6356         LDKPublicKey their_node_id_ref;
6357         CHECK(*((uint32_t*)their_node_id) == 33);
6358         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6359         LDKQueryShortChannelIds msg_conv;
6360         msg_conv.inner = (void*)(msg & (~1));
6361         msg_conv.is_owned = (msg & 1) || (msg == 0);
6362         msg_conv = QueryShortChannelIds_clone(&msg_conv);
6363         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6364         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6365         return (uint64_t)ret_conv;
6366 }
6367
6368 typedef struct LDKSocketDescriptor_JCalls {
6369         atomic_size_t refcnt;
6370         uint32_t send_data_meth;
6371         uint32_t disconnect_socket_meth;
6372         uint32_t eq_meth;
6373         uint32_t hash_meth;
6374 } LDKSocketDescriptor_JCalls;
6375 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
6376         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6377         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6378                 js_free(j_calls->send_data_meth);
6379                 js_free(j_calls->disconnect_socket_meth);
6380                 js_free(j_calls->eq_meth);
6381                 js_free(j_calls->hash_meth);
6382                 FREE(j_calls);
6383         }
6384 }
6385 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
6386         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6387         LDKu8slice data_var = data;
6388         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6389         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
6390         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
6391 }
6392 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
6393         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6394         js_invoke_function_0(j_calls->disconnect_socket_meth);
6395 }
6396 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
6397         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6398         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6399         *other_arg_clone = SocketDescriptor_clone(other_arg);
6400         return js_invoke_function_1(j_calls->eq_meth, (uint64_t)other_arg_clone);
6401 }
6402 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
6403         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6404         return js_invoke_function_0(j_calls->hash_meth);
6405 }
6406 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
6407         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
6408         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6409 }
6410 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
6411         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
6412         atomic_init(&calls->refcnt, 1);
6413         //TODO: Assign calls->o from o
6414
6415         LDKSocketDescriptor ret = {
6416                 .this_arg = (void*) calls,
6417                 .send_data = send_data_LDKSocketDescriptor_jcall,
6418                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
6419                 .eq = eq_LDKSocketDescriptor_jcall,
6420                 .hash = hash_LDKSocketDescriptor_jcall,
6421                 .cloned = LDKSocketDescriptor_JCalls_cloned,
6422                 .free = LDKSocketDescriptor_JCalls_free,
6423         };
6424         return ret;
6425 }
6426 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
6427         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6428         *res_ptr = LDKSocketDescriptor_init(o);
6429         return (long)res_ptr;
6430 }
6431 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
6432         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6433         LDKu8slice data_ref;
6434         data_ref.datalen = *((uint32_t*)data);
6435         data_ref.data = (int8_t*)(data + 4);
6436         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
6437         return ret_val;
6438 }
6439
6440 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
6441         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6442         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
6443 }
6444
6445 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
6446         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6447         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
6448         return ret_val;
6449 }
6450
6451 typedef struct LDKChannelManagerPersister_JCalls {
6452         atomic_size_t refcnt;
6453         uint32_t persist_manager_meth;
6454 } LDKChannelManagerPersister_JCalls;
6455 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
6456         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6457         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6458                 js_free(j_calls->persist_manager_meth);
6459                 FREE(j_calls);
6460         }
6461 }
6462 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
6463         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6464         LDKChannelManager channel_manager_var = *channel_manager;
6465         // Warning: we may need a move here but no clone is available for LDKChannelManager
6466         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6467         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6468         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
6469         if (channel_manager_var.is_owned) {
6470                 channel_manager_ref |= 1;
6471         }
6472         uint32_t ret = js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
6473         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
6474         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
6475         return ret_conv;
6476 }
6477 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
6478         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
6479         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6480 }
6481 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (/*TODO: JS Object Reference */void* o) {
6482         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
6483         atomic_init(&calls->refcnt, 1);
6484         //TODO: Assign calls->o from o
6485
6486         LDKChannelManagerPersister ret = {
6487                 .this_arg = (void*) calls,
6488                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
6489                 .free = LDKChannelManagerPersister_JCalls_free,
6490         };
6491         return ret;
6492 }
6493 long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/*TODO: JS Object Reference */void* o) {
6494         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
6495         *res_ptr = LDKChannelManagerPersister_init(o);
6496         return (long)res_ptr;
6497 }
6498 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
6499         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
6500         LDKChannelManager channel_manager_conv;
6501         channel_manager_conv.inner = (void*)(channel_manager & (~1));
6502         channel_manager_conv.is_owned = false;
6503         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6504         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
6505         return (uint64_t)ret_conv;
6506 }
6507
6508 uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint32_t ptr) {
6509         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
6510         switch(obj->tag) {
6511                 case LDKFallback_SegWitProgram: {
6512                         uint8_t version_val = obj->seg_wit_program.version._0;
6513                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
6514                         int8_tArray program_arr = init_arr(program_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6515                         memcpy((uint8_t*)(program_arr + 4), program_var.data, program_var.datalen);
6516                         return 0 /* LDKFallback - SegWitProgram */; (void) version_val; (void) program_arr;
6517                 }
6518                 case LDKFallback_PubKeyHash: {
6519                         int8_tArray pub_key_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
6520                         memcpy((uint8_t*)(pub_key_hash_arr + 4), obj->pub_key_hash.data, 20);
6521                         return 0 /* LDKFallback - PubKeyHash */; (void) pub_key_hash_arr;
6522                 }
6523                 case LDKFallback_ScriptHash: {
6524                         int8_tArray script_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
6525                         memcpy((uint8_t*)(script_hash_arr + 4), obj->script_hash.data, 20);
6526                         return 0 /* LDKFallback - ScriptHash */; (void) script_hash_arr;
6527                 }
6528                 default: abort();
6529         }
6530 }
6531 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
6532         LDKStr ret_str = _ldk_get_compiled_version();
6533         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6534         Str_free(ret_str);
6535         return ret_conv;
6536 }
6537
6538 jstring  __attribute__((visibility("default"))) TS__ldk_c_bindings_get_compiled_version() {
6539         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
6540         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6541         Str_free(ret_str);
6542         return ret_conv;
6543 }
6544
6545 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
6546         LDKTransaction _res_ref;
6547         _res_ref.datalen = *((uint32_t*)_res);
6548         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
6549         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
6550         _res_ref.data_is_owned = true;
6551         Transaction_free(_res_ref);
6552 }
6553
6554 uint32_t  __attribute__((visibility("default"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
6555         LDKCVec_u8Z script_pubkey_ref;
6556         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
6557         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
6558         memcpy(script_pubkey_ref.data, (uint8_t*)(script_pubkey + 4), script_pubkey_ref.datalen);
6559         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6560         *ret_ref = TxOut_new(script_pubkey_ref, value);
6561         return (uint64_t)ret_ref;
6562 }
6563
6564 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
6565         if ((_res & 1) != 0) return;
6566         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
6567         FREE((void*)_res);
6568         TxOut_free(_res_conv);
6569 }
6570
6571 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
6572         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
6573         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6574         *ret_ref = TxOut_clone(orig_conv);
6575         return (uint64_t)ret_ref;
6576 }
6577
6578 void  __attribute__((visibility("default"))) TS_Str_free(jstring _res) {
6579         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
6580         Str_free(dummy);
6581 }
6582
6583 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
6584         LDKSecretKey o_ref;
6585         CHECK(*((uint32_t*)o) == 32);
6586         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
6587         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6588         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
6589         return (uint64_t)ret_conv;
6590 }
6591
6592 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
6593         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6594         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6595         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
6596         return (uint64_t)ret_conv;
6597 }
6598
6599 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
6600         if ((_res & 1) != 0) return;
6601         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
6602         FREE((void*)_res);
6603         CResult_SecretKeyErrorZ_free(_res_conv);
6604 }
6605
6606 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
6607         LDKPublicKey o_ref;
6608         CHECK(*((uint32_t*)o) == 33);
6609         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
6610         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6611         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
6612         return (uint64_t)ret_conv;
6613 }
6614
6615 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
6616         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6617         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6618         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
6619         return (uint64_t)ret_conv;
6620 }
6621
6622 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
6623         if ((_res & 1) != 0) return;
6624         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
6625         FREE((void*)_res);
6626         CResult_PublicKeyErrorZ_free(_res_conv);
6627 }
6628
6629 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
6630         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
6631         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6632         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
6633         return (uint64_t)ret_conv;
6634 }
6635
6636 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
6637         LDKTxCreationKeys o_conv;
6638         o_conv.inner = (void*)(o & (~1));
6639         o_conv.is_owned = (o & 1) || (o == 0);
6640         o_conv = TxCreationKeys_clone(&o_conv);
6641         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6642         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
6643         return (uint64_t)ret_conv;
6644 }
6645
6646 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
6647         LDKDecodeError e_conv;
6648         e_conv.inner = (void*)(e & (~1));
6649         e_conv.is_owned = (e & 1) || (e == 0);
6650         e_conv = DecodeError_clone(&e_conv);
6651         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6652         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
6653         return (uint64_t)ret_conv;
6654 }
6655
6656 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
6657         if ((_res & 1) != 0) return;
6658         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6659         FREE((void*)_res);
6660         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
6661 }
6662
6663 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
6664         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
6665         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6666         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
6667         return (uint64_t)ret_conv;
6668 }
6669
6670 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
6671         LDKChannelPublicKeys o_conv;
6672         o_conv.inner = (void*)(o & (~1));
6673         o_conv.is_owned = (o & 1) || (o == 0);
6674         o_conv = ChannelPublicKeys_clone(&o_conv);
6675         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6676         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
6677         return (uint64_t)ret_conv;
6678 }
6679
6680 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
6681         LDKDecodeError e_conv;
6682         e_conv.inner = (void*)(e & (~1));
6683         e_conv.is_owned = (e & 1) || (e == 0);
6684         e_conv = DecodeError_clone(&e_conv);
6685         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6686         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
6687         return (uint64_t)ret_conv;
6688 }
6689
6690 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
6691         if ((_res & 1) != 0) return;
6692         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6693         FREE((void*)_res);
6694         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
6695 }
6696
6697 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
6698         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
6699         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6700         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
6701         return (uint64_t)ret_conv;
6702 }
6703
6704 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
6705         LDKTxCreationKeys o_conv;
6706         o_conv.inner = (void*)(o & (~1));
6707         o_conv.is_owned = (o & 1) || (o == 0);
6708         o_conv = TxCreationKeys_clone(&o_conv);
6709         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6710         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
6711         return (uint64_t)ret_conv;
6712 }
6713
6714 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
6715         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6716         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6717         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
6718         return (uint64_t)ret_conv;
6719 }
6720
6721 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
6722         if ((_res & 1) != 0) return;
6723         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
6724         FREE((void*)_res);
6725         CResult_TxCreationKeysErrorZ_free(_res_conv);
6726 }
6727
6728 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
6729         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
6730         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6731         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
6732         return (uint64_t)ret_conv;
6733 }
6734
6735 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
6736         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6737         *ret_copy = COption_u32Z_some(o);
6738         uint64_t ret_ref = (uint64_t)ret_copy;
6739         return ret_ref;
6740 }
6741
6742 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
6743         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6744         *ret_copy = COption_u32Z_none();
6745         uint64_t ret_ref = (uint64_t)ret_copy;
6746         return ret_ref;
6747 }
6748
6749 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
6750         if ((_res & 1) != 0) return;
6751         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
6752         FREE((void*)_res);
6753         COption_u32Z_free(_res_conv);
6754 }
6755
6756 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
6757         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
6758         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6759         *ret_copy = COption_u32Z_clone(orig_conv);
6760         uint64_t ret_ref = (uint64_t)ret_copy;
6761         return ret_ref;
6762 }
6763
6764 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
6765         LDKHTLCOutputInCommitment o_conv;
6766         o_conv.inner = (void*)(o & (~1));
6767         o_conv.is_owned = (o & 1) || (o == 0);
6768         o_conv = HTLCOutputInCommitment_clone(&o_conv);
6769         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6770         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
6771         return (uint64_t)ret_conv;
6772 }
6773
6774 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
6775         LDKDecodeError e_conv;
6776         e_conv.inner = (void*)(e & (~1));
6777         e_conv.is_owned = (e & 1) || (e == 0);
6778         e_conv = DecodeError_clone(&e_conv);
6779         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6780         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
6781         return (uint64_t)ret_conv;
6782 }
6783
6784 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
6785         if ((_res & 1) != 0) return;
6786         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
6787         FREE((void*)_res);
6788         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
6789 }
6790
6791 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
6792         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
6793         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6794         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
6795         return (uint64_t)ret_conv;
6796 }
6797
6798 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
6799         LDKCounterpartyChannelTransactionParameters o_conv;
6800         o_conv.inner = (void*)(o & (~1));
6801         o_conv.is_owned = (o & 1) || (o == 0);
6802         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
6803         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6804         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6805         return (uint64_t)ret_conv;
6806 }
6807
6808 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
6809         LDKDecodeError e_conv;
6810         e_conv.inner = (void*)(e & (~1));
6811         e_conv.is_owned = (e & 1) || (e == 0);
6812         e_conv = DecodeError_clone(&e_conv);
6813         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6814         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
6815         return (uint64_t)ret_conv;
6816 }
6817
6818 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
6819         if ((_res & 1) != 0) return;
6820         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6821         FREE((void*)_res);
6822         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6823 }
6824
6825 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
6826         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6827         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6828         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6829         return (uint64_t)ret_conv;
6830 }
6831
6832 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
6833         LDKChannelTransactionParameters o_conv;
6834         o_conv.inner = (void*)(o & (~1));
6835         o_conv.is_owned = (o & 1) || (o == 0);
6836         o_conv = ChannelTransactionParameters_clone(&o_conv);
6837         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6838         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6839         return (uint64_t)ret_conv;
6840 }
6841
6842 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
6843         LDKDecodeError e_conv;
6844         e_conv.inner = (void*)(e & (~1));
6845         e_conv.is_owned = (e & 1) || (e == 0);
6846         e_conv = DecodeError_clone(&e_conv);
6847         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6848         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
6849         return (uint64_t)ret_conv;
6850 }
6851
6852 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
6853         if ((_res & 1) != 0) return;
6854         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6855         FREE((void*)_res);
6856         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6857 }
6858
6859 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
6860         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6861         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6862         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6863         return (uint64_t)ret_conv;
6864 }
6865
6866 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
6867         LDKCVec_SignatureZ _res_constr;
6868         _res_constr.datalen = *((uint32_t*)_res);
6869         if (_res_constr.datalen > 0)
6870                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6871         else
6872                 _res_constr.data = NULL;
6873         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
6874         for (size_t m = 0; m < _res_constr.datalen; m++) {
6875                 int8_tArray _res_conv_12 = _res_vals[m];
6876                 LDKSignature _res_conv_12_ref;
6877                 CHECK(*((uint32_t*)_res_conv_12) == 64);
6878                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
6879                 _res_constr.data[m] = _res_conv_12_ref;
6880         }
6881         CVec_SignatureZ_free(_res_constr);
6882 }
6883
6884 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6885         LDKHolderCommitmentTransaction o_conv;
6886         o_conv.inner = (void*)(o & (~1));
6887         o_conv.is_owned = (o & 1) || (o == 0);
6888         o_conv = HolderCommitmentTransaction_clone(&o_conv);
6889         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6890         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
6891         return (uint64_t)ret_conv;
6892 }
6893
6894 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6895         LDKDecodeError e_conv;
6896         e_conv.inner = (void*)(e & (~1));
6897         e_conv.is_owned = (e & 1) || (e == 0);
6898         e_conv = DecodeError_clone(&e_conv);
6899         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6900         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
6901         return (uint64_t)ret_conv;
6902 }
6903
6904 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6905         if ((_res & 1) != 0) return;
6906         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6907         FREE((void*)_res);
6908         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
6909 }
6910
6911 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6912         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6913         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6914         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6915         return (uint64_t)ret_conv;
6916 }
6917
6918 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6919         LDKBuiltCommitmentTransaction o_conv;
6920         o_conv.inner = (void*)(o & (~1));
6921         o_conv.is_owned = (o & 1) || (o == 0);
6922         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
6923         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6924         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
6925         return (uint64_t)ret_conv;
6926 }
6927
6928 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6929         LDKDecodeError e_conv;
6930         e_conv.inner = (void*)(e & (~1));
6931         e_conv.is_owned = (e & 1) || (e == 0);
6932         e_conv = DecodeError_clone(&e_conv);
6933         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6934         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
6935         return (uint64_t)ret_conv;
6936 }
6937
6938 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6939         if ((_res & 1) != 0) return;
6940         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6941         FREE((void*)_res);
6942         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
6943 }
6944
6945 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6946         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6947         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6948         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6949         return (uint64_t)ret_conv;
6950 }
6951
6952 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6953         LDKCommitmentTransaction o_conv;
6954         o_conv.inner = (void*)(o & (~1));
6955         o_conv.is_owned = (o & 1) || (o == 0);
6956         o_conv = CommitmentTransaction_clone(&o_conv);
6957         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6958         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
6959         return (uint64_t)ret_conv;
6960 }
6961
6962 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6963         LDKDecodeError e_conv;
6964         e_conv.inner = (void*)(e & (~1));
6965         e_conv.is_owned = (e & 1) || (e == 0);
6966         e_conv = DecodeError_clone(&e_conv);
6967         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6968         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
6969         return (uint64_t)ret_conv;
6970 }
6971
6972 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6973         if ((_res & 1) != 0) return;
6974         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6975         FREE((void*)_res);
6976         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
6977 }
6978
6979 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6980         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
6981         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6982         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
6983         return (uint64_t)ret_conv;
6984 }
6985
6986 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
6987         LDKTrustedCommitmentTransaction o_conv;
6988         o_conv.inner = (void*)(o & (~1));
6989         o_conv.is_owned = (o & 1) || (o == 0);
6990         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
6991         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6992         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
6993         return (uint64_t)ret_conv;
6994 }
6995
6996 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
6997         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6998         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
6999         return (uint64_t)ret_conv;
7000 }
7001
7002 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
7003         if ((_res & 1) != 0) return;
7004         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
7005         FREE((void*)_res);
7006         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
7007 }
7008
7009 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
7010         LDKCVec_SignatureZ o_constr;
7011         o_constr.datalen = *((uint32_t*)o);
7012         if (o_constr.datalen > 0)
7013                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7014         else
7015                 o_constr.data = NULL;
7016         int8_tArray* o_vals = (int8_tArray*)(o + 4);
7017         for (size_t m = 0; m < o_constr.datalen; m++) {
7018                 int8_tArray o_conv_12 = o_vals[m];
7019                 LDKSignature o_conv_12_ref;
7020                 CHECK(*((uint32_t*)o_conv_12) == 64);
7021                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
7022                 o_constr.data[m] = o_conv_12_ref;
7023         }
7024         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7025         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
7026         return (uint64_t)ret_conv;
7027 }
7028
7029 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
7030         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7031         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
7032         return (uint64_t)ret_conv;
7033 }
7034
7035 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
7036         if ((_res & 1) != 0) return;
7037         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
7038         FREE((void*)_res);
7039         CResult_CVec_SignatureZNoneZ_free(_res_conv);
7040 }
7041
7042 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
7043         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
7044         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7045         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
7046         return (uint64_t)ret_conv;
7047 }
7048
7049 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
7050         LDKShutdownScript o_conv;
7051         o_conv.inner = (void*)(o & (~1));
7052         o_conv.is_owned = (o & 1) || (o == 0);
7053         o_conv = ShutdownScript_clone(&o_conv);
7054         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
7055         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
7056         return (uint64_t)ret_conv;
7057 }
7058
7059 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
7060         LDKDecodeError e_conv;
7061         e_conv.inner = (void*)(e & (~1));
7062         e_conv.is_owned = (e & 1) || (e == 0);
7063         e_conv = DecodeError_clone(&e_conv);
7064         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
7065         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
7066         return (uint64_t)ret_conv;
7067 }
7068
7069 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
7070         if ((_res & 1) != 0) return;
7071         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1);
7072         FREE((void*)_res);
7073         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
7074 }
7075
7076 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
7077         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
7078         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
7079         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
7080         return (uint64_t)ret_conv;
7081 }
7082
7083 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
7084         LDKShutdownScript o_conv;
7085         o_conv.inner = (void*)(o & (~1));
7086         o_conv.is_owned = (o & 1) || (o == 0);
7087         o_conv = ShutdownScript_clone(&o_conv);
7088         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
7089         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
7090         return (uint64_t)ret_conv;
7091 }
7092
7093 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
7094         LDKInvalidShutdownScript e_conv;
7095         e_conv.inner = (void*)(e & (~1));
7096         e_conv.is_owned = (e & 1) || (e == 0);
7097         // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript
7098         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
7099         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
7100         return (uint64_t)ret_conv;
7101 }
7102
7103 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
7104         if ((_res & 1) != 0) return;
7105         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1);
7106         FREE((void*)_res);
7107         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
7108 }
7109
7110 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
7111         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7112         *ret_conv = CResult_NoneErrorZ_ok();
7113         return (uint64_t)ret_conv;
7114 }
7115
7116 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
7117         LDKIOError e_conv = LDKIOError_from_js(e);
7118         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7119         *ret_conv = CResult_NoneErrorZ_err(e_conv);
7120         return (uint64_t)ret_conv;
7121 }
7122
7123 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
7124         if ((_res & 1) != 0) return;
7125         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
7126         FREE((void*)_res);
7127         CResult_NoneErrorZ_free(_res_conv);
7128 }
7129
7130 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
7131         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
7132         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7133         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
7134         return (uint64_t)ret_conv;
7135 }
7136
7137 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
7138         LDKRouteHop o_conv;
7139         o_conv.inner = (void*)(o & (~1));
7140         o_conv.is_owned = (o & 1) || (o == 0);
7141         o_conv = RouteHop_clone(&o_conv);
7142         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
7143         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
7144         return (uint64_t)ret_conv;
7145 }
7146
7147 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
7148         LDKDecodeError e_conv;
7149         e_conv.inner = (void*)(e & (~1));
7150         e_conv.is_owned = (e & 1) || (e == 0);
7151         e_conv = DecodeError_clone(&e_conv);
7152         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
7153         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
7154         return (uint64_t)ret_conv;
7155 }
7156
7157 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
7158         if ((_res & 1) != 0) return;
7159         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
7160         FREE((void*)_res);
7161         CResult_RouteHopDecodeErrorZ_free(_res_conv);
7162 }
7163
7164 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
7165         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
7166         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
7167         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
7168         return (uint64_t)ret_conv;
7169 }
7170
7171 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
7172         LDKCVec_RouteHopZ _res_constr;
7173         _res_constr.datalen = *((uint32_t*)_res);
7174         if (_res_constr.datalen > 0)
7175                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7176         else
7177                 _res_constr.data = NULL;
7178         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7179         for (size_t k = 0; k < _res_constr.datalen; k++) {
7180                 uint32_t _res_conv_10 = _res_vals[k];
7181                 LDKRouteHop _res_conv_10_conv;
7182                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
7183                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
7184                 _res_constr.data[k] = _res_conv_10_conv;
7185         }
7186         CVec_RouteHopZ_free(_res_constr);
7187 }
7188
7189 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
7190         LDKCVec_CVec_RouteHopZZ _res_constr;
7191         _res_constr.datalen = *((uint32_t*)_res);
7192         if (_res_constr.datalen > 0)
7193                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
7194         else
7195                 _res_constr.data = NULL;
7196         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
7197         for (size_t m = 0; m < _res_constr.datalen; m++) {
7198                 uint32_tArray _res_conv_12 = _res_vals[m];
7199                 LDKCVec_RouteHopZ _res_conv_12_constr;
7200                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
7201                 if (_res_conv_12_constr.datalen > 0)
7202                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7203                 else
7204                         _res_conv_12_constr.data = NULL;
7205                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
7206                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
7207                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
7208                         LDKRouteHop _res_conv_12_conv_10_conv;
7209                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
7210                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
7211                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
7212                 }
7213                 _res_constr.data[m] = _res_conv_12_constr;
7214         }
7215         CVec_CVec_RouteHopZZ_free(_res_constr);
7216 }
7217
7218 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
7219         LDKRoute o_conv;
7220         o_conv.inner = (void*)(o & (~1));
7221         o_conv.is_owned = (o & 1) || (o == 0);
7222         o_conv = Route_clone(&o_conv);
7223         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7224         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7225         return (uint64_t)ret_conv;
7226 }
7227
7228 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
7229         LDKDecodeError e_conv;
7230         e_conv.inner = (void*)(e & (~1));
7231         e_conv.is_owned = (e & 1) || (e == 0);
7232         e_conv = DecodeError_clone(&e_conv);
7233         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7234         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7235         return (uint64_t)ret_conv;
7236 }
7237
7238 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
7239         if ((_res & 1) != 0) return;
7240         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7241         FREE((void*)_res);
7242         CResult_RouteDecodeErrorZ_free(_res_conv);
7243 }
7244
7245 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
7246         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7247         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7248         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7249         return (uint64_t)ret_conv;
7250 }
7251
7252 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
7253         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7254         *ret_copy = COption_u64Z_some(o);
7255         uint64_t ret_ref = (uint64_t)ret_copy;
7256         return ret_ref;
7257 }
7258
7259 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
7260         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7261         *ret_copy = COption_u64Z_none();
7262         uint64_t ret_ref = (uint64_t)ret_copy;
7263         return ret_ref;
7264 }
7265
7266 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
7267         if ((_res & 1) != 0) return;
7268         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
7269         FREE((void*)_res);
7270         COption_u64Z_free(_res_conv);
7271 }
7272
7273 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
7274         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
7275         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7276         *ret_copy = COption_u64Z_clone(orig_conv);
7277         uint64_t ret_ref = (uint64_t)ret_copy;
7278         return ret_ref;
7279 }
7280
7281 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
7282         LDKCVec_ChannelDetailsZ _res_constr;
7283         _res_constr.datalen = *((uint32_t*)_res);
7284         if (_res_constr.datalen > 0)
7285                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7286         else
7287                 _res_constr.data = NULL;
7288         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7289         for (size_t q = 0; q < _res_constr.datalen; q++) {
7290                 uint32_t _res_conv_16 = _res_vals[q];
7291                 LDKChannelDetails _res_conv_16_conv;
7292                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7293                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7294                 _res_constr.data[q] = _res_conv_16_conv;
7295         }
7296         CVec_ChannelDetailsZ_free(_res_constr);
7297 }
7298
7299 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
7300         LDKCVec_RouteHintZ _res_constr;
7301         _res_constr.datalen = *((uint32_t*)_res);
7302         if (_res_constr.datalen > 0)
7303                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7304         else
7305                 _res_constr.data = NULL;
7306         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7307         for (size_t l = 0; l < _res_constr.datalen; l++) {
7308                 uint32_t _res_conv_11 = _res_vals[l];
7309                 LDKRouteHint _res_conv_11_conv;
7310                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
7311                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
7312                 _res_constr.data[l] = _res_conv_11_conv;
7313         }
7314         CVec_RouteHintZ_free(_res_constr);
7315 }
7316
7317 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
7318         LDKRoute o_conv;
7319         o_conv.inner = (void*)(o & (~1));
7320         o_conv.is_owned = (o & 1) || (o == 0);
7321         o_conv = Route_clone(&o_conv);
7322         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7323         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
7324         return (uint64_t)ret_conv;
7325 }
7326
7327 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
7328         LDKLightningError e_conv;
7329         e_conv.inner = (void*)(e & (~1));
7330         e_conv.is_owned = (e & 1) || (e == 0);
7331         e_conv = LightningError_clone(&e_conv);
7332         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7333         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
7334         return (uint64_t)ret_conv;
7335 }
7336
7337 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
7338         if ((_res & 1) != 0) return;
7339         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
7340         FREE((void*)_res);
7341         CResult_RouteLightningErrorZ_free(_res_conv);
7342 }
7343
7344 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
7345         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
7346         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7347         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
7348         return (uint64_t)ret_conv;
7349 }
7350
7351 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
7352         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
7353         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7354         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
7355         return (uint64_t)ret_conv;
7356 }
7357
7358 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
7359         LDKAccessError e_conv = LDKAccessError_from_js(e);
7360         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7361         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
7362         return (uint64_t)ret_conv;
7363 }
7364
7365 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
7366         if ((_res & 1) != 0) return;
7367         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
7368         FREE((void*)_res);
7369         CResult_TxOutAccessErrorZ_free(_res_conv);
7370 }
7371
7372 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
7373         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
7374         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7375         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
7376         return (uint64_t)ret_conv;
7377 }
7378
7379 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
7380         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
7381         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7382         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
7383         return (uint64_t)ret_ref;
7384 }
7385
7386 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
7387         LDKTransaction b_ref;
7388         b_ref.datalen = *((uint32_t*)b);
7389         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
7390         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
7391         b_ref.data_is_owned = true;
7392         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7393         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
7394         return (uint64_t)ret_ref;
7395 }
7396
7397 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
7398         if ((_res & 1) != 0) return;
7399         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
7400         FREE((void*)_res);
7401         C2Tuple_usizeTransactionZ_free(_res_conv);
7402 }
7403
7404 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
7405         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
7406         _res_constr.datalen = *((uint32_t*)_res);
7407         if (_res_constr.datalen > 0)
7408                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7409         else
7410                 _res_constr.data = NULL;
7411         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7412         for (size_t e = 0; e < _res_constr.datalen; e++) {
7413                 uint32_t _res_conv_30 = _res_vals[e];
7414                 LDKC2Tuple_usizeTransactionZ _res_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_30) & ~1);
7415                 FREE((void*)_res_conv_30);
7416                 _res_constr.data[e] = _res_conv_30_conv;
7417         }
7418         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
7419 }
7420
7421 void  __attribute__((visibility("default"))) TS_CVec_TxidZ_free(ptrArray _res) {
7422         LDKCVec_TxidZ _res_constr;
7423         _res_constr.datalen = *((uint32_t*)_res);
7424         if (_res_constr.datalen > 0)
7425                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7426         else
7427                 _res_constr.data = NULL;
7428         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7429         for (size_t m = 0; m < _res_constr.datalen; m++) {
7430                 int8_tArray _res_conv_12 = _res_vals[m];
7431                 LDKThirtyTwoBytes _res_conv_12_ref;
7432                 CHECK(*((uint32_t*)_res_conv_12) == 32);
7433                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), 32);
7434                 _res_constr.data[m] = _res_conv_12_ref;
7435         }
7436         CVec_TxidZ_free(_res_constr);
7437 }
7438
7439 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
7440         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7441         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
7442         return (uint64_t)ret_conv;
7443 }
7444
7445 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
7446         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
7447         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7448         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
7449         return (uint64_t)ret_conv;
7450 }
7451
7452 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
7453         if ((_res & 1) != 0) return;
7454         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
7455         FREE((void*)_res);
7456         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
7457 }
7458
7459 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
7460         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
7461         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7462         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
7463         return (uint64_t)ret_conv;
7464 }
7465
7466 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
7467         LDKCVec_MonitorEventZ _res_constr;
7468         _res_constr.datalen = *((uint32_t*)_res);
7469         if (_res_constr.datalen > 0)
7470                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
7471         else
7472                 _res_constr.data = NULL;
7473         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7474         for (size_t o = 0; o < _res_constr.datalen; o++) {
7475                 uint32_t _res_conv_14 = _res_vals[o];
7476                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
7477                 FREE((void*)_res_conv_14);
7478                 _res_constr.data[o] = _res_conv_14_conv;
7479         }
7480         CVec_MonitorEventZ_free(_res_constr);
7481 }
7482
7483 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
7484         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
7485         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7486         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
7487         uint64_t ret_ref = (uint64_t)ret_copy;
7488         return ret_ref;
7489 }
7490
7491 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
7492         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7493         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
7494         uint64_t ret_ref = (uint64_t)ret_copy;
7495         return ret_ref;
7496 }
7497
7498 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
7499         if ((_res & 1) != 0) return;
7500         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
7501         FREE((void*)_res);
7502         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
7503 }
7504
7505 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
7506         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
7507         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7508         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
7509         uint64_t ret_ref = (uint64_t)ret_copy;
7510         return ret_ref;
7511 }
7512
7513 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
7514         LDKCVec_SpendableOutputDescriptorZ _res_constr;
7515         _res_constr.datalen = *((uint32_t*)_res);
7516         if (_res_constr.datalen > 0)
7517                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
7518         else
7519                 _res_constr.data = NULL;
7520         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7521         for (size_t b = 0; b < _res_constr.datalen; b++) {
7522                 uint32_t _res_conv_27 = _res_vals[b];
7523                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
7524                 FREE((void*)_res_conv_27);
7525                 _res_constr.data[b] = _res_conv_27_conv;
7526         }
7527         CVec_SpendableOutputDescriptorZ_free(_res_constr);
7528 }
7529
7530 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
7531         LDKCVec_MessageSendEventZ _res_constr;
7532         _res_constr.datalen = *((uint32_t*)_res);
7533         if (_res_constr.datalen > 0)
7534                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7535         else
7536                 _res_constr.data = NULL;
7537         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7538         for (size_t s = 0; s < _res_constr.datalen; s++) {
7539                 uint32_t _res_conv_18 = _res_vals[s];
7540                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
7541                 FREE((void*)_res_conv_18);
7542                 _res_constr.data[s] = _res_conv_18_conv;
7543         }
7544         CVec_MessageSendEventZ_free(_res_constr);
7545 }
7546
7547 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
7548         LDKInitFeatures o_conv;
7549         o_conv.inner = (void*)(o & (~1));
7550         o_conv.is_owned = (o & 1) || (o == 0);
7551         o_conv = InitFeatures_clone(&o_conv);
7552         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7553         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
7554         return (uint64_t)ret_conv;
7555 }
7556
7557 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
7558         LDKDecodeError e_conv;
7559         e_conv.inner = (void*)(e & (~1));
7560         e_conv.is_owned = (e & 1) || (e == 0);
7561         e_conv = DecodeError_clone(&e_conv);
7562         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7563         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
7564         return (uint64_t)ret_conv;
7565 }
7566
7567 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
7568         if ((_res & 1) != 0) return;
7569         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7570         FREE((void*)_res);
7571         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
7572 }
7573
7574 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
7575         LDKNodeFeatures o_conv;
7576         o_conv.inner = (void*)(o & (~1));
7577         o_conv.is_owned = (o & 1) || (o == 0);
7578         o_conv = NodeFeatures_clone(&o_conv);
7579         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7580         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
7581         return (uint64_t)ret_conv;
7582 }
7583
7584 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
7585         LDKDecodeError e_conv;
7586         e_conv.inner = (void*)(e & (~1));
7587         e_conv.is_owned = (e & 1) || (e == 0);
7588         e_conv = DecodeError_clone(&e_conv);
7589         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7590         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
7591         return (uint64_t)ret_conv;
7592 }
7593
7594 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
7595         if ((_res & 1) != 0) return;
7596         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7597         FREE((void*)_res);
7598         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
7599 }
7600
7601 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
7602         LDKChannelFeatures o_conv;
7603         o_conv.inner = (void*)(o & (~1));
7604         o_conv.is_owned = (o & 1) || (o == 0);
7605         o_conv = ChannelFeatures_clone(&o_conv);
7606         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7607         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
7608         return (uint64_t)ret_conv;
7609 }
7610
7611 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
7612         LDKDecodeError e_conv;
7613         e_conv.inner = (void*)(e & (~1));
7614         e_conv.is_owned = (e & 1) || (e == 0);
7615         e_conv = DecodeError_clone(&e_conv);
7616         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7617         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
7618         return (uint64_t)ret_conv;
7619 }
7620
7621 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
7622         if ((_res & 1) != 0) return;
7623         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7624         FREE((void*)_res);
7625         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
7626 }
7627
7628 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
7629         LDKInvoiceFeatures o_conv;
7630         o_conv.inner = (void*)(o & (~1));
7631         o_conv.is_owned = (o & 1) || (o == 0);
7632         o_conv = InvoiceFeatures_clone(&o_conv);
7633         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7634         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
7635         return (uint64_t)ret_conv;
7636 }
7637
7638 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
7639         LDKDecodeError e_conv;
7640         e_conv.inner = (void*)(e & (~1));
7641         e_conv.is_owned = (e & 1) || (e == 0);
7642         e_conv = DecodeError_clone(&e_conv);
7643         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7644         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
7645         return (uint64_t)ret_conv;
7646 }
7647
7648 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
7649         if ((_res & 1) != 0) return;
7650         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7651         FREE((void*)_res);
7652         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
7653 }
7654
7655 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7656         LDKDelayedPaymentOutputDescriptor o_conv;
7657         o_conv.inner = (void*)(o & (~1));
7658         o_conv.is_owned = (o & 1) || (o == 0);
7659         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
7660         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7661         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
7662         return (uint64_t)ret_conv;
7663 }
7664
7665 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7666         LDKDecodeError e_conv;
7667         e_conv.inner = (void*)(e & (~1));
7668         e_conv.is_owned = (e & 1) || (e == 0);
7669         e_conv = DecodeError_clone(&e_conv);
7670         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7671         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
7672         return (uint64_t)ret_conv;
7673 }
7674
7675 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7676         if ((_res & 1) != 0) return;
7677         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7678         FREE((void*)_res);
7679         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
7680 }
7681
7682 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7683         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
7684         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7685         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
7686         return (uint64_t)ret_conv;
7687 }
7688
7689 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7690         LDKStaticPaymentOutputDescriptor o_conv;
7691         o_conv.inner = (void*)(o & (~1));
7692         o_conv.is_owned = (o & 1) || (o == 0);
7693         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
7694         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7695         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
7696         return (uint64_t)ret_conv;
7697 }
7698
7699 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7700         LDKDecodeError e_conv;
7701         e_conv.inner = (void*)(e & (~1));
7702         e_conv.is_owned = (e & 1) || (e == 0);
7703         e_conv = DecodeError_clone(&e_conv);
7704         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7705         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
7706         return (uint64_t)ret_conv;
7707 }
7708
7709 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7710         if ((_res & 1) != 0) return;
7711         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7712         FREE((void*)_res);
7713         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
7714 }
7715
7716 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7717         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
7718         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7719         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
7720         return (uint64_t)ret_conv;
7721 }
7722
7723 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7724         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
7725         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7726         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
7727         return (uint64_t)ret_conv;
7728 }
7729
7730 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7731         LDKDecodeError e_conv;
7732         e_conv.inner = (void*)(e & (~1));
7733         e_conv.is_owned = (e & 1) || (e == 0);
7734         e_conv = DecodeError_clone(&e_conv);
7735         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7736         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
7737         return (uint64_t)ret_conv;
7738 }
7739
7740 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7741         if ((_res & 1) != 0) return;
7742         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7743         FREE((void*)_res);
7744         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
7745 }
7746
7747 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7748         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
7749         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7750         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
7751         return (uint64_t)ret_conv;
7752 }
7753
7754 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
7755         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
7756         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7757         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
7758         return (uint64_t)ret_ref;
7759 }
7760
7761 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
7762         LDKSignature a_ref;
7763         CHECK(*((uint32_t*)a) == 64);
7764         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
7765         LDKCVec_SignatureZ b_constr;
7766         b_constr.datalen = *((uint32_t*)b);
7767         if (b_constr.datalen > 0)
7768                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7769         else
7770                 b_constr.data = NULL;
7771         int8_tArray* b_vals = (int8_tArray*)(b + 4);
7772         for (size_t m = 0; m < b_constr.datalen; m++) {
7773                 int8_tArray b_conv_12 = b_vals[m];
7774                 LDKSignature b_conv_12_ref;
7775                 CHECK(*((uint32_t*)b_conv_12) == 64);
7776                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
7777                 b_constr.data[m] = b_conv_12_ref;
7778         }
7779         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7780         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
7781         return (uint64_t)ret_ref;
7782 }
7783
7784 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
7785         if ((_res & 1) != 0) return;
7786         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
7787         FREE((void*)_res);
7788         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
7789 }
7790
7791 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
7792         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
7793         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7794         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
7795         return (uint64_t)ret_conv;
7796 }
7797
7798 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
7799         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7800         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
7801         return (uint64_t)ret_conv;
7802 }
7803
7804 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
7805         if ((_res & 1) != 0) return;
7806         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
7807         FREE((void*)_res);
7808         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
7809 }
7810
7811 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
7812         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
7813         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7814         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
7815         return (uint64_t)ret_conv;
7816 }
7817
7818 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
7819         LDKSignature o_ref;
7820         CHECK(*((uint32_t*)o) == 64);
7821         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
7822         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7823         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
7824         return (uint64_t)ret_conv;
7825 }
7826
7827 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
7828         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7829         *ret_conv = CResult_SignatureNoneZ_err();
7830         return (uint64_t)ret_conv;
7831 }
7832
7833 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
7834         if ((_res & 1) != 0) return;
7835         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
7836         FREE((void*)_res);
7837         CResult_SignatureNoneZ_free(_res_conv);
7838 }
7839
7840 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
7841         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
7842         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7843         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
7844         return (uint64_t)ret_conv;
7845 }
7846
7847 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
7848         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
7849         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7850         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
7851         return (uint64_t)ret_conv;
7852 }
7853
7854 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
7855         LDKDecodeError e_conv;
7856         e_conv.inner = (void*)(e & (~1));
7857         e_conv.is_owned = (e & 1) || (e == 0);
7858         e_conv = DecodeError_clone(&e_conv);
7859         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7860         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
7861         return (uint64_t)ret_conv;
7862 }
7863
7864 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
7865         if ((_res & 1) != 0) return;
7866         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
7867         FREE((void*)_res);
7868         CResult_SignDecodeErrorZ_free(_res_conv);
7869 }
7870
7871 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
7872         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
7873         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7874         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
7875         return (uint64_t)ret_conv;
7876 }
7877
7878 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
7879         LDKCVec_u8Z _res_ref;
7880         _res_ref.datalen = *((uint32_t*)_res);
7881         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
7882         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
7883         CVec_u8Z_free(_res_ref);
7884 }
7885
7886 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray arg) {
7887         LDKRecoverableSignature arg_ref;
7888         CHECK(*((uint32_t*)arg) == 68);
7889         memcpy(arg_ref.serialized_form, (uint8_t*)(arg + 4), 68);
7890         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7891         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
7892         return (uint64_t)ret_conv;
7893 }
7894
7895 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_err() {
7896         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7897         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
7898         return (uint64_t)ret_conv;
7899 }
7900
7901 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
7902         if ((_res & 1) != 0) return;
7903         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
7904         FREE((void*)_res);
7905         CResult_RecoverableSignatureNoneZ_free(_res_conv);
7906 }
7907
7908 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
7909         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
7910         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7911         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
7912         return (uint64_t)ret_conv;
7913 }
7914
7915 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
7916         LDKCVec_CVec_u8ZZ _res_constr;
7917         _res_constr.datalen = *((uint32_t*)_res);
7918         if (_res_constr.datalen > 0)
7919                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7920         else
7921                 _res_constr.data = NULL;
7922         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7923         for (size_t m = 0; m < _res_constr.datalen; m++) {
7924                 int8_tArray _res_conv_12 = _res_vals[m];
7925                 LDKCVec_u8Z _res_conv_12_ref;
7926                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
7927                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7928                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
7929                 _res_constr.data[m] = _res_conv_12_ref;
7930         }
7931         CVec_CVec_u8ZZ_free(_res_constr);
7932 }
7933
7934 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
7935         LDKCVec_CVec_u8ZZ o_constr;
7936         o_constr.datalen = *((uint32_t*)o);
7937         if (o_constr.datalen > 0)
7938                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7939         else
7940                 o_constr.data = NULL;
7941         int8_tArray* o_vals = (int8_tArray*)(o + 4);
7942         for (size_t m = 0; m < o_constr.datalen; m++) {
7943                 int8_tArray o_conv_12 = o_vals[m];
7944                 LDKCVec_u8Z o_conv_12_ref;
7945                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
7946                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7947                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
7948                 o_constr.data[m] = o_conv_12_ref;
7949         }
7950         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7951         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
7952         return (uint64_t)ret_conv;
7953 }
7954
7955 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
7956         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7957         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
7958         return (uint64_t)ret_conv;
7959 }
7960
7961 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
7962         if ((_res & 1) != 0) return;
7963         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
7964         FREE((void*)_res);
7965         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
7966 }
7967
7968 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
7969         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
7970         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7971         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
7972         return (uint64_t)ret_conv;
7973 }
7974
7975 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
7976         LDKInMemorySigner o_conv;
7977         o_conv.inner = (void*)(o & (~1));
7978         o_conv.is_owned = (o & 1) || (o == 0);
7979         o_conv = InMemorySigner_clone(&o_conv);
7980         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7981         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
7982         return (uint64_t)ret_conv;
7983 }
7984
7985 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
7986         LDKDecodeError e_conv;
7987         e_conv.inner = (void*)(e & (~1));
7988         e_conv.is_owned = (e & 1) || (e == 0);
7989         e_conv = DecodeError_clone(&e_conv);
7990         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7991         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
7992         return (uint64_t)ret_conv;
7993 }
7994
7995 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
7996         if ((_res & 1) != 0) return;
7997         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
7998         FREE((void*)_res);
7999         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
8000 }
8001
8002 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
8003         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
8004         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8005         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
8006         return (uint64_t)ret_conv;
8007 }
8008
8009 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
8010         LDKCVec_TxOutZ _res_constr;
8011         _res_constr.datalen = *((uint32_t*)_res);
8012         if (_res_constr.datalen > 0)
8013                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
8014         else
8015                 _res_constr.data = NULL;
8016         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8017         for (size_t h = 0; h < _res_constr.datalen; h++) {
8018                 uint32_t _res_conv_7 = _res_vals[h];
8019                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
8020                 FREE((void*)_res_conv_7);
8021                 _res_constr.data[h] = _res_conv_7_conv;
8022         }
8023         CVec_TxOutZ_free(_res_constr);
8024 }
8025
8026 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
8027         LDKTransaction o_ref;
8028         o_ref.datalen = *((uint32_t*)o);
8029         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
8030         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
8031         o_ref.data_is_owned = true;
8032         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8033         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
8034         return (uint64_t)ret_conv;
8035 }
8036
8037 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
8038         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8039         *ret_conv = CResult_TransactionNoneZ_err();
8040         return (uint64_t)ret_conv;
8041 }
8042
8043 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
8044         if ((_res & 1) != 0) return;
8045         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
8046         FREE((void*)_res);
8047         CResult_TransactionNoneZ_free(_res_conv);
8048 }
8049
8050 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
8051         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
8052         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8053         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
8054         return (uint64_t)ret_conv;
8055 }
8056
8057 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
8058         LDKThirtyTwoBytes a_ref;
8059         CHECK(*((uint32_t*)a) == 32);
8060         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8061         LDKChannelMonitor b_conv;
8062         b_conv.inner = (void*)(b & (~1));
8063         b_conv.is_owned = (b & 1) || (b == 0);
8064         b_conv = ChannelMonitor_clone(&b_conv);
8065         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8066         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
8067         return (uint64_t)ret_ref;
8068 }
8069
8070 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
8071         if ((_res & 1) != 0) return;
8072         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
8073         FREE((void*)_res);
8074         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
8075 }
8076
8077 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMonitorZZ_free(uint32_tArray _res) {
8078         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
8079         _res_constr.datalen = *((uint32_t*)_res);
8080         if (_res_constr.datalen > 0)
8081                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
8082         else
8083                 _res_constr.data = NULL;
8084         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8085         for (size_t m = 0; m < _res_constr.datalen; m++) {
8086                 uint32_t _res_conv_38 = _res_vals[m];
8087                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_38) & ~1);
8088                 FREE((void*)_res_conv_38);
8089                 _res_constr.data[m] = _res_conv_38_conv;
8090         }
8091         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
8092 }
8093
8094 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(uint32_tArray o) {
8095         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
8096         o_constr.datalen = *((uint32_t*)o);
8097         if (o_constr.datalen > 0)
8098                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
8099         else
8100                 o_constr.data = NULL;
8101         uint32_t* o_vals = (uint32_t*)(o + 4);
8102         for (size_t m = 0; m < o_constr.datalen; m++) {
8103                 uint32_t o_conv_38 = o_vals[m];
8104                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_38) & ~1);
8105                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
8106                 o_constr.data[m] = o_conv_38_conv;
8107         }
8108         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
8109         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
8110         return (uint64_t)ret_conv;
8111 }
8112
8113 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(uint32_t e) {
8114         LDKIOError e_conv = LDKIOError_from_js(e);
8115         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
8116         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
8117         return (uint64_t)ret_conv;
8118 }
8119
8120 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
8121         if ((_res & 1) != 0) return;
8122         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
8123         FREE((void*)_res);
8124         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
8125 }
8126
8127 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) {
8128         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
8129         *ret_copy = COption_u16Z_some(o);
8130         uint64_t ret_ref = (uint64_t)ret_copy;
8131         return ret_ref;
8132 }
8133
8134 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_none() {
8135         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
8136         *ret_copy = COption_u16Z_none();
8137         uint64_t ret_ref = (uint64_t)ret_copy;
8138         return ret_ref;
8139 }
8140
8141 void  __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) {
8142         if ((_res & 1) != 0) return;
8143         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
8144         FREE((void*)_res);
8145         COption_u16Z_free(_res_conv);
8146 }
8147
8148 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_clone(uint32_t orig) {
8149         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
8150         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
8151         *ret_copy = COption_u16Z_clone(orig_conv);
8152         uint64_t ret_ref = (uint64_t)ret_copy;
8153         return ret_ref;
8154 }
8155
8156 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
8157         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8158         *ret_conv = CResult_NoneAPIErrorZ_ok();
8159         return (uint64_t)ret_conv;
8160 }
8161
8162 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
8163         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
8164         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8165         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
8166         return (uint64_t)ret_conv;
8167 }
8168
8169 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
8170         if ((_res & 1) != 0) return;
8171         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
8172         FREE((void*)_res);
8173         CResult_NoneAPIErrorZ_free(_res_conv);
8174 }
8175
8176 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
8177         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
8178         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8179         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
8180         return (uint64_t)ret_conv;
8181 }
8182
8183 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
8184         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
8185         _res_constr.datalen = *((uint32_t*)_res);
8186         if (_res_constr.datalen > 0)
8187                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
8188         else
8189                 _res_constr.data = NULL;
8190         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8191         for (size_t w = 0; w < _res_constr.datalen; w++) {
8192                 uint32_t _res_conv_22 = _res_vals[w];
8193                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
8194                 FREE((void*)_res_conv_22);
8195                 _res_constr.data[w] = _res_conv_22_conv;
8196         }
8197         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
8198 }
8199
8200 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
8201         LDKCVec_APIErrorZ _res_constr;
8202         _res_constr.datalen = *((uint32_t*)_res);
8203         if (_res_constr.datalen > 0)
8204                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
8205         else
8206                 _res_constr.data = NULL;
8207         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8208         for (size_t k = 0; k < _res_constr.datalen; k++) {
8209                 uint32_t _res_conv_10 = _res_vals[k];
8210                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
8211                 FREE((void*)_res_conv_10);
8212                 _res_constr.data[k] = _res_conv_10_conv;
8213         }
8214         CVec_APIErrorZ_free(_res_constr);
8215 }
8216
8217 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
8218         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8219         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
8220         return (uint64_t)ret_conv;
8221 }
8222
8223 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
8224         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
8225         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8226         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
8227         return (uint64_t)ret_conv;
8228 }
8229
8230 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
8231         if ((_res & 1) != 0) return;
8232         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
8233         FREE((void*)_res);
8234         CResult_NonePaymentSendFailureZ_free(_res_conv);
8235 }
8236
8237 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
8238         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
8239         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8240         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
8241         return (uint64_t)ret_conv;
8242 }
8243
8244 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_ok(int8_tArray o) {
8245         LDKThirtyTwoBytes o_ref;
8246         CHECK(*((uint32_t*)o) == 32);
8247         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
8248         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
8249         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
8250         return (uint64_t)ret_conv;
8251 }
8252
8253 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_err(uint32_t e) {
8254         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
8255         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
8256         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
8257         return (uint64_t)ret_conv;
8258 }
8259
8260 void  __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_free(uint32_t _res) {
8261         if ((_res & 1) != 0) return;
8262         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
8263         FREE((void*)_res);
8264         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
8265 }
8266
8267 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_clone(uint32_t orig) {
8268         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)(orig & ~1);
8269         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
8270         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
8271         return (uint64_t)ret_conv;
8272 }
8273
8274 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
8275         LDKCVec_NetAddressZ _res_constr;
8276         _res_constr.datalen = *((uint32_t*)_res);
8277         if (_res_constr.datalen > 0)
8278                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
8279         else
8280                 _res_constr.data = NULL;
8281         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8282         for (size_t m = 0; m < _res_constr.datalen; m++) {
8283                 uint32_t _res_conv_12 = _res_vals[m];
8284                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
8285                 FREE((void*)_res_conv_12);
8286                 _res_constr.data[m] = _res_conv_12_conv;
8287         }
8288         CVec_NetAddressZ_free(_res_constr);
8289 }
8290
8291 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
8292         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
8293         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
8294         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
8295         return (uint64_t)ret_ref;
8296 }
8297
8298 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
8299         LDKThirtyTwoBytes a_ref;
8300         CHECK(*((uint32_t*)a) == 32);
8301         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8302         LDKThirtyTwoBytes b_ref;
8303         CHECK(*((uint32_t*)b) == 32);
8304         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
8305         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
8306         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
8307         return (uint64_t)ret_ref;
8308 }
8309
8310 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
8311         if ((_res & 1) != 0) return;
8312         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
8313         FREE((void*)_res);
8314         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
8315 }
8316
8317 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
8318         LDKThirtyTwoBytes o_ref;
8319         CHECK(*((uint32_t*)o) == 32);
8320         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
8321         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8322         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
8323         return (uint64_t)ret_conv;
8324 }
8325
8326 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
8327         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
8328         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8329         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
8330         return (uint64_t)ret_conv;
8331 }
8332
8333 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
8334         if ((_res & 1) != 0) return;
8335         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
8336         FREE((void*)_res);
8337         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
8338 }
8339
8340 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
8341         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
8342         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8343         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
8344         return (uint64_t)ret_conv;
8345 }
8346
8347 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
8348         LDKCVec_ChannelMonitorZ _res_constr;
8349         _res_constr.datalen = *((uint32_t*)_res);
8350         if (_res_constr.datalen > 0)
8351                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
8352         else
8353                 _res_constr.data = NULL;
8354         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8355         for (size_t q = 0; q < _res_constr.datalen; q++) {
8356                 uint32_t _res_conv_16 = _res_vals[q];
8357                 LDKChannelMonitor _res_conv_16_conv;
8358                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8359                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8360                 _res_constr.data[q] = _res_conv_16_conv;
8361         }
8362         CVec_ChannelMonitorZ_free(_res_constr);
8363 }
8364
8365 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
8366         LDKThirtyTwoBytes a_ref;
8367         CHECK(*((uint32_t*)a) == 32);
8368         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8369         LDKChannelManager b_conv;
8370         b_conv.inner = (void*)(b & (~1));
8371         b_conv.is_owned = (b & 1) || (b == 0);
8372         // Warning: we need a move here but no clone is available for LDKChannelManager
8373         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
8374         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
8375         return (uint64_t)ret_ref;
8376 }
8377
8378 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
8379         if ((_res & 1) != 0) return;
8380         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
8381         FREE((void*)_res);
8382         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
8383 }
8384
8385 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
8386         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
8387         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8388         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
8389         return (uint64_t)ret_conv;
8390 }
8391
8392 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
8393         LDKDecodeError e_conv;
8394         e_conv.inner = (void*)(e & (~1));
8395         e_conv.is_owned = (e & 1) || (e == 0);
8396         e_conv = DecodeError_clone(&e_conv);
8397         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8398         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
8399         return (uint64_t)ret_conv;
8400 }
8401
8402 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
8403         if ((_res & 1) != 0) return;
8404         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8405         FREE((void*)_res);
8406         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
8407 }
8408
8409 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
8410         LDKChannelConfig o_conv;
8411         o_conv.inner = (void*)(o & (~1));
8412         o_conv.is_owned = (o & 1) || (o == 0);
8413         o_conv = ChannelConfig_clone(&o_conv);
8414         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8415         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
8416         return (uint64_t)ret_conv;
8417 }
8418
8419 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
8420         LDKDecodeError e_conv;
8421         e_conv.inner = (void*)(e & (~1));
8422         e_conv.is_owned = (e & 1) || (e == 0);
8423         e_conv = DecodeError_clone(&e_conv);
8424         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8425         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
8426         return (uint64_t)ret_conv;
8427 }
8428
8429 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
8430         if ((_res & 1) != 0) return;
8431         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
8432         FREE((void*)_res);
8433         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
8434 }
8435
8436 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
8437         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
8438         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8439         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
8440         return (uint64_t)ret_conv;
8441 }
8442
8443 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
8444         LDKOutPoint o_conv;
8445         o_conv.inner = (void*)(o & (~1));
8446         o_conv.is_owned = (o & 1) || (o == 0);
8447         o_conv = OutPoint_clone(&o_conv);
8448         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8449         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
8450         return (uint64_t)ret_conv;
8451 }
8452
8453 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
8454         LDKDecodeError e_conv;
8455         e_conv.inner = (void*)(e & (~1));
8456         e_conv.is_owned = (e & 1) || (e == 0);
8457         e_conv = DecodeError_clone(&e_conv);
8458         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8459         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
8460         return (uint64_t)ret_conv;
8461 }
8462
8463 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
8464         if ((_res & 1) != 0) return;
8465         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
8466         FREE((void*)_res);
8467         CResult_OutPointDecodeErrorZ_free(_res_conv);
8468 }
8469
8470 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
8471         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
8472         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8473         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
8474         return (uint64_t)ret_conv;
8475 }
8476
8477 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
8478         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
8479         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8480         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
8481         return (uint64_t)ret_conv;
8482 }
8483
8484 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err() {
8485         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8486         *ret_conv = CResult_SiPrefixNoneZ_err();
8487         return (uint64_t)ret_conv;
8488 }
8489
8490 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
8491         if ((_res & 1) != 0) return;
8492         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
8493         FREE((void*)_res);
8494         CResult_SiPrefixNoneZ_free(_res_conv);
8495 }
8496
8497 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
8498         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
8499         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8500         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
8501         return (uint64_t)ret_conv;
8502 }
8503
8504 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
8505         LDKInvoice o_conv;
8506         o_conv.inner = (void*)(o & (~1));
8507         o_conv.is_owned = (o & 1) || (o == 0);
8508         o_conv = Invoice_clone(&o_conv);
8509         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8510         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
8511         return (uint64_t)ret_conv;
8512 }
8513
8514 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
8515         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8516         *ret_conv = CResult_InvoiceNoneZ_err();
8517         return (uint64_t)ret_conv;
8518 }
8519
8520 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
8521         if ((_res & 1) != 0) return;
8522         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
8523         FREE((void*)_res);
8524         CResult_InvoiceNoneZ_free(_res_conv);
8525 }
8526
8527 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
8528         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
8529         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8530         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
8531         return (uint64_t)ret_conv;
8532 }
8533
8534 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
8535         LDKSignedRawInvoice o_conv;
8536         o_conv.inner = (void*)(o & (~1));
8537         o_conv.is_owned = (o & 1) || (o == 0);
8538         o_conv = SignedRawInvoice_clone(&o_conv);
8539         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8540         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
8541         return (uint64_t)ret_conv;
8542 }
8543
8544 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
8545         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8546         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
8547         return (uint64_t)ret_conv;
8548 }
8549
8550 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
8551         if ((_res & 1) != 0) return;
8552         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
8553         FREE((void*)_res);
8554         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
8555 }
8556
8557 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
8558         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
8559         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8560         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
8561         return (uint64_t)ret_conv;
8562 }
8563
8564 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
8565         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
8566         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
8567         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
8568         return (uint64_t)ret_ref;
8569 }
8570
8571 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
8572         LDKRawInvoice a_conv;
8573         a_conv.inner = (void*)(a & (~1));
8574         a_conv.is_owned = (a & 1) || (a == 0);
8575         a_conv = RawInvoice_clone(&a_conv);
8576         LDKThirtyTwoBytes b_ref;
8577         CHECK(*((uint32_t*)b) == 32);
8578         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
8579         LDKInvoiceSignature c_conv;
8580         c_conv.inner = (void*)(c & (~1));
8581         c_conv.is_owned = (c & 1) || (c == 0);
8582         c_conv = InvoiceSignature_clone(&c_conv);
8583         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
8584         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
8585         return (uint64_t)ret_ref;
8586 }
8587
8588 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
8589         if ((_res & 1) != 0) return;
8590         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
8591         FREE((void*)_res);
8592         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
8593 }
8594
8595 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
8596         LDKPayeePubKey o_conv;
8597         o_conv.inner = (void*)(o & (~1));
8598         o_conv.is_owned = (o & 1) || (o == 0);
8599         o_conv = PayeePubKey_clone(&o_conv);
8600         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8601         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
8602         return (uint64_t)ret_conv;
8603 }
8604
8605 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
8606         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8607         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8608         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
8609         return (uint64_t)ret_conv;
8610 }
8611
8612 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
8613         if ((_res & 1) != 0) return;
8614         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
8615         FREE((void*)_res);
8616         CResult_PayeePubKeyErrorZ_free(_res_conv);
8617 }
8618
8619 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
8620         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
8621         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8622         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
8623         return (uint64_t)ret_conv;
8624 }
8625
8626 void  __attribute__((visibility("default"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
8627         LDKCVec_PrivateRouteZ _res_constr;
8628         _res_constr.datalen = *((uint32_t*)_res);
8629         if (_res_constr.datalen > 0)
8630                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
8631         else
8632                 _res_constr.data = NULL;
8633         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8634         for (size_t o = 0; o < _res_constr.datalen; o++) {
8635                 uint32_t _res_conv_14 = _res_vals[o];
8636                 LDKPrivateRoute _res_conv_14_conv;
8637                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
8638                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
8639                 _res_constr.data[o] = _res_conv_14_conv;
8640         }
8641         CVec_PrivateRouteZ_free(_res_constr);
8642 }
8643
8644 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
8645         LDKPositiveTimestamp o_conv;
8646         o_conv.inner = (void*)(o & (~1));
8647         o_conv.is_owned = (o & 1) || (o == 0);
8648         o_conv = PositiveTimestamp_clone(&o_conv);
8649         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8650         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
8651         return (uint64_t)ret_conv;
8652 }
8653
8654 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
8655         LDKCreationError e_conv = LDKCreationError_from_js(e);
8656         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8657         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
8658         return (uint64_t)ret_conv;
8659 }
8660
8661 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
8662         if ((_res & 1) != 0) return;
8663         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
8664         FREE((void*)_res);
8665         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
8666 }
8667
8668 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
8669         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
8670         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8671         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
8672         return (uint64_t)ret_conv;
8673 }
8674
8675 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_ok() {
8676         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8677         *ret_conv = CResult_NoneSemanticErrorZ_ok();
8678         return (uint64_t)ret_conv;
8679 }
8680
8681 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
8682         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
8683         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8684         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
8685         return (uint64_t)ret_conv;
8686 }
8687
8688 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
8689         if ((_res & 1) != 0) return;
8690         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
8691         FREE((void*)_res);
8692         CResult_NoneSemanticErrorZ_free(_res_conv);
8693 }
8694
8695 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
8696         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
8697         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8698         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
8699         return (uint64_t)ret_conv;
8700 }
8701
8702 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
8703         LDKInvoice o_conv;
8704         o_conv.inner = (void*)(o & (~1));
8705         o_conv.is_owned = (o & 1) || (o == 0);
8706         o_conv = Invoice_clone(&o_conv);
8707         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8708         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
8709         return (uint64_t)ret_conv;
8710 }
8711
8712 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
8713         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
8714         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8715         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
8716         return (uint64_t)ret_conv;
8717 }
8718
8719 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
8720         if ((_res & 1) != 0) return;
8721         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
8722         FREE((void*)_res);
8723         CResult_InvoiceSemanticErrorZ_free(_res_conv);
8724 }
8725
8726 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
8727         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
8728         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8729         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
8730         return (uint64_t)ret_conv;
8731 }
8732
8733 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
8734         LDKDescription o_conv;
8735         o_conv.inner = (void*)(o & (~1));
8736         o_conv.is_owned = (o & 1) || (o == 0);
8737         o_conv = Description_clone(&o_conv);
8738         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8739         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
8740         return (uint64_t)ret_conv;
8741 }
8742
8743 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
8744         LDKCreationError e_conv = LDKCreationError_from_js(e);
8745         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8746         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
8747         return (uint64_t)ret_conv;
8748 }
8749
8750 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
8751         if ((_res & 1) != 0) return;
8752         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
8753         FREE((void*)_res);
8754         CResult_DescriptionCreationErrorZ_free(_res_conv);
8755 }
8756
8757 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
8758         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
8759         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8760         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
8761         return (uint64_t)ret_conv;
8762 }
8763
8764 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_ok(uint32_t o) {
8765         LDKExpiryTime o_conv;
8766         o_conv.inner = (void*)(o & (~1));
8767         o_conv.is_owned = (o & 1) || (o == 0);
8768         o_conv = ExpiryTime_clone(&o_conv);
8769         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8770         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
8771         return (uint64_t)ret_conv;
8772 }
8773
8774 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_err(uint32_t e) {
8775         LDKCreationError e_conv = LDKCreationError_from_js(e);
8776         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8777         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
8778         return (uint64_t)ret_conv;
8779 }
8780
8781 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
8782         if ((_res & 1) != 0) return;
8783         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
8784         FREE((void*)_res);
8785         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
8786 }
8787
8788 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone(uint32_t orig) {
8789         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
8790         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8791         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
8792         return (uint64_t)ret_conv;
8793 }
8794
8795 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
8796         LDKPrivateRoute o_conv;
8797         o_conv.inner = (void*)(o & (~1));
8798         o_conv.is_owned = (o & 1) || (o == 0);
8799         o_conv = PrivateRoute_clone(&o_conv);
8800         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8801         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
8802         return (uint64_t)ret_conv;
8803 }
8804
8805 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
8806         LDKCreationError e_conv = LDKCreationError_from_js(e);
8807         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8808         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
8809         return (uint64_t)ret_conv;
8810 }
8811
8812 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
8813         if ((_res & 1) != 0) return;
8814         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
8815         FREE((void*)_res);
8816         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
8817 }
8818
8819 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
8820         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
8821         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8822         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
8823         return (uint64_t)ret_conv;
8824 }
8825
8826 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_ok(jstring o) {
8827         LDKStr o_conv = str_ref_to_owned_c(o);
8828         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
8829         *ret_conv = CResult_StringErrorZ_ok(o_conv);
8830         return (uint64_t)ret_conv;
8831 }
8832
8833 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uint32_t e) {
8834         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8835         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
8836         *ret_conv = CResult_StringErrorZ_err(e_conv);
8837         return (uint64_t)ret_conv;
8838 }
8839
8840 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
8841         if ((_res & 1) != 0) return;
8842         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
8843         FREE((void*)_res);
8844         CResult_StringErrorZ_free(_res_conv);
8845 }
8846
8847 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
8848         LDKChannelMonitorUpdate o_conv;
8849         o_conv.inner = (void*)(o & (~1));
8850         o_conv.is_owned = (o & 1) || (o == 0);
8851         o_conv = ChannelMonitorUpdate_clone(&o_conv);
8852         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8853         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
8854         return (uint64_t)ret_conv;
8855 }
8856
8857 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
8858         LDKDecodeError e_conv;
8859         e_conv.inner = (void*)(e & (~1));
8860         e_conv.is_owned = (e & 1) || (e == 0);
8861         e_conv = DecodeError_clone(&e_conv);
8862         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8863         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
8864         return (uint64_t)ret_conv;
8865 }
8866
8867 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
8868         if ((_res & 1) != 0) return;
8869         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8870         FREE((void*)_res);
8871         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
8872 }
8873
8874 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
8875         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
8876         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8877         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
8878         return (uint64_t)ret_conv;
8879 }
8880
8881 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
8882         LDKHTLCUpdate o_conv;
8883         o_conv.inner = (void*)(o & (~1));
8884         o_conv.is_owned = (o & 1) || (o == 0);
8885         o_conv = HTLCUpdate_clone(&o_conv);
8886         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8887         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
8888         return (uint64_t)ret_conv;
8889 }
8890
8891 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
8892         LDKDecodeError e_conv;
8893         e_conv.inner = (void*)(e & (~1));
8894         e_conv.is_owned = (e & 1) || (e == 0);
8895         e_conv = DecodeError_clone(&e_conv);
8896         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8897         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
8898         return (uint64_t)ret_conv;
8899 }
8900
8901 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
8902         if ((_res & 1) != 0) return;
8903         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8904         FREE((void*)_res);
8905         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
8906 }
8907
8908 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
8909         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
8910         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8911         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
8912         return (uint64_t)ret_conv;
8913 }
8914
8915 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
8916         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8917         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
8918         return (uint64_t)ret_conv;
8919 }
8920
8921 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
8922         LDKMonitorUpdateError e_conv;
8923         e_conv.inner = (void*)(e & (~1));
8924         e_conv.is_owned = (e & 1) || (e == 0);
8925         e_conv = MonitorUpdateError_clone(&e_conv);
8926         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8927         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
8928         return (uint64_t)ret_conv;
8929 }
8930
8931 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
8932         if ((_res & 1) != 0) return;
8933         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
8934         FREE((void*)_res);
8935         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
8936 }
8937
8938 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
8939         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
8940         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8941         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
8942         return (uint64_t)ret_conv;
8943 }
8944
8945 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
8946         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
8947         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
8948         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
8949         return (uint64_t)ret_ref;
8950 }
8951
8952 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
8953         LDKOutPoint a_conv;
8954         a_conv.inner = (void*)(a & (~1));
8955         a_conv.is_owned = (a & 1) || (a == 0);
8956         a_conv = OutPoint_clone(&a_conv);
8957         LDKCVec_u8Z b_ref;
8958         b_ref.datalen = *((uint32_t*)b);
8959         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
8960         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
8961         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
8962         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
8963         return (uint64_t)ret_ref;
8964 }
8965
8966 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
8967         if ((_res & 1) != 0) return;
8968         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
8969         FREE((void*)_res);
8970         C2Tuple_OutPointScriptZ_free(_res_conv);
8971 }
8972
8973 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
8974         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
8975         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8976         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
8977         return (uint64_t)ret_ref;
8978 }
8979
8980 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
8981         LDKCVec_u8Z b_ref;
8982         b_ref.datalen = *((uint32_t*)b);
8983         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
8984         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
8985         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8986         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
8987         return (uint64_t)ret_ref;
8988 }
8989
8990 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
8991         if ((_res & 1) != 0) return;
8992         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
8993         FREE((void*)_res);
8994         C2Tuple_u32ScriptZ_free(_res_conv);
8995 }
8996
8997 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
8998         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
8999         _res_constr.datalen = *((uint32_t*)_res);
9000         if (_res_constr.datalen > 0)
9001                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
9002         else
9003                 _res_constr.data = NULL;
9004         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9005         for (size_t e = 0; e < _res_constr.datalen; e++) {
9006                 uint32_t _res_conv_30 = _res_vals[e];
9007                 LDKC2Tuple_u32ScriptZ _res_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_30) & ~1);
9008                 FREE((void*)_res_conv_30);
9009                 _res_constr.data[e] = _res_conv_30_conv;
9010         }
9011         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
9012 }
9013
9014 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
9015         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
9016         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
9017         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
9018         return (uint64_t)ret_ref;
9019 }
9020
9021 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
9022         LDKThirtyTwoBytes a_ref;
9023         CHECK(*((uint32_t*)a) == 32);
9024         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9025         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
9026         b_constr.datalen = *((uint32_t*)b);
9027         if (b_constr.datalen > 0)
9028                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
9029         else
9030                 b_constr.data = NULL;
9031         uint32_t* b_vals = (uint32_t*)(b + 4);
9032         for (size_t e = 0; e < b_constr.datalen; e++) {
9033                 uint32_t b_conv_30 = b_vals[e];
9034                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
9035                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
9036                 b_constr.data[e] = b_conv_30_conv;
9037         }
9038         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
9039         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
9040         return (uint64_t)ret_ref;
9041 }
9042
9043 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
9044         if ((_res & 1) != 0) return;
9045         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
9046         FREE((void*)_res);
9047         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
9048 }
9049
9050 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
9051         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
9052         _res_constr.datalen = *((uint32_t*)_res);
9053         if (_res_constr.datalen > 0)
9054                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
9055         else
9056                 _res_constr.data = NULL;
9057         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9058         for (size_t c = 0; c < _res_constr.datalen; c++) {
9059                 uint32_t _res_conv_54 = _res_vals[c];
9060                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_54_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_54) & ~1);
9061                 FREE((void*)_res_conv_54);
9062                 _res_constr.data[c] = _res_conv_54_conv;
9063         }
9064         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
9065 }
9066
9067 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
9068         LDKCVec_EventZ _res_constr;
9069         _res_constr.datalen = *((uint32_t*)_res);
9070         if (_res_constr.datalen > 0)
9071                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
9072         else
9073                 _res_constr.data = NULL;
9074         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9075         for (size_t h = 0; h < _res_constr.datalen; h++) {
9076                 uint32_t _res_conv_7 = _res_vals[h];
9077                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
9078                 FREE((void*)_res_conv_7);
9079                 _res_constr.data[h] = _res_conv_7_conv;
9080         }
9081         CVec_EventZ_free(_res_constr);
9082 }
9083
9084 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
9085         LDKCVec_TransactionZ _res_constr;
9086         _res_constr.datalen = *((uint32_t*)_res);
9087         if (_res_constr.datalen > 0)
9088                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
9089         else
9090                 _res_constr.data = NULL;
9091         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
9092         for (size_t m = 0; m < _res_constr.datalen; m++) {
9093                 int8_tArray _res_conv_12 = _res_vals[m];
9094                 LDKTransaction _res_conv_12_ref;
9095                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
9096                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
9097                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
9098                 _res_conv_12_ref.data_is_owned = true;
9099                 _res_constr.data[m] = _res_conv_12_ref;
9100         }
9101         CVec_TransactionZ_free(_res_constr);
9102 }
9103
9104 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
9105         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
9106         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
9107         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
9108         return (uint64_t)ret_ref;
9109 }
9110
9111 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
9112         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
9113         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
9114         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
9115         return (uint64_t)ret_ref;
9116 }
9117
9118 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
9119         if ((_res & 1) != 0) return;
9120         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
9121         FREE((void*)_res);
9122         C2Tuple_u32TxOutZ_free(_res_conv);
9123 }
9124
9125 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
9126         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
9127         _res_constr.datalen = *((uint32_t*)_res);
9128         if (_res_constr.datalen > 0)
9129                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
9130         else
9131                 _res_constr.data = NULL;
9132         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9133         for (size_t z = 0; z < _res_constr.datalen; z++) {
9134                 uint32_t _res_conv_25 = _res_vals[z];
9135                 LDKC2Tuple_u32TxOutZ _res_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_25) & ~1);
9136                 FREE((void*)_res_conv_25);
9137                 _res_constr.data[z] = _res_conv_25_conv;
9138         }
9139         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
9140 }
9141
9142 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
9143         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
9144         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
9145         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
9146         return (uint64_t)ret_ref;
9147 }
9148
9149 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
9150         LDKThirtyTwoBytes a_ref;
9151         CHECK(*((uint32_t*)a) == 32);
9152         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9153         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
9154         b_constr.datalen = *((uint32_t*)b);
9155         if (b_constr.datalen > 0)
9156                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
9157         else
9158                 b_constr.data = NULL;
9159         uint32_t* b_vals = (uint32_t*)(b + 4);
9160         for (size_t z = 0; z < b_constr.datalen; z++) {
9161                 uint32_t b_conv_25 = b_vals[z];
9162                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
9163                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
9164                 b_constr.data[z] = b_conv_25_conv;
9165         }
9166         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
9167         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
9168         return (uint64_t)ret_ref;
9169 }
9170
9171 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
9172         if ((_res & 1) != 0) return;
9173         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
9174         FREE((void*)_res);
9175         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
9176 }
9177
9178 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
9179         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
9180         _res_constr.datalen = *((uint32_t*)_res);
9181         if (_res_constr.datalen > 0)
9182                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
9183         else
9184                 _res_constr.data = NULL;
9185         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9186         for (size_t x = 0; x < _res_constr.datalen; x++) {
9187                 uint32_t _res_conv_49 = _res_vals[x];
9188                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_49) & ~1);
9189                 FREE((void*)_res_conv_49);
9190                 _res_constr.data[x] = _res_conv_49_conv;
9191         }
9192         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
9193 }
9194
9195 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
9196         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
9197         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
9198         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
9199         return (uint64_t)ret_conv;
9200 }
9201
9202 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
9203         LDKDecodeError e_conv;
9204         e_conv.inner = (void*)(e & (~1));
9205         e_conv.is_owned = (e & 1) || (e == 0);
9206         e_conv = DecodeError_clone(&e_conv);
9207         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
9208         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
9209         return (uint64_t)ret_conv;
9210 }
9211
9212 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
9213         if ((_res & 1) != 0) return;
9214         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9215         FREE((void*)_res);
9216         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
9217 }
9218
9219 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
9220         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9221         *ret_conv = CResult_boolLightningErrorZ_ok(o);
9222         return (uint64_t)ret_conv;
9223 }
9224
9225 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
9226         LDKLightningError e_conv;
9227         e_conv.inner = (void*)(e & (~1));
9228         e_conv.is_owned = (e & 1) || (e == 0);
9229         e_conv = LightningError_clone(&e_conv);
9230         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9231         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
9232         return (uint64_t)ret_conv;
9233 }
9234
9235 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
9236         if ((_res & 1) != 0) return;
9237         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
9238         FREE((void*)_res);
9239         CResult_boolLightningErrorZ_free(_res_conv);
9240 }
9241
9242 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
9243         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
9244         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9245         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
9246         return (uint64_t)ret_conv;
9247 }
9248
9249 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
9250         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
9251         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9252         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
9253         return (uint64_t)ret_ref;
9254 }
9255
9256 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
9257         LDKChannelAnnouncement a_conv;
9258         a_conv.inner = (void*)(a & (~1));
9259         a_conv.is_owned = (a & 1) || (a == 0);
9260         a_conv = ChannelAnnouncement_clone(&a_conv);
9261         LDKChannelUpdate b_conv;
9262         b_conv.inner = (void*)(b & (~1));
9263         b_conv.is_owned = (b & 1) || (b == 0);
9264         b_conv = ChannelUpdate_clone(&b_conv);
9265         LDKChannelUpdate c_conv;
9266         c_conv.inner = (void*)(c & (~1));
9267         c_conv.is_owned = (c & 1) || (c == 0);
9268         c_conv = ChannelUpdate_clone(&c_conv);
9269         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9270         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
9271         return (uint64_t)ret_ref;
9272 }
9273
9274 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
9275         if ((_res & 1) != 0) return;
9276         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
9277         FREE((void*)_res);
9278         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
9279 }
9280
9281 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
9282         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
9283         _res_constr.datalen = *((uint32_t*)_res);
9284         if (_res_constr.datalen > 0)
9285                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9286         else
9287                 _res_constr.data = NULL;
9288         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9289         for (size_t l = 0; l < _res_constr.datalen; l++) {
9290                 uint32_t _res_conv_63 = _res_vals[l];
9291                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
9292                 FREE((void*)_res_conv_63);
9293                 _res_constr.data[l] = _res_conv_63_conv;
9294         }
9295         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
9296 }
9297
9298 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
9299         LDKCVec_NodeAnnouncementZ _res_constr;
9300         _res_constr.datalen = *((uint32_t*)_res);
9301         if (_res_constr.datalen > 0)
9302                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9303         else
9304                 _res_constr.data = NULL;
9305         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9306         for (size_t s = 0; s < _res_constr.datalen; s++) {
9307                 uint32_t _res_conv_18 = _res_vals[s];
9308                 LDKNodeAnnouncement _res_conv_18_conv;
9309                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
9310                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
9311                 _res_constr.data[s] = _res_conv_18_conv;
9312         }
9313         CVec_NodeAnnouncementZ_free(_res_constr);
9314 }
9315
9316 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
9317         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9318         *ret_conv = CResult_NoneLightningErrorZ_ok();
9319         return (uint64_t)ret_conv;
9320 }
9321
9322 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
9323         LDKLightningError e_conv;
9324         e_conv.inner = (void*)(e & (~1));
9325         e_conv.is_owned = (e & 1) || (e == 0);
9326         e_conv = LightningError_clone(&e_conv);
9327         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9328         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
9329         return (uint64_t)ret_conv;
9330 }
9331
9332 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
9333         if ((_res & 1) != 0) return;
9334         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
9335         FREE((void*)_res);
9336         CResult_NoneLightningErrorZ_free(_res_conv);
9337 }
9338
9339 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
9340         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
9341         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9342         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
9343         return (uint64_t)ret_conv;
9344 }
9345
9346 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
9347         LDKCVec_PublicKeyZ _res_constr;
9348         _res_constr.datalen = *((uint32_t*)_res);
9349         if (_res_constr.datalen > 0)
9350                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
9351         else
9352                 _res_constr.data = NULL;
9353         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
9354         for (size_t m = 0; m < _res_constr.datalen; m++) {
9355                 int8_tArray _res_conv_12 = _res_vals[m];
9356                 LDKPublicKey _res_conv_12_ref;
9357                 CHECK(*((uint32_t*)_res_conv_12) == 33);
9358                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
9359                 _res_constr.data[m] = _res_conv_12_ref;
9360         }
9361         CVec_PublicKeyZ_free(_res_constr);
9362 }
9363
9364 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
9365         LDKCVec_u8Z o_ref;
9366         o_ref.datalen = *((uint32_t*)o);
9367         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
9368         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
9369         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9370         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
9371         return (uint64_t)ret_conv;
9372 }
9373
9374 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
9375         LDKPeerHandleError e_conv;
9376         e_conv.inner = (void*)(e & (~1));
9377         e_conv.is_owned = (e & 1) || (e == 0);
9378         e_conv = PeerHandleError_clone(&e_conv);
9379         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9380         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
9381         return (uint64_t)ret_conv;
9382 }
9383
9384 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
9385         if ((_res & 1) != 0) return;
9386         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9387         FREE((void*)_res);
9388         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
9389 }
9390
9391 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
9392         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
9393         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9394         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
9395         return (uint64_t)ret_conv;
9396 }
9397
9398 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
9399         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9400         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
9401         return (uint64_t)ret_conv;
9402 }
9403
9404 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
9405         LDKPeerHandleError e_conv;
9406         e_conv.inner = (void*)(e & (~1));
9407         e_conv.is_owned = (e & 1) || (e == 0);
9408         e_conv = PeerHandleError_clone(&e_conv);
9409         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9410         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
9411         return (uint64_t)ret_conv;
9412 }
9413
9414 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
9415         if ((_res & 1) != 0) return;
9416         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9417         FREE((void*)_res);
9418         CResult_NonePeerHandleErrorZ_free(_res_conv);
9419 }
9420
9421 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
9422         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
9423         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9424         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
9425         return (uint64_t)ret_conv;
9426 }
9427
9428 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
9429         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9430         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
9431         return (uint64_t)ret_conv;
9432 }
9433
9434 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
9435         LDKPeerHandleError e_conv;
9436         e_conv.inner = (void*)(e & (~1));
9437         e_conv.is_owned = (e & 1) || (e == 0);
9438         e_conv = PeerHandleError_clone(&e_conv);
9439         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9440         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
9441         return (uint64_t)ret_conv;
9442 }
9443
9444 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
9445         if ((_res & 1) != 0) return;
9446         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9447         FREE((void*)_res);
9448         CResult_boolPeerHandleErrorZ_free(_res_conv);
9449 }
9450
9451 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
9452         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
9453         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9454         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
9455         return (uint64_t)ret_conv;
9456 }
9457
9458 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
9459         LDKDirectionalChannelInfo o_conv;
9460         o_conv.inner = (void*)(o & (~1));
9461         o_conv.is_owned = (o & 1) || (o == 0);
9462         o_conv = DirectionalChannelInfo_clone(&o_conv);
9463         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9464         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
9465         return (uint64_t)ret_conv;
9466 }
9467
9468 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
9469         LDKDecodeError e_conv;
9470         e_conv.inner = (void*)(e & (~1));
9471         e_conv.is_owned = (e & 1) || (e == 0);
9472         e_conv = DecodeError_clone(&e_conv);
9473         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9474         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
9475         return (uint64_t)ret_conv;
9476 }
9477
9478 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
9479         if ((_res & 1) != 0) return;
9480         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9481         FREE((void*)_res);
9482         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
9483 }
9484
9485 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
9486         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
9487         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9488         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
9489         return (uint64_t)ret_conv;
9490 }
9491
9492 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
9493         LDKChannelInfo o_conv;
9494         o_conv.inner = (void*)(o & (~1));
9495         o_conv.is_owned = (o & 1) || (o == 0);
9496         o_conv = ChannelInfo_clone(&o_conv);
9497         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9498         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
9499         return (uint64_t)ret_conv;
9500 }
9501
9502 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
9503         LDKDecodeError e_conv;
9504         e_conv.inner = (void*)(e & (~1));
9505         e_conv.is_owned = (e & 1) || (e == 0);
9506         e_conv = DecodeError_clone(&e_conv);
9507         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9508         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
9509         return (uint64_t)ret_conv;
9510 }
9511
9512 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
9513         if ((_res & 1) != 0) return;
9514         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9515         FREE((void*)_res);
9516         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
9517 }
9518
9519 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
9520         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
9521         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9522         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
9523         return (uint64_t)ret_conv;
9524 }
9525
9526 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
9527         LDKRoutingFees o_conv;
9528         o_conv.inner = (void*)(o & (~1));
9529         o_conv.is_owned = (o & 1) || (o == 0);
9530         o_conv = RoutingFees_clone(&o_conv);
9531         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9532         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
9533         return (uint64_t)ret_conv;
9534 }
9535
9536 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
9537         LDKDecodeError e_conv;
9538         e_conv.inner = (void*)(e & (~1));
9539         e_conv.is_owned = (e & 1) || (e == 0);
9540         e_conv = DecodeError_clone(&e_conv);
9541         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9542         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
9543         return (uint64_t)ret_conv;
9544 }
9545
9546 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
9547         if ((_res & 1) != 0) return;
9548         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9549         FREE((void*)_res);
9550         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
9551 }
9552
9553 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
9554         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
9555         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9556         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
9557         return (uint64_t)ret_conv;
9558 }
9559
9560 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
9561         LDKNodeAnnouncementInfo o_conv;
9562         o_conv.inner = (void*)(o & (~1));
9563         o_conv.is_owned = (o & 1) || (o == 0);
9564         o_conv = NodeAnnouncementInfo_clone(&o_conv);
9565         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9566         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
9567         return (uint64_t)ret_conv;
9568 }
9569
9570 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
9571         LDKDecodeError e_conv;
9572         e_conv.inner = (void*)(e & (~1));
9573         e_conv.is_owned = (e & 1) || (e == 0);
9574         e_conv = DecodeError_clone(&e_conv);
9575         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9576         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
9577         return (uint64_t)ret_conv;
9578 }
9579
9580 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
9581         if ((_res & 1) != 0) return;
9582         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9583         FREE((void*)_res);
9584         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
9585 }
9586
9587 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
9588         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
9589         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9590         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
9591         return (uint64_t)ret_conv;
9592 }
9593
9594 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
9595         LDKCVec_u64Z _res_constr;
9596         _res_constr.datalen = *((uint32_t*)_res);
9597         if (_res_constr.datalen > 0)
9598                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
9599         else
9600                 _res_constr.data = NULL;
9601         int64_t* _res_vals = (int64_t*)(_res + 4);
9602         for (size_t i = 0; i < _res_constr.datalen; i++) {
9603                 int64_t _res_conv_8 = _res_vals[i];
9604                 _res_constr.data[i] = _res_conv_8;
9605         }
9606         CVec_u64Z_free(_res_constr);
9607 }
9608
9609 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
9610         LDKNodeInfo o_conv;
9611         o_conv.inner = (void*)(o & (~1));
9612         o_conv.is_owned = (o & 1) || (o == 0);
9613         o_conv = NodeInfo_clone(&o_conv);
9614         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9615         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
9616         return (uint64_t)ret_conv;
9617 }
9618
9619 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
9620         LDKDecodeError e_conv;
9621         e_conv.inner = (void*)(e & (~1));
9622         e_conv.is_owned = (e & 1) || (e == 0);
9623         e_conv = DecodeError_clone(&e_conv);
9624         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9625         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
9626         return (uint64_t)ret_conv;
9627 }
9628
9629 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
9630         if ((_res & 1) != 0) return;
9631         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9632         FREE((void*)_res);
9633         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
9634 }
9635
9636 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
9637         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
9638         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9639         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
9640         return (uint64_t)ret_conv;
9641 }
9642
9643 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
9644         LDKNetworkGraph o_conv;
9645         o_conv.inner = (void*)(o & (~1));
9646         o_conv.is_owned = (o & 1) || (o == 0);
9647         o_conv = NetworkGraph_clone(&o_conv);
9648         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9649         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
9650         return (uint64_t)ret_conv;
9651 }
9652
9653 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
9654         LDKDecodeError e_conv;
9655         e_conv.inner = (void*)(e & (~1));
9656         e_conv.is_owned = (e & 1) || (e == 0);
9657         e_conv = DecodeError_clone(&e_conv);
9658         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9659         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
9660         return (uint64_t)ret_conv;
9661 }
9662
9663 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
9664         if ((_res & 1) != 0) return;
9665         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
9666         FREE((void*)_res);
9667         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
9668 }
9669
9670 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
9671         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
9672         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9673         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
9674         return (uint64_t)ret_conv;
9675 }
9676
9677 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
9678         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
9679         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9680         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
9681         return (uint64_t)ret_conv;
9682 }
9683
9684 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
9685         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9686         *ret_conv = CResult_NetAddressu8Z_err(e);
9687         return (uint64_t)ret_conv;
9688 }
9689
9690 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
9691         if ((_res & 1) != 0) return;
9692         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
9693         FREE((void*)_res);
9694         CResult_NetAddressu8Z_free(_res_conv);
9695 }
9696
9697 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
9698         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
9699         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9700         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
9701         return (uint64_t)ret_conv;
9702 }
9703
9704 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
9705         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
9706         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9707         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
9708         return (uint64_t)ret_conv;
9709 }
9710
9711 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
9712         LDKDecodeError e_conv;
9713         e_conv.inner = (void*)(e & (~1));
9714         e_conv.is_owned = (e & 1) || (e == 0);
9715         e_conv = DecodeError_clone(&e_conv);
9716         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9717         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
9718         return (uint64_t)ret_conv;
9719 }
9720
9721 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
9722         if ((_res & 1) != 0) return;
9723         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9724         FREE((void*)_res);
9725         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
9726 }
9727
9728 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
9729         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
9730         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9731         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
9732         return (uint64_t)ret_conv;
9733 }
9734
9735 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
9736         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
9737         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9738         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
9739         return (uint64_t)ret_conv;
9740 }
9741
9742 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
9743         LDKDecodeError e_conv;
9744         e_conv.inner = (void*)(e & (~1));
9745         e_conv.is_owned = (e & 1) || (e == 0);
9746         e_conv = DecodeError_clone(&e_conv);
9747         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9748         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
9749         return (uint64_t)ret_conv;
9750 }
9751
9752 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
9753         if ((_res & 1) != 0) return;
9754         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
9755         FREE((void*)_res);
9756         CResult_NetAddressDecodeErrorZ_free(_res_conv);
9757 }
9758
9759 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
9760         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
9761         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9762         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
9763         return (uint64_t)ret_conv;
9764 }
9765
9766 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
9767         LDKCVec_UpdateAddHTLCZ _res_constr;
9768         _res_constr.datalen = *((uint32_t*)_res);
9769         if (_res_constr.datalen > 0)
9770                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
9771         else
9772                 _res_constr.data = NULL;
9773         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9774         for (size_t p = 0; p < _res_constr.datalen; p++) {
9775                 uint32_t _res_conv_15 = _res_vals[p];
9776                 LDKUpdateAddHTLC _res_conv_15_conv;
9777                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
9778                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
9779                 _res_constr.data[p] = _res_conv_15_conv;
9780         }
9781         CVec_UpdateAddHTLCZ_free(_res_constr);
9782 }
9783
9784 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
9785         LDKCVec_UpdateFulfillHTLCZ _res_constr;
9786         _res_constr.datalen = *((uint32_t*)_res);
9787         if (_res_constr.datalen > 0)
9788                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
9789         else
9790                 _res_constr.data = NULL;
9791         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9792         for (size_t t = 0; t < _res_constr.datalen; t++) {
9793                 uint32_t _res_conv_19 = _res_vals[t];
9794                 LDKUpdateFulfillHTLC _res_conv_19_conv;
9795                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
9796                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
9797                 _res_constr.data[t] = _res_conv_19_conv;
9798         }
9799         CVec_UpdateFulfillHTLCZ_free(_res_constr);
9800 }
9801
9802 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
9803         LDKCVec_UpdateFailHTLCZ _res_constr;
9804         _res_constr.datalen = *((uint32_t*)_res);
9805         if (_res_constr.datalen > 0)
9806                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
9807         else
9808                 _res_constr.data = NULL;
9809         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9810         for (size_t q = 0; q < _res_constr.datalen; q++) {
9811                 uint32_t _res_conv_16 = _res_vals[q];
9812                 LDKUpdateFailHTLC _res_conv_16_conv;
9813                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9814                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9815                 _res_constr.data[q] = _res_conv_16_conv;
9816         }
9817         CVec_UpdateFailHTLCZ_free(_res_constr);
9818 }
9819
9820 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
9821         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
9822         _res_constr.datalen = *((uint32_t*)_res);
9823         if (_res_constr.datalen > 0)
9824                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
9825         else
9826                 _res_constr.data = NULL;
9827         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9828         for (size_t z = 0; z < _res_constr.datalen; z++) {
9829                 uint32_t _res_conv_25 = _res_vals[z];
9830                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
9831                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
9832                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
9833                 _res_constr.data[z] = _res_conv_25_conv;
9834         }
9835         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
9836 }
9837
9838 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
9839         LDKAcceptChannel o_conv;
9840         o_conv.inner = (void*)(o & (~1));
9841         o_conv.is_owned = (o & 1) || (o == 0);
9842         o_conv = AcceptChannel_clone(&o_conv);
9843         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9844         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
9845         return (uint64_t)ret_conv;
9846 }
9847
9848 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
9849         LDKDecodeError e_conv;
9850         e_conv.inner = (void*)(e & (~1));
9851         e_conv.is_owned = (e & 1) || (e == 0);
9852         e_conv = DecodeError_clone(&e_conv);
9853         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9854         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
9855         return (uint64_t)ret_conv;
9856 }
9857
9858 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
9859         if ((_res & 1) != 0) return;
9860         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9861         FREE((void*)_res);
9862         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
9863 }
9864
9865 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
9866         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
9867         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9868         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
9869         return (uint64_t)ret_conv;
9870 }
9871
9872 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
9873         LDKAnnouncementSignatures o_conv;
9874         o_conv.inner = (void*)(o & (~1));
9875         o_conv.is_owned = (o & 1) || (o == 0);
9876         o_conv = AnnouncementSignatures_clone(&o_conv);
9877         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9878         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
9879         return (uint64_t)ret_conv;
9880 }
9881
9882 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
9883         LDKDecodeError e_conv;
9884         e_conv.inner = (void*)(e & (~1));
9885         e_conv.is_owned = (e & 1) || (e == 0);
9886         e_conv = DecodeError_clone(&e_conv);
9887         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9888         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
9889         return (uint64_t)ret_conv;
9890 }
9891
9892 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
9893         if ((_res & 1) != 0) return;
9894         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9895         FREE((void*)_res);
9896         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
9897 }
9898
9899 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
9900         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
9901         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9902         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
9903         return (uint64_t)ret_conv;
9904 }
9905
9906 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
9907         LDKChannelReestablish o_conv;
9908         o_conv.inner = (void*)(o & (~1));
9909         o_conv.is_owned = (o & 1) || (o == 0);
9910         o_conv = ChannelReestablish_clone(&o_conv);
9911         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9912         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
9913         return (uint64_t)ret_conv;
9914 }
9915
9916 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
9917         LDKDecodeError e_conv;
9918         e_conv.inner = (void*)(e & (~1));
9919         e_conv.is_owned = (e & 1) || (e == 0);
9920         e_conv = DecodeError_clone(&e_conv);
9921         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9922         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
9923         return (uint64_t)ret_conv;
9924 }
9925
9926 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
9927         if ((_res & 1) != 0) return;
9928         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
9929         FREE((void*)_res);
9930         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
9931 }
9932
9933 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
9934         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
9935         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9936         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
9937         return (uint64_t)ret_conv;
9938 }
9939
9940 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
9941         LDKClosingSigned o_conv;
9942         o_conv.inner = (void*)(o & (~1));
9943         o_conv.is_owned = (o & 1) || (o == 0);
9944         o_conv = ClosingSigned_clone(&o_conv);
9945         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9946         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
9947         return (uint64_t)ret_conv;
9948 }
9949
9950 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
9951         LDKDecodeError e_conv;
9952         e_conv.inner = (void*)(e & (~1));
9953         e_conv.is_owned = (e & 1) || (e == 0);
9954         e_conv = DecodeError_clone(&e_conv);
9955         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9956         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
9957         return (uint64_t)ret_conv;
9958 }
9959
9960 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
9961         if ((_res & 1) != 0) return;
9962         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9963         FREE((void*)_res);
9964         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
9965 }
9966
9967 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
9968         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
9969         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9970         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
9971         return (uint64_t)ret_conv;
9972 }
9973
9974 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
9975         LDKClosingSignedFeeRange o_conv;
9976         o_conv.inner = (void*)(o & (~1));
9977         o_conv.is_owned = (o & 1) || (o == 0);
9978         o_conv = ClosingSignedFeeRange_clone(&o_conv);
9979         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
9980         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
9981         return (uint64_t)ret_conv;
9982 }
9983
9984 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
9985         LDKDecodeError e_conv;
9986         e_conv.inner = (void*)(e & (~1));
9987         e_conv.is_owned = (e & 1) || (e == 0);
9988         e_conv = DecodeError_clone(&e_conv);
9989         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
9990         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
9991         return (uint64_t)ret_conv;
9992 }
9993
9994 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
9995         if ((_res & 1) != 0) return;
9996         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
9997         FREE((void*)_res);
9998         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
9999 }
10000
10001 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
10002         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
10003         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
10004         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
10005         return (uint64_t)ret_conv;
10006 }
10007
10008 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
10009         LDKCommitmentSigned o_conv;
10010         o_conv.inner = (void*)(o & (~1));
10011         o_conv.is_owned = (o & 1) || (o == 0);
10012         o_conv = CommitmentSigned_clone(&o_conv);
10013         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
10014         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
10015         return (uint64_t)ret_conv;
10016 }
10017
10018 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
10019         LDKDecodeError e_conv;
10020         e_conv.inner = (void*)(e & (~1));
10021         e_conv.is_owned = (e & 1) || (e == 0);
10022         e_conv = DecodeError_clone(&e_conv);
10023         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
10024         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
10025         return (uint64_t)ret_conv;
10026 }
10027
10028 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
10029         if ((_res & 1) != 0) return;
10030         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
10031         FREE((void*)_res);
10032         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
10033 }
10034
10035 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
10036         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
10037         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
10038         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
10039         return (uint64_t)ret_conv;
10040 }
10041
10042 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
10043         LDKFundingCreated o_conv;
10044         o_conv.inner = (void*)(o & (~1));
10045         o_conv.is_owned = (o & 1) || (o == 0);
10046         o_conv = FundingCreated_clone(&o_conv);
10047         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
10048         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
10049         return (uint64_t)ret_conv;
10050 }
10051
10052 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
10053         LDKDecodeError e_conv;
10054         e_conv.inner = (void*)(e & (~1));
10055         e_conv.is_owned = (e & 1) || (e == 0);
10056         e_conv = DecodeError_clone(&e_conv);
10057         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
10058         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
10059         return (uint64_t)ret_conv;
10060 }
10061
10062 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
10063         if ((_res & 1) != 0) return;
10064         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
10065         FREE((void*)_res);
10066         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
10067 }
10068
10069 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
10070         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
10071         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
10072         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
10073         return (uint64_t)ret_conv;
10074 }
10075
10076 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
10077         LDKFundingSigned o_conv;
10078         o_conv.inner = (void*)(o & (~1));
10079         o_conv.is_owned = (o & 1) || (o == 0);
10080         o_conv = FundingSigned_clone(&o_conv);
10081         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
10082         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
10083         return (uint64_t)ret_conv;
10084 }
10085
10086 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
10087         LDKDecodeError e_conv;
10088         e_conv.inner = (void*)(e & (~1));
10089         e_conv.is_owned = (e & 1) || (e == 0);
10090         e_conv = DecodeError_clone(&e_conv);
10091         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
10092         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
10093         return (uint64_t)ret_conv;
10094 }
10095
10096 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
10097         if ((_res & 1) != 0) return;
10098         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
10099         FREE((void*)_res);
10100         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
10101 }
10102
10103 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
10104         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
10105         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
10106         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
10107         return (uint64_t)ret_conv;
10108 }
10109
10110 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
10111         LDKFundingLocked o_conv;
10112         o_conv.inner = (void*)(o & (~1));
10113         o_conv.is_owned = (o & 1) || (o == 0);
10114         o_conv = FundingLocked_clone(&o_conv);
10115         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
10116         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
10117         return (uint64_t)ret_conv;
10118 }
10119
10120 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
10121         LDKDecodeError e_conv;
10122         e_conv.inner = (void*)(e & (~1));
10123         e_conv.is_owned = (e & 1) || (e == 0);
10124         e_conv = DecodeError_clone(&e_conv);
10125         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
10126         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
10127         return (uint64_t)ret_conv;
10128 }
10129
10130 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
10131         if ((_res & 1) != 0) return;
10132         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
10133         FREE((void*)_res);
10134         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
10135 }
10136
10137 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
10138         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
10139         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
10140         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
10141         return (uint64_t)ret_conv;
10142 }
10143
10144 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
10145         LDKInit o_conv;
10146         o_conv.inner = (void*)(o & (~1));
10147         o_conv.is_owned = (o & 1) || (o == 0);
10148         o_conv = Init_clone(&o_conv);
10149         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
10150         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
10151         return (uint64_t)ret_conv;
10152 }
10153
10154 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
10155         LDKDecodeError e_conv;
10156         e_conv.inner = (void*)(e & (~1));
10157         e_conv.is_owned = (e & 1) || (e == 0);
10158         e_conv = DecodeError_clone(&e_conv);
10159         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
10160         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
10161         return (uint64_t)ret_conv;
10162 }
10163
10164 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
10165         if ((_res & 1) != 0) return;
10166         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
10167         FREE((void*)_res);
10168         CResult_InitDecodeErrorZ_free(_res_conv);
10169 }
10170
10171 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
10172         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
10173         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
10174         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
10175         return (uint64_t)ret_conv;
10176 }
10177
10178 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
10179         LDKOpenChannel o_conv;
10180         o_conv.inner = (void*)(o & (~1));
10181         o_conv.is_owned = (o & 1) || (o == 0);
10182         o_conv = OpenChannel_clone(&o_conv);
10183         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
10184         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
10185         return (uint64_t)ret_conv;
10186 }
10187
10188 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
10189         LDKDecodeError e_conv;
10190         e_conv.inner = (void*)(e & (~1));
10191         e_conv.is_owned = (e & 1) || (e == 0);
10192         e_conv = DecodeError_clone(&e_conv);
10193         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
10194         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
10195         return (uint64_t)ret_conv;
10196 }
10197
10198 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
10199         if ((_res & 1) != 0) return;
10200         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
10201         FREE((void*)_res);
10202         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
10203 }
10204
10205 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
10206         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
10207         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
10208         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
10209         return (uint64_t)ret_conv;
10210 }
10211
10212 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
10213         LDKRevokeAndACK o_conv;
10214         o_conv.inner = (void*)(o & (~1));
10215         o_conv.is_owned = (o & 1) || (o == 0);
10216         o_conv = RevokeAndACK_clone(&o_conv);
10217         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
10218         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
10219         return (uint64_t)ret_conv;
10220 }
10221
10222 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
10223         LDKDecodeError e_conv;
10224         e_conv.inner = (void*)(e & (~1));
10225         e_conv.is_owned = (e & 1) || (e == 0);
10226         e_conv = DecodeError_clone(&e_conv);
10227         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
10228         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
10229         return (uint64_t)ret_conv;
10230 }
10231
10232 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
10233         if ((_res & 1) != 0) return;
10234         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
10235         FREE((void*)_res);
10236         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
10237 }
10238
10239 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
10240         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
10241         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
10242         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
10243         return (uint64_t)ret_conv;
10244 }
10245
10246 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
10247         LDKShutdown o_conv;
10248         o_conv.inner = (void*)(o & (~1));
10249         o_conv.is_owned = (o & 1) || (o == 0);
10250         o_conv = Shutdown_clone(&o_conv);
10251         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
10252         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
10253         return (uint64_t)ret_conv;
10254 }
10255
10256 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
10257         LDKDecodeError e_conv;
10258         e_conv.inner = (void*)(e & (~1));
10259         e_conv.is_owned = (e & 1) || (e == 0);
10260         e_conv = DecodeError_clone(&e_conv);
10261         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
10262         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
10263         return (uint64_t)ret_conv;
10264 }
10265
10266 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
10267         if ((_res & 1) != 0) return;
10268         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
10269         FREE((void*)_res);
10270         CResult_ShutdownDecodeErrorZ_free(_res_conv);
10271 }
10272
10273 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
10274         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
10275         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
10276         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
10277         return (uint64_t)ret_conv;
10278 }
10279
10280 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
10281         LDKUpdateFailHTLC o_conv;
10282         o_conv.inner = (void*)(o & (~1));
10283         o_conv.is_owned = (o & 1) || (o == 0);
10284         o_conv = UpdateFailHTLC_clone(&o_conv);
10285         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
10286         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
10287         return (uint64_t)ret_conv;
10288 }
10289
10290 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
10291         LDKDecodeError e_conv;
10292         e_conv.inner = (void*)(e & (~1));
10293         e_conv.is_owned = (e & 1) || (e == 0);
10294         e_conv = DecodeError_clone(&e_conv);
10295         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
10296         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
10297         return (uint64_t)ret_conv;
10298 }
10299
10300 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
10301         if ((_res & 1) != 0) return;
10302         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10303         FREE((void*)_res);
10304         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
10305 }
10306
10307 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
10308         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
10309         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
10310         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
10311         return (uint64_t)ret_conv;
10312 }
10313
10314 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
10315         LDKUpdateFailMalformedHTLC o_conv;
10316         o_conv.inner = (void*)(o & (~1));
10317         o_conv.is_owned = (o & 1) || (o == 0);
10318         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
10319         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10320         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
10321         return (uint64_t)ret_conv;
10322 }
10323
10324 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
10325         LDKDecodeError e_conv;
10326         e_conv.inner = (void*)(e & (~1));
10327         e_conv.is_owned = (e & 1) || (e == 0);
10328         e_conv = DecodeError_clone(&e_conv);
10329         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10330         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
10331         return (uint64_t)ret_conv;
10332 }
10333
10334 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
10335         if ((_res & 1) != 0) return;
10336         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10337         FREE((void*)_res);
10338         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
10339 }
10340
10341 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
10342         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
10343         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10344         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
10345         return (uint64_t)ret_conv;
10346 }
10347
10348 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
10349         LDKUpdateFee o_conv;
10350         o_conv.inner = (void*)(o & (~1));
10351         o_conv.is_owned = (o & 1) || (o == 0);
10352         o_conv = UpdateFee_clone(&o_conv);
10353         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10354         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
10355         return (uint64_t)ret_conv;
10356 }
10357
10358 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
10359         LDKDecodeError e_conv;
10360         e_conv.inner = (void*)(e & (~1));
10361         e_conv.is_owned = (e & 1) || (e == 0);
10362         e_conv = DecodeError_clone(&e_conv);
10363         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10364         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
10365         return (uint64_t)ret_conv;
10366 }
10367
10368 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
10369         if ((_res & 1) != 0) return;
10370         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10371         FREE((void*)_res);
10372         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
10373 }
10374
10375 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
10376         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
10377         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10378         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
10379         return (uint64_t)ret_conv;
10380 }
10381
10382 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
10383         LDKUpdateFulfillHTLC o_conv;
10384         o_conv.inner = (void*)(o & (~1));
10385         o_conv.is_owned = (o & 1) || (o == 0);
10386         o_conv = UpdateFulfillHTLC_clone(&o_conv);
10387         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10388         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
10389         return (uint64_t)ret_conv;
10390 }
10391
10392 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
10393         LDKDecodeError e_conv;
10394         e_conv.inner = (void*)(e & (~1));
10395         e_conv.is_owned = (e & 1) || (e == 0);
10396         e_conv = DecodeError_clone(&e_conv);
10397         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10398         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
10399         return (uint64_t)ret_conv;
10400 }
10401
10402 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
10403         if ((_res & 1) != 0) return;
10404         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10405         FREE((void*)_res);
10406         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
10407 }
10408
10409 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
10410         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
10411         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10412         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
10413         return (uint64_t)ret_conv;
10414 }
10415
10416 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
10417         LDKUpdateAddHTLC o_conv;
10418         o_conv.inner = (void*)(o & (~1));
10419         o_conv.is_owned = (o & 1) || (o == 0);
10420         o_conv = UpdateAddHTLC_clone(&o_conv);
10421         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10422         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
10423         return (uint64_t)ret_conv;
10424 }
10425
10426 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
10427         LDKDecodeError e_conv;
10428         e_conv.inner = (void*)(e & (~1));
10429         e_conv.is_owned = (e & 1) || (e == 0);
10430         e_conv = DecodeError_clone(&e_conv);
10431         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10432         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
10433         return (uint64_t)ret_conv;
10434 }
10435
10436 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
10437         if ((_res & 1) != 0) return;
10438         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10439         FREE((void*)_res);
10440         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
10441 }
10442
10443 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
10444         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
10445         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10446         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
10447         return (uint64_t)ret_conv;
10448 }
10449
10450 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
10451         LDKPing o_conv;
10452         o_conv.inner = (void*)(o & (~1));
10453         o_conv.is_owned = (o & 1) || (o == 0);
10454         o_conv = Ping_clone(&o_conv);
10455         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10456         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
10457         return (uint64_t)ret_conv;
10458 }
10459
10460 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
10461         LDKDecodeError e_conv;
10462         e_conv.inner = (void*)(e & (~1));
10463         e_conv.is_owned = (e & 1) || (e == 0);
10464         e_conv = DecodeError_clone(&e_conv);
10465         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10466         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
10467         return (uint64_t)ret_conv;
10468 }
10469
10470 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
10471         if ((_res & 1) != 0) return;
10472         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
10473         FREE((void*)_res);
10474         CResult_PingDecodeErrorZ_free(_res_conv);
10475 }
10476
10477 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
10478         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
10479         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10480         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
10481         return (uint64_t)ret_conv;
10482 }
10483
10484 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
10485         LDKPong o_conv;
10486         o_conv.inner = (void*)(o & (~1));
10487         o_conv.is_owned = (o & 1) || (o == 0);
10488         o_conv = Pong_clone(&o_conv);
10489         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10490         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
10491         return (uint64_t)ret_conv;
10492 }
10493
10494 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
10495         LDKDecodeError e_conv;
10496         e_conv.inner = (void*)(e & (~1));
10497         e_conv.is_owned = (e & 1) || (e == 0);
10498         e_conv = DecodeError_clone(&e_conv);
10499         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10500         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
10501         return (uint64_t)ret_conv;
10502 }
10503
10504 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
10505         if ((_res & 1) != 0) return;
10506         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
10507         FREE((void*)_res);
10508         CResult_PongDecodeErrorZ_free(_res_conv);
10509 }
10510
10511 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
10512         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
10513         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10514         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
10515         return (uint64_t)ret_conv;
10516 }
10517
10518 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
10519         LDKUnsignedChannelAnnouncement o_conv;
10520         o_conv.inner = (void*)(o & (~1));
10521         o_conv.is_owned = (o & 1) || (o == 0);
10522         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
10523         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10524         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
10525         return (uint64_t)ret_conv;
10526 }
10527
10528 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
10529         LDKDecodeError e_conv;
10530         e_conv.inner = (void*)(e & (~1));
10531         e_conv.is_owned = (e & 1) || (e == 0);
10532         e_conv = DecodeError_clone(&e_conv);
10533         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10534         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
10535         return (uint64_t)ret_conv;
10536 }
10537
10538 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
10539         if ((_res & 1) != 0) return;
10540         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10541         FREE((void*)_res);
10542         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
10543 }
10544
10545 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10546         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
10547         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10548         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
10549         return (uint64_t)ret_conv;
10550 }
10551
10552 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
10553         LDKChannelAnnouncement o_conv;
10554         o_conv.inner = (void*)(o & (~1));
10555         o_conv.is_owned = (o & 1) || (o == 0);
10556         o_conv = ChannelAnnouncement_clone(&o_conv);
10557         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10558         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
10559         return (uint64_t)ret_conv;
10560 }
10561
10562 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
10563         LDKDecodeError e_conv;
10564         e_conv.inner = (void*)(e & (~1));
10565         e_conv.is_owned = (e & 1) || (e == 0);
10566         e_conv = DecodeError_clone(&e_conv);
10567         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10568         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
10569         return (uint64_t)ret_conv;
10570 }
10571
10572 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
10573         if ((_res & 1) != 0) return;
10574         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10575         FREE((void*)_res);
10576         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
10577 }
10578
10579 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10580         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
10581         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10582         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
10583         return (uint64_t)ret_conv;
10584 }
10585
10586 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
10587         LDKUnsignedChannelUpdate o_conv;
10588         o_conv.inner = (void*)(o & (~1));
10589         o_conv.is_owned = (o & 1) || (o == 0);
10590         o_conv = UnsignedChannelUpdate_clone(&o_conv);
10591         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10592         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
10593         return (uint64_t)ret_conv;
10594 }
10595
10596 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
10597         LDKDecodeError e_conv;
10598         e_conv.inner = (void*)(e & (~1));
10599         e_conv.is_owned = (e & 1) || (e == 0);
10600         e_conv = DecodeError_clone(&e_conv);
10601         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10602         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
10603         return (uint64_t)ret_conv;
10604 }
10605
10606 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
10607         if ((_res & 1) != 0) return;
10608         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10609         FREE((void*)_res);
10610         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
10611 }
10612
10613 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
10614         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
10615         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10616         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
10617         return (uint64_t)ret_conv;
10618 }
10619
10620 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
10621         LDKChannelUpdate o_conv;
10622         o_conv.inner = (void*)(o & (~1));
10623         o_conv.is_owned = (o & 1) || (o == 0);
10624         o_conv = ChannelUpdate_clone(&o_conv);
10625         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10626         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
10627         return (uint64_t)ret_conv;
10628 }
10629
10630 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
10631         LDKDecodeError e_conv;
10632         e_conv.inner = (void*)(e & (~1));
10633         e_conv.is_owned = (e & 1) || (e == 0);
10634         e_conv = DecodeError_clone(&e_conv);
10635         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10636         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
10637         return (uint64_t)ret_conv;
10638 }
10639
10640 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
10641         if ((_res & 1) != 0) return;
10642         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10643         FREE((void*)_res);
10644         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
10645 }
10646
10647 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
10648         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
10649         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10650         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
10651         return (uint64_t)ret_conv;
10652 }
10653
10654 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
10655         LDKErrorMessage o_conv;
10656         o_conv.inner = (void*)(o & (~1));
10657         o_conv.is_owned = (o & 1) || (o == 0);
10658         o_conv = ErrorMessage_clone(&o_conv);
10659         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10660         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
10661         return (uint64_t)ret_conv;
10662 }
10663
10664 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
10665         LDKDecodeError e_conv;
10666         e_conv.inner = (void*)(e & (~1));
10667         e_conv.is_owned = (e & 1) || (e == 0);
10668         e_conv = DecodeError_clone(&e_conv);
10669         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10670         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
10671         return (uint64_t)ret_conv;
10672 }
10673
10674 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
10675         if ((_res & 1) != 0) return;
10676         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
10677         FREE((void*)_res);
10678         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
10679 }
10680
10681 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
10682         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
10683         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10684         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
10685         return (uint64_t)ret_conv;
10686 }
10687
10688 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
10689         LDKUnsignedNodeAnnouncement o_conv;
10690         o_conv.inner = (void*)(o & (~1));
10691         o_conv.is_owned = (o & 1) || (o == 0);
10692         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
10693         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10694         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
10695         return (uint64_t)ret_conv;
10696 }
10697
10698 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
10699         LDKDecodeError e_conv;
10700         e_conv.inner = (void*)(e & (~1));
10701         e_conv.is_owned = (e & 1) || (e == 0);
10702         e_conv = DecodeError_clone(&e_conv);
10703         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10704         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
10705         return (uint64_t)ret_conv;
10706 }
10707
10708 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
10709         if ((_res & 1) != 0) return;
10710         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10711         FREE((void*)_res);
10712         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
10713 }
10714
10715 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10716         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
10717         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10718         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
10719         return (uint64_t)ret_conv;
10720 }
10721
10722 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
10723         LDKNodeAnnouncement o_conv;
10724         o_conv.inner = (void*)(o & (~1));
10725         o_conv.is_owned = (o & 1) || (o == 0);
10726         o_conv = NodeAnnouncement_clone(&o_conv);
10727         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10728         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
10729         return (uint64_t)ret_conv;
10730 }
10731
10732 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
10733         LDKDecodeError e_conv;
10734         e_conv.inner = (void*)(e & (~1));
10735         e_conv.is_owned = (e & 1) || (e == 0);
10736         e_conv = DecodeError_clone(&e_conv);
10737         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10738         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
10739         return (uint64_t)ret_conv;
10740 }
10741
10742 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
10743         if ((_res & 1) != 0) return;
10744         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10745         FREE((void*)_res);
10746         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
10747 }
10748
10749 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10750         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
10751         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10752         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
10753         return (uint64_t)ret_conv;
10754 }
10755
10756 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
10757         LDKQueryShortChannelIds o_conv;
10758         o_conv.inner = (void*)(o & (~1));
10759         o_conv.is_owned = (o & 1) || (o == 0);
10760         o_conv = QueryShortChannelIds_clone(&o_conv);
10761         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10762         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
10763         return (uint64_t)ret_conv;
10764 }
10765
10766 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
10767         LDKDecodeError e_conv;
10768         e_conv.inner = (void*)(e & (~1));
10769         e_conv.is_owned = (e & 1) || (e == 0);
10770         e_conv = DecodeError_clone(&e_conv);
10771         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10772         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
10773         return (uint64_t)ret_conv;
10774 }
10775
10776 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
10777         if ((_res & 1) != 0) return;
10778         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
10779         FREE((void*)_res);
10780         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
10781 }
10782
10783 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
10784         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
10785         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10786         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
10787         return (uint64_t)ret_conv;
10788 }
10789
10790 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
10791         LDKReplyShortChannelIdsEnd o_conv;
10792         o_conv.inner = (void*)(o & (~1));
10793         o_conv.is_owned = (o & 1) || (o == 0);
10794         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
10795         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10796         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
10797         return (uint64_t)ret_conv;
10798 }
10799
10800 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
10801         LDKDecodeError e_conv;
10802         e_conv.inner = (void*)(e & (~1));
10803         e_conv.is_owned = (e & 1) || (e == 0);
10804         e_conv = DecodeError_clone(&e_conv);
10805         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10806         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
10807         return (uint64_t)ret_conv;
10808 }
10809
10810 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
10811         if ((_res & 1) != 0) return;
10812         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
10813         FREE((void*)_res);
10814         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
10815 }
10816
10817 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
10818         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
10819         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10820         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
10821         return (uint64_t)ret_conv;
10822 }
10823
10824 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
10825         LDKQueryChannelRange o_conv;
10826         o_conv.inner = (void*)(o & (~1));
10827         o_conv.is_owned = (o & 1) || (o == 0);
10828         o_conv = QueryChannelRange_clone(&o_conv);
10829         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10830         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
10831         return (uint64_t)ret_conv;
10832 }
10833
10834 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
10835         LDKDecodeError e_conv;
10836         e_conv.inner = (void*)(e & (~1));
10837         e_conv.is_owned = (e & 1) || (e == 0);
10838         e_conv = DecodeError_clone(&e_conv);
10839         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10840         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
10841         return (uint64_t)ret_conv;
10842 }
10843
10844 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
10845         if ((_res & 1) != 0) return;
10846         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10847         FREE((void*)_res);
10848         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
10849 }
10850
10851 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
10852         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
10853         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10854         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
10855         return (uint64_t)ret_conv;
10856 }
10857
10858 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
10859         LDKReplyChannelRange o_conv;
10860         o_conv.inner = (void*)(o & (~1));
10861         o_conv.is_owned = (o & 1) || (o == 0);
10862         o_conv = ReplyChannelRange_clone(&o_conv);
10863         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10864         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
10865         return (uint64_t)ret_conv;
10866 }
10867
10868 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
10869         LDKDecodeError e_conv;
10870         e_conv.inner = (void*)(e & (~1));
10871         e_conv.is_owned = (e & 1) || (e == 0);
10872         e_conv = DecodeError_clone(&e_conv);
10873         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10874         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
10875         return (uint64_t)ret_conv;
10876 }
10877
10878 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
10879         if ((_res & 1) != 0) return;
10880         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10881         FREE((void*)_res);
10882         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
10883 }
10884
10885 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
10886         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
10887         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10888         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
10889         return (uint64_t)ret_conv;
10890 }
10891
10892 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
10893         LDKGossipTimestampFilter o_conv;
10894         o_conv.inner = (void*)(o & (~1));
10895         o_conv.is_owned = (o & 1) || (o == 0);
10896         o_conv = GossipTimestampFilter_clone(&o_conv);
10897         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10898         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
10899         return (uint64_t)ret_conv;
10900 }
10901
10902 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
10903         LDKDecodeError e_conv;
10904         e_conv.inner = (void*)(e & (~1));
10905         e_conv.is_owned = (e & 1) || (e == 0);
10906         e_conv = DecodeError_clone(&e_conv);
10907         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10908         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
10909         return (uint64_t)ret_conv;
10910 }
10911
10912 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
10913         if ((_res & 1) != 0) return;
10914         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
10915         FREE((void*)_res);
10916         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
10917 }
10918
10919 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
10920         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
10921         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10922         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
10923         return (uint64_t)ret_conv;
10924 }
10925
10926 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
10927         LDKInvoice o_conv;
10928         o_conv.inner = (void*)(o & (~1));
10929         o_conv.is_owned = (o & 1) || (o == 0);
10930         o_conv = Invoice_clone(&o_conv);
10931         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10932         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
10933         return (uint64_t)ret_conv;
10934 }
10935
10936 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
10937         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
10938         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10939         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
10940         return (uint64_t)ret_conv;
10941 }
10942
10943 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
10944         if ((_res & 1) != 0) return;
10945         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
10946         FREE((void*)_res);
10947         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
10948 }
10949
10950 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
10951         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
10952         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10953         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
10954         return (uint64_t)ret_conv;
10955 }
10956
10957 void  __attribute__((visibility("default"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
10958         if ((this_ptr & 1) != 0) return;
10959         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1);
10960         FREE((void*)this_ptr);
10961         PaymentPurpose_free(this_ptr_conv);
10962 }
10963
10964 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_clone(uint32_t orig) {
10965         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
10966         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
10967         *ret_copy = PaymentPurpose_clone(orig_conv);
10968         uint64_t ret_ref = (uint64_t)ret_copy;
10969         return ret_ref;
10970 }
10971
10972 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret, int64_t user_payment_id) {
10973         LDKThirtyTwoBytes payment_preimage_ref;
10974         CHECK(*((uint32_t*)payment_preimage) == 32);
10975         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
10976         LDKThirtyTwoBytes payment_secret_ref;
10977         CHECK(*((uint32_t*)payment_secret) == 32);
10978         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
10979         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
10980         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
10981         uint64_t ret_ref = (uint64_t)ret_copy;
10982         return ret_ref;
10983 }
10984
10985 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
10986         LDKThirtyTwoBytes a_ref;
10987         CHECK(*((uint32_t*)a) == 32);
10988         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
10989         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
10990         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
10991         uint64_t ret_ref = (uint64_t)ret_copy;
10992         return ret_ref;
10993 }
10994
10995 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
10996         if ((this_ptr & 1) != 0) return;
10997         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
10998         FREE((void*)this_ptr);
10999         Event_free(this_ptr_conv);
11000 }
11001
11002 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
11003         LDKEvent* orig_conv = (LDKEvent*)orig;
11004         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11005         *ret_copy = Event_clone(orig_conv);
11006         uint64_t ret_ref = (uint64_t)ret_copy;
11007         return ret_ref;
11008 }
11009
11010 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) {
11011         LDKThirtyTwoBytes temporary_channel_id_ref;
11012         CHECK(*((uint32_t*)temporary_channel_id) == 32);
11013         memcpy(temporary_channel_id_ref.data, (uint8_t*)(temporary_channel_id + 4), 32);
11014         LDKCVec_u8Z output_script_ref;
11015         output_script_ref.datalen = *((uint32_t*)output_script);
11016         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
11017         memcpy(output_script_ref.data, (uint8_t*)(output_script + 4), output_script_ref.datalen);
11018         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11019         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
11020         uint64_t ret_ref = (uint64_t)ret_copy;
11021         return ret_ref;
11022 }
11023
11024 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
11025         LDKThirtyTwoBytes payment_hash_ref;
11026         CHECK(*((uint32_t*)payment_hash) == 32);
11027         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
11028         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1);
11029         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11030         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
11031         uint64_t ret_ref = (uint64_t)ret_copy;
11032         return ret_ref;
11033 }
11034
11035 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArray payment_preimage) {
11036         LDKThirtyTwoBytes payment_preimage_ref;
11037         CHECK(*((uint32_t*)payment_preimage) == 32);
11038         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
11039         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11040         *ret_copy = Event_payment_sent(payment_preimage_ref);
11041         uint64_t ret_ref = (uint64_t)ret_copy;
11042         return ret_ref;
11043 }
11044
11045 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_failed(int8_tArray payment_hash, jboolean rejected_by_dest) {
11046         LDKThirtyTwoBytes payment_hash_ref;
11047         CHECK(*((uint32_t*)payment_hash) == 32);
11048         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
11049         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11050         *ret_copy = Event_payment_failed(payment_hash_ref, rejected_by_dest);
11051         uint64_t ret_ref = (uint64_t)ret_copy;
11052         return ret_ref;
11053 }
11054
11055 uint32_t  __attribute__((visibility("default"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
11056         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11057         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
11058         uint64_t ret_ref = (uint64_t)ret_copy;
11059         return ret_ref;
11060 }
11061
11062 uint32_t  __attribute__((visibility("default"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
11063         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
11064         outputs_constr.datalen = *((uint32_t*)outputs);
11065         if (outputs_constr.datalen > 0)
11066                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
11067         else
11068                 outputs_constr.data = NULL;
11069         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
11070         for (size_t b = 0; b < outputs_constr.datalen; b++) {
11071                 uint32_t outputs_conv_27 = outputs_vals[b];
11072                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
11073                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
11074                 outputs_constr.data[b] = outputs_conv_27_conv;
11075         }
11076         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11077         *ret_copy = Event_spendable_outputs(outputs_constr);
11078         uint64_t ret_ref = (uint64_t)ret_copy;
11079         return ret_ref;
11080 }
11081
11082 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
11083         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1);
11084         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11085         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
11086         uint64_t ret_ref = (uint64_t)ret_copy;
11087         return ret_ref;
11088 }
11089
11090 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
11091         LDKEvent* obj_conv = (LDKEvent*)obj;
11092         LDKCVec_u8Z ret_var = Event_write(obj_conv);
11093         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11094         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11095         CVec_u8Z_free(ret_var);
11096         return ret_arr;
11097 }
11098
11099 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
11100         if ((this_ptr & 1) != 0) return;
11101         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
11102         FREE((void*)this_ptr);
11103         MessageSendEvent_free(this_ptr_conv);
11104 }
11105
11106 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
11107         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
11108         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11109         *ret_copy = MessageSendEvent_clone(orig_conv);
11110         uint64_t ret_ref = (uint64_t)ret_copy;
11111         return ret_ref;
11112 }
11113
11114 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
11115         LDKPublicKey node_id_ref;
11116         CHECK(*((uint32_t*)node_id) == 33);
11117         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11118         LDKAcceptChannel msg_conv;
11119         msg_conv.inner = (void*)(msg & (~1));
11120         msg_conv.is_owned = (msg & 1) || (msg == 0);
11121         msg_conv = AcceptChannel_clone(&msg_conv);
11122         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11123         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
11124         uint64_t ret_ref = (uint64_t)ret_copy;
11125         return ret_ref;
11126 }
11127
11128 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
11129         LDKPublicKey node_id_ref;
11130         CHECK(*((uint32_t*)node_id) == 33);
11131         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11132         LDKOpenChannel msg_conv;
11133         msg_conv.inner = (void*)(msg & (~1));
11134         msg_conv.is_owned = (msg & 1) || (msg == 0);
11135         msg_conv = OpenChannel_clone(&msg_conv);
11136         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11137         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
11138         uint64_t ret_ref = (uint64_t)ret_copy;
11139         return ret_ref;
11140 }
11141
11142 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
11143         LDKPublicKey node_id_ref;
11144         CHECK(*((uint32_t*)node_id) == 33);
11145         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11146         LDKFundingCreated msg_conv;
11147         msg_conv.inner = (void*)(msg & (~1));
11148         msg_conv.is_owned = (msg & 1) || (msg == 0);
11149         msg_conv = FundingCreated_clone(&msg_conv);
11150         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11151         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
11152         uint64_t ret_ref = (uint64_t)ret_copy;
11153         return ret_ref;
11154 }
11155
11156 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
11157         LDKPublicKey node_id_ref;
11158         CHECK(*((uint32_t*)node_id) == 33);
11159         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11160         LDKFundingSigned msg_conv;
11161         msg_conv.inner = (void*)(msg & (~1));
11162         msg_conv.is_owned = (msg & 1) || (msg == 0);
11163         msg_conv = FundingSigned_clone(&msg_conv);
11164         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11165         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
11166         uint64_t ret_ref = (uint64_t)ret_copy;
11167         return ret_ref;
11168 }
11169
11170 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
11171         LDKPublicKey node_id_ref;
11172         CHECK(*((uint32_t*)node_id) == 33);
11173         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11174         LDKFundingLocked msg_conv;
11175         msg_conv.inner = (void*)(msg & (~1));
11176         msg_conv.is_owned = (msg & 1) || (msg == 0);
11177         msg_conv = FundingLocked_clone(&msg_conv);
11178         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11179         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
11180         uint64_t ret_ref = (uint64_t)ret_copy;
11181         return ret_ref;
11182 }
11183
11184 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
11185         LDKPublicKey node_id_ref;
11186         CHECK(*((uint32_t*)node_id) == 33);
11187         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11188         LDKAnnouncementSignatures msg_conv;
11189         msg_conv.inner = (void*)(msg & (~1));
11190         msg_conv.is_owned = (msg & 1) || (msg == 0);
11191         msg_conv = AnnouncementSignatures_clone(&msg_conv);
11192         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11193         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
11194         uint64_t ret_ref = (uint64_t)ret_copy;
11195         return ret_ref;
11196 }
11197
11198 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
11199         LDKPublicKey node_id_ref;
11200         CHECK(*((uint32_t*)node_id) == 33);
11201         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11202         LDKCommitmentUpdate updates_conv;
11203         updates_conv.inner = (void*)(updates & (~1));
11204         updates_conv.is_owned = (updates & 1) || (updates == 0);
11205         updates_conv = CommitmentUpdate_clone(&updates_conv);
11206         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11207         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
11208         uint64_t ret_ref = (uint64_t)ret_copy;
11209         return ret_ref;
11210 }
11211
11212 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
11213         LDKPublicKey node_id_ref;
11214         CHECK(*((uint32_t*)node_id) == 33);
11215         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11216         LDKRevokeAndACK msg_conv;
11217         msg_conv.inner = (void*)(msg & (~1));
11218         msg_conv.is_owned = (msg & 1) || (msg == 0);
11219         msg_conv = RevokeAndACK_clone(&msg_conv);
11220         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11221         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
11222         uint64_t ret_ref = (uint64_t)ret_copy;
11223         return ret_ref;
11224 }
11225
11226 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
11227         LDKPublicKey node_id_ref;
11228         CHECK(*((uint32_t*)node_id) == 33);
11229         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11230         LDKClosingSigned msg_conv;
11231         msg_conv.inner = (void*)(msg & (~1));
11232         msg_conv.is_owned = (msg & 1) || (msg == 0);
11233         msg_conv = ClosingSigned_clone(&msg_conv);
11234         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11235         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
11236         uint64_t ret_ref = (uint64_t)ret_copy;
11237         return ret_ref;
11238 }
11239
11240 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
11241         LDKPublicKey node_id_ref;
11242         CHECK(*((uint32_t*)node_id) == 33);
11243         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11244         LDKShutdown msg_conv;
11245         msg_conv.inner = (void*)(msg & (~1));
11246         msg_conv.is_owned = (msg & 1) || (msg == 0);
11247         msg_conv = Shutdown_clone(&msg_conv);
11248         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11249         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
11250         uint64_t ret_ref = (uint64_t)ret_copy;
11251         return ret_ref;
11252 }
11253
11254 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
11255         LDKPublicKey node_id_ref;
11256         CHECK(*((uint32_t*)node_id) == 33);
11257         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11258         LDKChannelReestablish msg_conv;
11259         msg_conv.inner = (void*)(msg & (~1));
11260         msg_conv.is_owned = (msg & 1) || (msg == 0);
11261         msg_conv = ChannelReestablish_clone(&msg_conv);
11262         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11263         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
11264         uint64_t ret_ref = (uint64_t)ret_copy;
11265         return ret_ref;
11266 }
11267
11268 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
11269         LDKChannelAnnouncement msg_conv;
11270         msg_conv.inner = (void*)(msg & (~1));
11271         msg_conv.is_owned = (msg & 1) || (msg == 0);
11272         msg_conv = ChannelAnnouncement_clone(&msg_conv);
11273         LDKChannelUpdate update_msg_conv;
11274         update_msg_conv.inner = (void*)(update_msg & (~1));
11275         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
11276         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
11277         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11278         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
11279         uint64_t ret_ref = (uint64_t)ret_copy;
11280         return ret_ref;
11281 }
11282
11283 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
11284         LDKNodeAnnouncement msg_conv;
11285         msg_conv.inner = (void*)(msg & (~1));
11286         msg_conv.is_owned = (msg & 1) || (msg == 0);
11287         msg_conv = NodeAnnouncement_clone(&msg_conv);
11288         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11289         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
11290         uint64_t ret_ref = (uint64_t)ret_copy;
11291         return ret_ref;
11292 }
11293
11294 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
11295         LDKChannelUpdate msg_conv;
11296         msg_conv.inner = (void*)(msg & (~1));
11297         msg_conv.is_owned = (msg & 1) || (msg == 0);
11298         msg_conv = ChannelUpdate_clone(&msg_conv);
11299         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11300         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
11301         uint64_t ret_ref = (uint64_t)ret_copy;
11302         return ret_ref;
11303 }
11304
11305 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
11306         LDKPublicKey node_id_ref;
11307         CHECK(*((uint32_t*)node_id) == 33);
11308         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11309         LDKChannelUpdate msg_conv;
11310         msg_conv.inner = (void*)(msg & (~1));
11311         msg_conv.is_owned = (msg & 1) || (msg == 0);
11312         msg_conv = ChannelUpdate_clone(&msg_conv);
11313         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11314         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
11315         uint64_t ret_ref = (uint64_t)ret_copy;
11316         return ret_ref;
11317 }
11318
11319 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
11320         LDKPublicKey node_id_ref;
11321         CHECK(*((uint32_t*)node_id) == 33);
11322         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11323         LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1);
11324         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11325         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
11326         uint64_t ret_ref = (uint64_t)ret_copy;
11327         return ret_ref;
11328 }
11329
11330 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_payment_failure_network_update(uint32_t update) {
11331         LDKHTLCFailChannelUpdate update_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)update) & ~1);
11332         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11333         *ret_copy = MessageSendEvent_payment_failure_network_update(update_conv);
11334         uint64_t ret_ref = (uint64_t)ret_copy;
11335         return ret_ref;
11336 }
11337
11338 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
11339         LDKPublicKey node_id_ref;
11340         CHECK(*((uint32_t*)node_id) == 33);
11341         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11342         LDKQueryChannelRange msg_conv;
11343         msg_conv.inner = (void*)(msg & (~1));
11344         msg_conv.is_owned = (msg & 1) || (msg == 0);
11345         msg_conv = QueryChannelRange_clone(&msg_conv);
11346         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11347         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
11348         uint64_t ret_ref = (uint64_t)ret_copy;
11349         return ret_ref;
11350 }
11351
11352 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
11353         LDKPublicKey node_id_ref;
11354         CHECK(*((uint32_t*)node_id) == 33);
11355         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11356         LDKQueryShortChannelIds msg_conv;
11357         msg_conv.inner = (void*)(msg & (~1));
11358         msg_conv.is_owned = (msg & 1) || (msg == 0);
11359         msg_conv = QueryShortChannelIds_clone(&msg_conv);
11360         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11361         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
11362         uint64_t ret_ref = (uint64_t)ret_copy;
11363         return ret_ref;
11364 }
11365
11366 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
11367         LDKPublicKey node_id_ref;
11368         CHECK(*((uint32_t*)node_id) == 33);
11369         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
11370         LDKReplyChannelRange msg_conv;
11371         msg_conv.inner = (void*)(msg & (~1));
11372         msg_conv.is_owned = (msg & 1) || (msg == 0);
11373         msg_conv = ReplyChannelRange_clone(&msg_conv);
11374         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
11375         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
11376         uint64_t ret_ref = (uint64_t)ret_copy;
11377         return ret_ref;
11378 }
11379
11380 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
11381         if ((this_ptr & 1) != 0) return;
11382         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
11383         FREE((void*)this_ptr);
11384         MessageSendEventsProvider_free(this_ptr_conv);
11385 }
11386
11387 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
11388         if ((this_ptr & 1) != 0) return;
11389         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
11390         FREE((void*)this_ptr);
11391         EventsProvider_free(this_ptr_conv);
11392 }
11393
11394 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
11395         if ((this_ptr & 1) != 0) return;
11396         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
11397         FREE((void*)this_ptr);
11398         EventHandler_free(this_ptr_conv);
11399 }
11400
11401 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
11402         if ((this_ptr & 1) != 0) return;
11403         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
11404         FREE((void*)this_ptr);
11405         APIError_free(this_ptr_conv);
11406 }
11407
11408 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
11409         LDKAPIError* orig_conv = (LDKAPIError*)orig;
11410         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
11411         *ret_copy = APIError_clone(orig_conv);
11412         uint64_t ret_ref = (uint64_t)ret_copy;
11413         return ret_ref;
11414 }
11415
11416 uint32_t  __attribute__((visibility("default"))) TS_APIError_apimisuse_error(jstring err) {
11417         LDKStr err_conv = str_ref_to_owned_c(err);
11418         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
11419         *ret_copy = APIError_apimisuse_error(err_conv);
11420         uint64_t ret_ref = (uint64_t)ret_copy;
11421         return ret_ref;
11422 }
11423
11424 uint32_t  __attribute__((visibility("default"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
11425         LDKStr err_conv = str_ref_to_owned_c(err);
11426         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
11427         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
11428         uint64_t ret_ref = (uint64_t)ret_copy;
11429         return ret_ref;
11430 }
11431
11432 uint32_t  __attribute__((visibility("default"))) TS_APIError_route_error(jstring err) {
11433         LDKStr err_conv = str_ref_to_owned_c(err);
11434         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
11435         *ret_copy = APIError_route_error(err_conv);
11436         uint64_t ret_ref = (uint64_t)ret_copy;
11437         return ret_ref;
11438 }
11439
11440 uint32_t  __attribute__((visibility("default"))) TS_APIError_channel_unavailable(jstring err) {
11441         LDKStr err_conv = str_ref_to_owned_c(err);
11442         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
11443         *ret_copy = APIError_channel_unavailable(err_conv);
11444         uint64_t ret_ref = (uint64_t)ret_copy;
11445         return ret_ref;
11446 }
11447
11448 uint32_t  __attribute__((visibility("default"))) TS_APIError_monitor_update_failed() {
11449         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
11450         *ret_copy = APIError_monitor_update_failed();
11451         uint64_t ret_ref = (uint64_t)ret_copy;
11452         return ret_ref;
11453 }
11454
11455 uint32_t  __attribute__((visibility("default"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
11456         LDKShutdownScript script_conv;
11457         script_conv.inner = (void*)(script & (~1));
11458         script_conv.is_owned = (script & 1) || (script == 0);
11459         script_conv = ShutdownScript_clone(&script_conv);
11460         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
11461         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
11462         uint64_t ret_ref = (uint64_t)ret_copy;
11463         return ret_ref;
11464 }
11465
11466 uint32_t  __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_tArray sk) {
11467         LDKu8slice msg_ref;
11468         msg_ref.datalen = *((uint32_t*)msg);
11469         msg_ref.data = (int8_t*)(msg + 4);
11470         unsigned char sk_arr[32];
11471         CHECK(*((uint32_t*)sk) == 32);
11472         memcpy(sk_arr, (uint8_t*)(sk + 4), 32);
11473         unsigned char (*sk_ref)[32] = &sk_arr;
11474         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11475         *ret_conv = sign(msg_ref, sk_ref);
11476         return (uint64_t)ret_conv;
11477 }
11478
11479 uint32_t  __attribute__((visibility("default"))) TS_recover_pk(int8_tArray msg, jstring sig) {
11480         LDKu8slice msg_ref;
11481         msg_ref.datalen = *((uint32_t*)msg);
11482         msg_ref.data = (int8_t*)(msg + 4);
11483         LDKStr sig_conv = str_ref_to_owned_c(sig);
11484         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11485         *ret_conv = recover_pk(msg_ref, sig_conv);
11486         return (uint64_t)ret_conv;
11487 }
11488
11489 jboolean  __attribute__((visibility("default"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
11490         LDKu8slice msg_ref;
11491         msg_ref.datalen = *((uint32_t*)msg);
11492         msg_ref.data = (int8_t*)(msg + 4);
11493         LDKStr sig_conv = str_ref_to_owned_c(sig);
11494         LDKPublicKey pk_ref;
11495         CHECK(*((uint32_t*)pk) == 33);
11496         memcpy(pk_ref.compressed_form, (uint8_t*)(pk + 4), 33);
11497         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
11498         return ret_val;
11499 }
11500
11501 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
11502         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
11503         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
11504         return ret_conv;
11505 }
11506
11507 uint32_t  __attribute__((visibility("default"))) TS_Level_trace() {
11508         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
11509         return ret_conv;
11510 }
11511
11512 uint32_t  __attribute__((visibility("default"))) TS_Level_debug() {
11513         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
11514         return ret_conv;
11515 }
11516
11517 uint32_t  __attribute__((visibility("default"))) TS_Level_info() {
11518         uint32_t ret_conv = LDKLevel_to_js(Level_info());
11519         return ret_conv;
11520 }
11521
11522 uint32_t  __attribute__((visibility("default"))) TS_Level_warn() {
11523         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
11524         return ret_conv;
11525 }
11526
11527 uint32_t  __attribute__((visibility("default"))) TS_Level_error() {
11528         uint32_t ret_conv = LDKLevel_to_js(Level_error());
11529         return ret_conv;
11530 }
11531
11532 jboolean  __attribute__((visibility("default"))) TS_Level_eq(uint32_t a, uint32_t b) {
11533         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
11534         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
11535         jboolean ret_val = Level_eq(a_conv, b_conv);
11536         return ret_val;
11537 }
11538
11539 int64_t  __attribute__((visibility("default"))) TS_Level_hash(uint32_t o) {
11540         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
11541         int64_t ret_val = Level_hash(o_conv);
11542         return ret_val;
11543 }
11544
11545 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
11546         uint32_t ret_conv = LDKLevel_to_js(Level_max());
11547         return ret_conv;
11548 }
11549
11550 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
11551         if ((this_ptr & 1) != 0) return;
11552         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
11553         FREE((void*)this_ptr);
11554         Logger_free(this_ptr_conv);
11555 }
11556
11557 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
11558         LDKChannelHandshakeConfig this_obj_conv;
11559         this_obj_conv.inner = (void*)(this_obj & (~1));
11560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11561         ChannelHandshakeConfig_free(this_obj_conv);
11562 }
11563
11564 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
11565         LDKChannelHandshakeConfig this_ptr_conv;
11566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11567         this_ptr_conv.is_owned = false;
11568         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
11569         return ret_val;
11570 }
11571
11572 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
11573         LDKChannelHandshakeConfig this_ptr_conv;
11574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11575         this_ptr_conv.is_owned = false;
11576         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
11577 }
11578
11579 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
11580         LDKChannelHandshakeConfig this_ptr_conv;
11581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11582         this_ptr_conv.is_owned = false;
11583         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
11584         return ret_val;
11585 }
11586
11587 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
11588         LDKChannelHandshakeConfig this_ptr_conv;
11589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11590         this_ptr_conv.is_owned = false;
11591         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
11592 }
11593
11594 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
11595         LDKChannelHandshakeConfig this_ptr_conv;
11596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11597         this_ptr_conv.is_owned = false;
11598         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
11599         return ret_val;
11600 }
11601
11602 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
11603         LDKChannelHandshakeConfig this_ptr_conv;
11604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11605         this_ptr_conv.is_owned = false;
11606         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
11607 }
11608
11609 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) {
11610         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
11611         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11612         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11613         uint64_t ret_ref = (uint64_t)ret_var.inner;
11614         if (ret_var.is_owned) {
11615                 ret_ref |= 1;
11616         }
11617         return ret_ref;
11618 }
11619
11620 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
11621         LDKChannelHandshakeConfig orig_conv;
11622         orig_conv.inner = (void*)(orig & (~1));
11623         orig_conv.is_owned = false;
11624         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
11625         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11626         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11627         uint64_t ret_ref = (uint64_t)ret_var.inner;
11628         if (ret_var.is_owned) {
11629                 ret_ref |= 1;
11630         }
11631         return ret_ref;
11632 }
11633
11634 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
11635         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
11636         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11637         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11638         uint64_t ret_ref = (uint64_t)ret_var.inner;
11639         if (ret_var.is_owned) {
11640                 ret_ref |= 1;
11641         }
11642         return ret_ref;
11643 }
11644
11645 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
11646         LDKChannelHandshakeLimits this_obj_conv;
11647         this_obj_conv.inner = (void*)(this_obj & (~1));
11648         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11649         ChannelHandshakeLimits_free(this_obj_conv);
11650 }
11651
11652 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
11653         LDKChannelHandshakeLimits this_ptr_conv;
11654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11655         this_ptr_conv.is_owned = false;
11656         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
11657         return ret_val;
11658 }
11659
11660 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
11661         LDKChannelHandshakeLimits this_ptr_conv;
11662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11663         this_ptr_conv.is_owned = false;
11664         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
11665 }
11666
11667 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
11668         LDKChannelHandshakeLimits this_ptr_conv;
11669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11670         this_ptr_conv.is_owned = false;
11671         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
11672         return ret_val;
11673 }
11674
11675 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
11676         LDKChannelHandshakeLimits this_ptr_conv;
11677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11678         this_ptr_conv.is_owned = false;
11679         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
11680 }
11681
11682 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
11683         LDKChannelHandshakeLimits this_ptr_conv;
11684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11685         this_ptr_conv.is_owned = false;
11686         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
11687         return ret_val;
11688 }
11689
11690 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
11691         LDKChannelHandshakeLimits this_ptr_conv;
11692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11693         this_ptr_conv.is_owned = false;
11694         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
11695 }
11696
11697 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
11698         LDKChannelHandshakeLimits this_ptr_conv;
11699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11700         this_ptr_conv.is_owned = false;
11701         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
11702         return ret_val;
11703 }
11704
11705 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
11706         LDKChannelHandshakeLimits this_ptr_conv;
11707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11708         this_ptr_conv.is_owned = false;
11709         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
11710 }
11711
11712 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
11713         LDKChannelHandshakeLimits this_ptr_conv;
11714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11715         this_ptr_conv.is_owned = false;
11716         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
11717         return ret_val;
11718 }
11719
11720 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
11721         LDKChannelHandshakeLimits this_ptr_conv;
11722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11723         this_ptr_conv.is_owned = false;
11724         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
11725 }
11726
11727 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
11728         LDKChannelHandshakeLimits this_ptr_conv;
11729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11730         this_ptr_conv.is_owned = false;
11731         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
11732         return ret_val;
11733 }
11734
11735 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
11736         LDKChannelHandshakeLimits this_ptr_conv;
11737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11738         this_ptr_conv.is_owned = false;
11739         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
11740 }
11741
11742 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
11743         LDKChannelHandshakeLimits this_ptr_conv;
11744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11745         this_ptr_conv.is_owned = false;
11746         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
11747         return ret_val;
11748 }
11749
11750 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
11751         LDKChannelHandshakeLimits this_ptr_conv;
11752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11753         this_ptr_conv.is_owned = false;
11754         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
11755 }
11756
11757 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
11758         LDKChannelHandshakeLimits this_ptr_conv;
11759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11760         this_ptr_conv.is_owned = false;
11761         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
11762         return ret_val;
11763 }
11764
11765 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
11766         LDKChannelHandshakeLimits this_ptr_conv;
11767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11768         this_ptr_conv.is_owned = false;
11769         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
11770 }
11771
11772 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) {
11773         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);
11774         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11775         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11776         uint64_t ret_ref = (uint64_t)ret_var.inner;
11777         if (ret_var.is_owned) {
11778                 ret_ref |= 1;
11779         }
11780         return ret_ref;
11781 }
11782
11783 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
11784         LDKChannelHandshakeLimits orig_conv;
11785         orig_conv.inner = (void*)(orig & (~1));
11786         orig_conv.is_owned = false;
11787         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
11788         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11789         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11790         uint64_t ret_ref = (uint64_t)ret_var.inner;
11791         if (ret_var.is_owned) {
11792                 ret_ref |= 1;
11793         }
11794         return ret_ref;
11795 }
11796
11797 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
11798         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
11799         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11800         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11801         uint64_t ret_ref = (uint64_t)ret_var.inner;
11802         if (ret_var.is_owned) {
11803                 ret_ref |= 1;
11804         }
11805         return ret_ref;
11806 }
11807
11808 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
11809         LDKChannelConfig this_obj_conv;
11810         this_obj_conv.inner = (void*)(this_obj & (~1));
11811         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11812         ChannelConfig_free(this_obj_conv);
11813 }
11814
11815 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
11816         LDKChannelConfig this_ptr_conv;
11817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11818         this_ptr_conv.is_owned = false;
11819         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
11820         return ret_val;
11821 }
11822
11823 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
11824         LDKChannelConfig this_ptr_conv;
11825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11826         this_ptr_conv.is_owned = false;
11827         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
11828 }
11829
11830 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
11831         LDKChannelConfig this_ptr_conv;
11832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11833         this_ptr_conv.is_owned = false;
11834         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
11835         return ret_val;
11836 }
11837
11838 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint32_t this_ptr, int32_t val) {
11839         LDKChannelConfig this_ptr_conv;
11840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11841         this_ptr_conv.is_owned = false;
11842         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
11843 }
11844
11845 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
11846         LDKChannelConfig this_ptr_conv;
11847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11848         this_ptr_conv.is_owned = false;
11849         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
11850         return ret_val;
11851 }
11852
11853 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
11854         LDKChannelConfig this_ptr_conv;
11855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11856         this_ptr_conv.is_owned = false;
11857         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
11858 }
11859
11860 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
11861         LDKChannelConfig this_ptr_conv;
11862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11863         this_ptr_conv.is_owned = false;
11864         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
11865         return ret_val;
11866 }
11867
11868 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
11869         LDKChannelConfig this_ptr_conv;
11870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11871         this_ptr_conv.is_owned = false;
11872         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
11873 }
11874
11875 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
11876         LDKChannelConfig this_ptr_conv;
11877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11878         this_ptr_conv.is_owned = false;
11879         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
11880         return ret_val;
11881 }
11882
11883 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
11884         LDKChannelConfig this_ptr_conv;
11885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11886         this_ptr_conv.is_owned = false;
11887         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
11888 }
11889
11890 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_max_dust_htlc_exposure_msat(uint32_t this_ptr) {
11891         LDKChannelConfig this_ptr_conv;
11892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11893         this_ptr_conv.is_owned = false;
11894         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
11895         return ret_val;
11896 }
11897
11898 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_max_dust_htlc_exposure_msat(uint32_t this_ptr, int64_t val) {
11899         LDKChannelConfig this_ptr_conv;
11900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11901         this_ptr_conv.is_owned = false;
11902         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
11903 }
11904
11905 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr) {
11906         LDKChannelConfig this_ptr_conv;
11907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11908         this_ptr_conv.is_owned = false;
11909         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
11910         return ret_val;
11911 }
11912
11913 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
11914         LDKChannelConfig this_ptr_conv;
11915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11916         this_ptr_conv.is_owned = false;
11917         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
11918 }
11919
11920 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) {
11921         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);
11922         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11923         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11924         uint64_t ret_ref = (uint64_t)ret_var.inner;
11925         if (ret_var.is_owned) {
11926                 ret_ref |= 1;
11927         }
11928         return ret_ref;
11929 }
11930
11931 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
11932         LDKChannelConfig orig_conv;
11933         orig_conv.inner = (void*)(orig & (~1));
11934         orig_conv.is_owned = false;
11935         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
11936         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11937         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11938         uint64_t ret_ref = (uint64_t)ret_var.inner;
11939         if (ret_var.is_owned) {
11940                 ret_ref |= 1;
11941         }
11942         return ret_ref;
11943 }
11944
11945 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
11946         LDKChannelConfig ret_var = ChannelConfig_default();
11947         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11948         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11949         uint64_t ret_ref = (uint64_t)ret_var.inner;
11950         if (ret_var.is_owned) {
11951                 ret_ref |= 1;
11952         }
11953         return ret_ref;
11954 }
11955
11956 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
11957         LDKChannelConfig obj_conv;
11958         obj_conv.inner = (void*)(obj & (~1));
11959         obj_conv.is_owned = false;
11960         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
11961         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11962         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11963         CVec_u8Z_free(ret_var);
11964         return ret_arr;
11965 }
11966
11967 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
11968         LDKu8slice ser_ref;
11969         ser_ref.datalen = *((uint32_t*)ser);
11970         ser_ref.data = (int8_t*)(ser + 4);
11971         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
11972         *ret_conv = ChannelConfig_read(ser_ref);
11973         return (uint64_t)ret_conv;
11974 }
11975
11976 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
11977         LDKUserConfig this_obj_conv;
11978         this_obj_conv.inner = (void*)(this_obj & (~1));
11979         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11980         UserConfig_free(this_obj_conv);
11981 }
11982
11983 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
11984         LDKUserConfig this_ptr_conv;
11985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11986         this_ptr_conv.is_owned = false;
11987         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
11988         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11989         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11990         uint64_t ret_ref = (uint64_t)ret_var.inner;
11991         if (ret_var.is_owned) {
11992                 ret_ref |= 1;
11993         }
11994         return ret_ref;
11995 }
11996
11997 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
11998         LDKUserConfig this_ptr_conv;
11999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12000         this_ptr_conv.is_owned = false;
12001         LDKChannelHandshakeConfig val_conv;
12002         val_conv.inner = (void*)(val & (~1));
12003         val_conv.is_owned = (val & 1) || (val == 0);
12004         val_conv = ChannelHandshakeConfig_clone(&val_conv);
12005         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
12006 }
12007
12008 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
12009         LDKUserConfig this_ptr_conv;
12010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12011         this_ptr_conv.is_owned = false;
12012         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
12013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12015         uint64_t ret_ref = (uint64_t)ret_var.inner;
12016         if (ret_var.is_owned) {
12017                 ret_ref |= 1;
12018         }
12019         return ret_ref;
12020 }
12021
12022 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
12023         LDKUserConfig this_ptr_conv;
12024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12025         this_ptr_conv.is_owned = false;
12026         LDKChannelHandshakeLimits val_conv;
12027         val_conv.inner = (void*)(val & (~1));
12028         val_conv.is_owned = (val & 1) || (val == 0);
12029         val_conv = ChannelHandshakeLimits_clone(&val_conv);
12030         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
12031 }
12032
12033 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
12034         LDKUserConfig this_ptr_conv;
12035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12036         this_ptr_conv.is_owned = false;
12037         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
12038         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12039         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12040         uint64_t ret_ref = (uint64_t)ret_var.inner;
12041         if (ret_var.is_owned) {
12042                 ret_ref |= 1;
12043         }
12044         return ret_ref;
12045 }
12046
12047 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
12048         LDKUserConfig this_ptr_conv;
12049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12050         this_ptr_conv.is_owned = false;
12051         LDKChannelConfig val_conv;
12052         val_conv.inner = (void*)(val & (~1));
12053         val_conv.is_owned = (val & 1) || (val == 0);
12054         val_conv = ChannelConfig_clone(&val_conv);
12055         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
12056 }
12057
12058 jboolean  __attribute__((visibility("default"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
12059         LDKUserConfig this_ptr_conv;
12060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12061         this_ptr_conv.is_owned = false;
12062         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
12063         return ret_val;
12064 }
12065
12066 void  __attribute__((visibility("default"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint32_t this_ptr, jboolean val) {
12067         LDKUserConfig this_ptr_conv;
12068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12069         this_ptr_conv.is_owned = false;
12070         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
12071 }
12072
12073 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) {
12074         LDKChannelHandshakeConfig own_channel_config_arg_conv;
12075         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
12076         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
12077         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
12078         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
12079         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
12080         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
12081         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
12082         LDKChannelConfig channel_options_arg_conv;
12083         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
12084         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
12085         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
12086         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);
12087         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12088         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12089         uint64_t ret_ref = (uint64_t)ret_var.inner;
12090         if (ret_var.is_owned) {
12091                 ret_ref |= 1;
12092         }
12093         return ret_ref;
12094 }
12095
12096 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
12097         LDKUserConfig orig_conv;
12098         orig_conv.inner = (void*)(orig & (~1));
12099         orig_conv.is_owned = false;
12100         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
12101         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12102         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12103         uint64_t ret_ref = (uint64_t)ret_var.inner;
12104         if (ret_var.is_owned) {
12105                 ret_ref |= 1;
12106         }
12107         return ret_ref;
12108 }
12109
12110 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
12111         LDKUserConfig ret_var = UserConfig_default();
12112         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12113         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12114         uint64_t ret_ref = (uint64_t)ret_var.inner;
12115         if (ret_var.is_owned) {
12116                 ret_ref |= 1;
12117         }
12118         return ret_ref;
12119 }
12120
12121 void  __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) {
12122         LDKBestBlock this_obj_conv;
12123         this_obj_conv.inner = (void*)(this_obj & (~1));
12124         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12125         BestBlock_free(this_obj_conv);
12126 }
12127
12128 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) {
12129         LDKBestBlock orig_conv;
12130         orig_conv.inner = (void*)(orig & (~1));
12131         orig_conv.is_owned = false;
12132         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
12133         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12134         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12135         uint64_t ret_ref = (uint64_t)ret_var.inner;
12136         if (ret_var.is_owned) {
12137                 ret_ref |= 1;
12138         }
12139         return ret_ref;
12140 }
12141
12142 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
12143         LDKNetwork network_conv = LDKNetwork_from_js(network);
12144         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
12145         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12146         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12147         uint64_t ret_ref = (uint64_t)ret_var.inner;
12148         if (ret_var.is_owned) {
12149                 ret_ref |= 1;
12150         }
12151         return ret_ref;
12152 }
12153
12154 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
12155         LDKThirtyTwoBytes block_hash_ref;
12156         CHECK(*((uint32_t*)block_hash) == 32);
12157         memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
12158         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
12159         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12160         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12161         uint64_t ret_ref = (uint64_t)ret_var.inner;
12162         if (ret_var.is_owned) {
12163                 ret_ref |= 1;
12164         }
12165         return ret_ref;
12166 }
12167
12168 int8_tArray  __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) {
12169         LDKBestBlock this_arg_conv;
12170         this_arg_conv.inner = (void*)(this_arg & (~1));
12171         this_arg_conv.is_owned = false;
12172         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12173         memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32);
12174         return ret_arr;
12175 }
12176
12177 int32_t  __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) {
12178         LDKBestBlock this_arg_conv;
12179         this_arg_conv.inner = (void*)(this_arg & (~1));
12180         this_arg_conv.is_owned = false;
12181         int32_t ret_val = BestBlock_height(&this_arg_conv);
12182         return ret_val;
12183 }
12184
12185 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
12186         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
12187         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
12188         return ret_conv;
12189 }
12190
12191 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_chain() {
12192         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
12193         return ret_conv;
12194 }
12195
12196 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_tx() {
12197         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
12198         return ret_conv;
12199 }
12200
12201 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
12202         if ((this_ptr & 1) != 0) return;
12203         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
12204         FREE((void*)this_ptr);
12205         Access_free(this_ptr_conv);
12206 }
12207
12208 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
12209         if ((this_ptr & 1) != 0) return;
12210         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
12211         FREE((void*)this_ptr);
12212         Listen_free(this_ptr_conv);
12213 }
12214
12215 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
12216         if ((this_ptr & 1) != 0) return;
12217         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
12218         FREE((void*)this_ptr);
12219         Confirm_free(this_ptr_conv);
12220 }
12221
12222 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
12223         if ((this_ptr & 1) != 0) return;
12224         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
12225         FREE((void*)this_ptr);
12226         Watch_free(this_ptr_conv);
12227 }
12228
12229 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
12230         if ((this_ptr & 1) != 0) return;
12231         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
12232         FREE((void*)this_ptr);
12233         Filter_free(this_ptr_conv);
12234 }
12235
12236 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
12237         LDKWatchedOutput this_obj_conv;
12238         this_obj_conv.inner = (void*)(this_obj & (~1));
12239         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12240         WatchedOutput_free(this_obj_conv);
12241 }
12242
12243 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
12244         LDKWatchedOutput this_ptr_conv;
12245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12246         this_ptr_conv.is_owned = false;
12247         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12248         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
12249         return ret_arr;
12250 }
12251
12252 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
12253         LDKWatchedOutput this_ptr_conv;
12254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12255         this_ptr_conv.is_owned = false;
12256         LDKThirtyTwoBytes val_ref;
12257         CHECK(*((uint32_t*)val) == 32);
12258         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12259         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
12260 }
12261
12262 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
12263         LDKWatchedOutput this_ptr_conv;
12264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12265         this_ptr_conv.is_owned = false;
12266         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
12267         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12268         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12269         uint64_t ret_ref = (uint64_t)ret_var.inner;
12270         if (ret_var.is_owned) {
12271                 ret_ref |= 1;
12272         }
12273         return ret_ref;
12274 }
12275
12276 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
12277         LDKWatchedOutput this_ptr_conv;
12278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12279         this_ptr_conv.is_owned = false;
12280         LDKOutPoint val_conv;
12281         val_conv.inner = (void*)(val & (~1));
12282         val_conv.is_owned = (val & 1) || (val == 0);
12283         val_conv = OutPoint_clone(&val_conv);
12284         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
12285 }
12286
12287 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
12288         LDKWatchedOutput this_ptr_conv;
12289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12290         this_ptr_conv.is_owned = false;
12291         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
12292         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12293         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12294         return ret_arr;
12295 }
12296
12297 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
12298         LDKWatchedOutput this_ptr_conv;
12299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12300         this_ptr_conv.is_owned = false;
12301         LDKCVec_u8Z val_ref;
12302         val_ref.datalen = *((uint32_t*)val);
12303         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
12304         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
12305         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
12306 }
12307
12308 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
12309         LDKThirtyTwoBytes block_hash_arg_ref;
12310         CHECK(*((uint32_t*)block_hash_arg) == 32);
12311         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
12312         LDKOutPoint outpoint_arg_conv;
12313         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12314         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12315         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12316         LDKCVec_u8Z script_pubkey_arg_ref;
12317         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
12318         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
12319         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
12320         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
12321         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12322         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12323         uint64_t ret_ref = (uint64_t)ret_var.inner;
12324         if (ret_var.is_owned) {
12325                 ret_ref |= 1;
12326         }
12327         return ret_ref;
12328 }
12329
12330 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t orig) {
12331         LDKWatchedOutput orig_conv;
12332         orig_conv.inner = (void*)(orig & (~1));
12333         orig_conv.is_owned = false;
12334         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
12335         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12336         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12337         uint64_t ret_ref = (uint64_t)ret_var.inner;
12338         if (ret_var.is_owned) {
12339                 ret_ref |= 1;
12340         }
12341         return ret_ref;
12342 }
12343
12344 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o) {
12345         LDKWatchedOutput o_conv;
12346         o_conv.inner = (void*)(o & (~1));
12347         o_conv.is_owned = false;
12348         int64_t ret_val = WatchedOutput_hash(&o_conv);
12349         return ret_val;
12350 }
12351
12352 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
12353         if ((this_ptr & 1) != 0) return;
12354         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
12355         FREE((void*)this_ptr);
12356         BroadcasterInterface_free(this_ptr_conv);
12357 }
12358
12359 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
12360         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
12361         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
12362         return ret_conv;
12363 }
12364
12365 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_background() {
12366         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
12367         return ret_conv;
12368 }
12369
12370 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_normal() {
12371         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
12372         return ret_conv;
12373 }
12374
12375 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_high_priority() {
12376         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
12377         return ret_conv;
12378 }
12379
12380 jboolean  __attribute__((visibility("default"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
12381         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
12382         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
12383         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
12384         return ret_val;
12385 }
12386
12387 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
12388         if ((this_ptr & 1) != 0) return;
12389         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
12390         FREE((void*)this_ptr);
12391         FeeEstimator_free(this_ptr_conv);
12392 }
12393
12394 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
12395         LDKChainMonitor this_obj_conv;
12396         this_obj_conv.inner = (void*)(this_obj & (~1));
12397         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12398         ChainMonitor_free(this_obj_conv);
12399 }
12400
12401 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
12402         LDKFilter *chain_source_conv_ptr = NULL;
12403         if (chain_source != 0) {
12404                 LDKFilter chain_source_conv;
12405                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
12406                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
12407                 *chain_source_conv_ptr = chain_source_conv;
12408         }
12409         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12410         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12411         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
12412         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
12413         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
12414         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12415         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12416         uint64_t ret_ref = (uint64_t)ret_var.inner;
12417         if (ret_var.is_owned) {
12418                 ret_ref |= 1;
12419         }
12420         return ret_ref;
12421 }
12422
12423 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
12424         LDKChainMonitor this_arg_conv;
12425         this_arg_conv.inner = (void*)(this_arg & (~1));
12426         this_arg_conv.is_owned = false;
12427         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
12428         *ret = ChainMonitor_as_Listen(&this_arg_conv);
12429         return (uint64_t)ret;
12430 }
12431
12432 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
12433         LDKChainMonitor this_arg_conv;
12434         this_arg_conv.inner = (void*)(this_arg & (~1));
12435         this_arg_conv.is_owned = false;
12436         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
12437         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
12438         return (uint64_t)ret;
12439 }
12440
12441 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
12442         LDKChainMonitor this_arg_conv;
12443         this_arg_conv.inner = (void*)(this_arg & (~1));
12444         this_arg_conv.is_owned = false;
12445         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
12446         *ret = ChainMonitor_as_Watch(&this_arg_conv);
12447         return (uint64_t)ret;
12448 }
12449
12450 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
12451         LDKChainMonitor this_arg_conv;
12452         this_arg_conv.inner = (void*)(this_arg & (~1));
12453         this_arg_conv.is_owned = false;
12454         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
12455         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
12456         return (uint64_t)ret;
12457 }
12458
12459 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
12460         LDKChannelMonitorUpdate this_obj_conv;
12461         this_obj_conv.inner = (void*)(this_obj & (~1));
12462         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12463         ChannelMonitorUpdate_free(this_obj_conv);
12464 }
12465
12466 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
12467         LDKChannelMonitorUpdate this_ptr_conv;
12468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12469         this_ptr_conv.is_owned = false;
12470         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
12471         return ret_val;
12472 }
12473
12474 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
12475         LDKChannelMonitorUpdate this_ptr_conv;
12476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12477         this_ptr_conv.is_owned = false;
12478         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
12479 }
12480
12481 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
12482         LDKChannelMonitorUpdate orig_conv;
12483         orig_conv.inner = (void*)(orig & (~1));
12484         orig_conv.is_owned = false;
12485         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
12486         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12487         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12488         uint64_t ret_ref = (uint64_t)ret_var.inner;
12489         if (ret_var.is_owned) {
12490                 ret_ref |= 1;
12491         }
12492         return ret_ref;
12493 }
12494
12495 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
12496         LDKChannelMonitorUpdate obj_conv;
12497         obj_conv.inner = (void*)(obj & (~1));
12498         obj_conv.is_owned = false;
12499         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
12500         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12501         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12502         CVec_u8Z_free(ret_var);
12503         return ret_arr;
12504 }
12505
12506 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
12507         LDKu8slice ser_ref;
12508         ser_ref.datalen = *((uint32_t*)ser);
12509         ser_ref.data = (int8_t*)(ser + 4);
12510         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
12511         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
12512         return (uint64_t)ret_conv;
12513 }
12514
12515 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
12516         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
12517         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
12518         return ret_conv;
12519 }
12520
12521 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
12522         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
12523         return ret_conv;
12524 }
12525
12526 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
12527         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
12528         return ret_conv;
12529 }
12530
12531 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
12532         LDKMonitorUpdateError this_obj_conv;
12533         this_obj_conv.inner = (void*)(this_obj & (~1));
12534         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12535         MonitorUpdateError_free(this_obj_conv);
12536 }
12537
12538 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
12539         LDKMonitorUpdateError orig_conv;
12540         orig_conv.inner = (void*)(orig & (~1));
12541         orig_conv.is_owned = false;
12542         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
12543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12545         uint64_t ret_ref = (uint64_t)ret_var.inner;
12546         if (ret_var.is_owned) {
12547                 ret_ref |= 1;
12548         }
12549         return ret_ref;
12550 }
12551
12552 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
12553         if ((this_ptr & 1) != 0) return;
12554         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
12555         FREE((void*)this_ptr);
12556         MonitorEvent_free(this_ptr_conv);
12557 }
12558
12559 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
12560         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
12561         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
12562         *ret_copy = MonitorEvent_clone(orig_conv);
12563         uint64_t ret_ref = (uint64_t)ret_copy;
12564         return ret_ref;
12565 }
12566
12567 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_htlcevent(uint32_t a) {
12568         LDKHTLCUpdate a_conv;
12569         a_conv.inner = (void*)(a & (~1));
12570         a_conv.is_owned = (a & 1) || (a == 0);
12571         a_conv = HTLCUpdate_clone(&a_conv);
12572         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
12573         *ret_copy = MonitorEvent_htlcevent(a_conv);
12574         uint64_t ret_ref = (uint64_t)ret_copy;
12575         return ret_ref;
12576 }
12577
12578 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_broadcasted(uint32_t a) {
12579         LDKOutPoint a_conv;
12580         a_conv.inner = (void*)(a & (~1));
12581         a_conv.is_owned = (a & 1) || (a == 0);
12582         a_conv = OutPoint_clone(&a_conv);
12583         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
12584         *ret_copy = MonitorEvent_commitment_tx_broadcasted(a_conv);
12585         uint64_t ret_ref = (uint64_t)ret_copy;
12586         return ret_ref;
12587 }
12588
12589 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
12590         LDKHTLCUpdate this_obj_conv;
12591         this_obj_conv.inner = (void*)(this_obj & (~1));
12592         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12593         HTLCUpdate_free(this_obj_conv);
12594 }
12595
12596 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
12597         LDKHTLCUpdate orig_conv;
12598         orig_conv.inner = (void*)(orig & (~1));
12599         orig_conv.is_owned = false;
12600         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
12601         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12602         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12603         uint64_t ret_ref = (uint64_t)ret_var.inner;
12604         if (ret_var.is_owned) {
12605                 ret_ref |= 1;
12606         }
12607         return ret_ref;
12608 }
12609
12610 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
12611         LDKHTLCUpdate obj_conv;
12612         obj_conv.inner = (void*)(obj & (~1));
12613         obj_conv.is_owned = false;
12614         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
12615         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12616         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12617         CVec_u8Z_free(ret_var);
12618         return ret_arr;
12619 }
12620
12621 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
12622         LDKu8slice ser_ref;
12623         ser_ref.datalen = *((uint32_t*)ser);
12624         ser_ref.data = (int8_t*)(ser + 4);
12625         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
12626         *ret_conv = HTLCUpdate_read(ser_ref);
12627         return (uint64_t)ret_conv;
12628 }
12629
12630 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
12631         LDKChannelMonitor this_obj_conv;
12632         this_obj_conv.inner = (void*)(this_obj & (~1));
12633         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12634         ChannelMonitor_free(this_obj_conv);
12635 }
12636
12637 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
12638         LDKChannelMonitor orig_conv;
12639         orig_conv.inner = (void*)(orig & (~1));
12640         orig_conv.is_owned = false;
12641         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
12642         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12643         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12644         uint64_t ret_ref = (uint64_t)ret_var.inner;
12645         if (ret_var.is_owned) {
12646                 ret_ref |= 1;
12647         }
12648         return ret_ref;
12649 }
12650
12651 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
12652         LDKChannelMonitor obj_conv;
12653         obj_conv.inner = (void*)(obj & (~1));
12654         obj_conv.is_owned = false;
12655         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
12656         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12657         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12658         CVec_u8Z_free(ret_var);
12659         return ret_arr;
12660 }
12661
12662 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) {
12663         LDKChannelMonitor this_arg_conv;
12664         this_arg_conv.inner = (void*)(this_arg & (~1));
12665         this_arg_conv.is_owned = false;
12666         LDKChannelMonitorUpdate updates_conv;
12667         updates_conv.inner = (void*)(updates & (~1));
12668         updates_conv.is_owned = false;
12669         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12670         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12671         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
12672         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
12673         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
12674         return (uint64_t)ret_conv;
12675 }
12676
12677 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
12678         LDKChannelMonitor this_arg_conv;
12679         this_arg_conv.inner = (void*)(this_arg & (~1));
12680         this_arg_conv.is_owned = false;
12681         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
12682         return ret_val;
12683 }
12684
12685 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
12686         LDKChannelMonitor this_arg_conv;
12687         this_arg_conv.inner = (void*)(this_arg & (~1));
12688         this_arg_conv.is_owned = false;
12689         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
12690         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
12691         return (uint64_t)ret_ref;
12692 }
12693
12694 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
12695         LDKChannelMonitor this_arg_conv;
12696         this_arg_conv.inner = (void*)(this_arg & (~1));
12697         this_arg_conv.is_owned = false;
12698         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
12699         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
12700         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
12701         for (size_t c = 0; c < ret_var.datalen; c++) {
12702                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_54_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
12703                 *ret_conv_54_ref = ret_var.data[c];
12704                 ret_arr_ptr[c] = (uint64_t)ret_conv_54_ref;
12705         }
12706         FREE(ret_var.data);
12707         return ret_arr;
12708 }
12709
12710 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
12711         LDKChannelMonitor this_arg_conv;
12712         this_arg_conv.inner = (void*)(this_arg & (~1));
12713         this_arg_conv.is_owned = false;
12714         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
12715         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
12716 }
12717
12718 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
12719         LDKChannelMonitor this_arg_conv;
12720         this_arg_conv.inner = (void*)(this_arg & (~1));
12721         this_arg_conv.is_owned = false;
12722         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
12723         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
12724         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
12725         for (size_t o = 0; o < ret_var.datalen; o++) {
12726                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
12727                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
12728                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
12729                 ret_arr_ptr[o] = ret_conv_14_ref;
12730         }
12731         FREE(ret_var.data);
12732         return ret_arr;
12733 }
12734
12735 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
12736         LDKChannelMonitor this_arg_conv;
12737         this_arg_conv.inner = (void*)(this_arg & (~1));
12738         this_arg_conv.is_owned = false;
12739         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
12740         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
12741         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
12742         for (size_t h = 0; h < ret_var.datalen; h++) {
12743                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12744                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
12745                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
12746                 ret_arr_ptr[h] = ret_conv_7_ref;
12747         }
12748         FREE(ret_var.data);
12749         return ret_arr;
12750 }
12751
12752 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
12753         LDKChannelMonitor this_arg_conv;
12754         this_arg_conv.inner = (void*)(this_arg & (~1));
12755         this_arg_conv.is_owned = false;
12756         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
12757         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
12758         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
12759         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
12760         for (size_t m = 0; m < ret_var.datalen; m++) {
12761                 LDKTransaction ret_conv_12_var = ret_var.data[m];
12762                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12763                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
12764                 Transaction_free(ret_conv_12_var);
12765                 ret_arr_ptr[m] = ret_conv_12_arr;
12766         }
12767         FREE(ret_var.data);
12768         return ret_arr;
12769 }
12770
12771 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) {
12772         LDKChannelMonitor this_arg_conv;
12773         this_arg_conv.inner = (void*)(this_arg & (~1));
12774         this_arg_conv.is_owned = false;
12775         unsigned char header_arr[80];
12776         CHECK(*((uint32_t*)header) == 80);
12777         memcpy(header_arr, (uint8_t*)(header + 4), 80);
12778         unsigned char (*header_ref)[80] = &header_arr;
12779         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12780         txdata_constr.datalen = *((uint32_t*)txdata);
12781         if (txdata_constr.datalen > 0)
12782                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12783         else
12784                 txdata_constr.data = NULL;
12785         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
12786         for (size_t e = 0; e < txdata_constr.datalen; e++) {
12787                 uint32_t txdata_conv_30 = txdata_vals[e];
12788                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
12789                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
12790                 txdata_constr.data[e] = txdata_conv_30_conv;
12791         }
12792         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12793         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12794         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12795         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);
12796         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
12797         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
12798         for (size_t x = 0; x < ret_var.datalen; x++) {
12799                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12800                 *ret_conv_49_ref = ret_var.data[x];
12801                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
12802         }
12803         FREE(ret_var.data);
12804         return ret_arr;
12805 }
12806
12807 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) {
12808         LDKChannelMonitor this_arg_conv;
12809         this_arg_conv.inner = (void*)(this_arg & (~1));
12810         this_arg_conv.is_owned = false;
12811         unsigned char header_arr[80];
12812         CHECK(*((uint32_t*)header) == 80);
12813         memcpy(header_arr, (uint8_t*)(header + 4), 80);
12814         unsigned char (*header_ref)[80] = &header_arr;
12815         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12816         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12817         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12818         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
12819 }
12820
12821 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) {
12822         LDKChannelMonitor this_arg_conv;
12823         this_arg_conv.inner = (void*)(this_arg & (~1));
12824         this_arg_conv.is_owned = false;
12825         unsigned char header_arr[80];
12826         CHECK(*((uint32_t*)header) == 80);
12827         memcpy(header_arr, (uint8_t*)(header + 4), 80);
12828         unsigned char (*header_ref)[80] = &header_arr;
12829         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12830         txdata_constr.datalen = *((uint32_t*)txdata);
12831         if (txdata_constr.datalen > 0)
12832                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12833         else
12834                 txdata_constr.data = NULL;
12835         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
12836         for (size_t e = 0; e < txdata_constr.datalen; e++) {
12837                 uint32_t txdata_conv_30 = txdata_vals[e];
12838                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
12839                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
12840                 txdata_constr.data[e] = txdata_conv_30_conv;
12841         }
12842         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12843         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12844         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12845         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);
12846         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
12847         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
12848         for (size_t x = 0; x < ret_var.datalen; x++) {
12849                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12850                 *ret_conv_49_ref = ret_var.data[x];
12851                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
12852         }
12853         FREE(ret_var.data);
12854         return ret_arr;
12855 }
12856
12857 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) {
12858         LDKChannelMonitor this_arg_conv;
12859         this_arg_conv.inner = (void*)(this_arg & (~1));
12860         this_arg_conv.is_owned = false;
12861         unsigned char txid_arr[32];
12862         CHECK(*((uint32_t*)txid) == 32);
12863         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
12864         unsigned char (*txid_ref)[32] = &txid_arr;
12865         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12866         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12867         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12868         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
12869 }
12870
12871 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) {
12872         LDKChannelMonitor this_arg_conv;
12873         this_arg_conv.inner = (void*)(this_arg & (~1));
12874         this_arg_conv.is_owned = false;
12875         unsigned char header_arr[80];
12876         CHECK(*((uint32_t*)header) == 80);
12877         memcpy(header_arr, (uint8_t*)(header + 4), 80);
12878         unsigned char (*header_ref)[80] = &header_arr;
12879         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12880         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12881         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12882         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
12883         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
12884         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
12885         for (size_t x = 0; x < ret_var.datalen; x++) {
12886                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12887                 *ret_conv_49_ref = ret_var.data[x];
12888                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
12889         }
12890         FREE(ret_var.data);
12891         return ret_arr;
12892 }
12893
12894 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
12895         LDKChannelMonitor this_arg_conv;
12896         this_arg_conv.inner = (void*)(this_arg & (~1));
12897         this_arg_conv.is_owned = false;
12898         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
12899         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
12900         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
12901         for (size_t m = 0; m < ret_var.datalen; m++) {
12902                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12903                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
12904                 ret_arr_ptr[m] = ret_conv_12_arr;
12905         }
12906         FREE(ret_var.data);
12907         return ret_arr;
12908 }
12909
12910 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
12911         LDKChannelMonitor this_arg_conv;
12912         this_arg_conv.inner = (void*)(this_arg & (~1));
12913         this_arg_conv.is_owned = false;
12914         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
12915         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12916         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12917         uint64_t ret_ref = (uint64_t)ret_var.inner;
12918         if (ret_var.is_owned) {
12919                 ret_ref |= 1;
12920         }
12921         return ret_ref;
12922 }
12923
12924 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
12925         if ((this_ptr & 1) != 0) return;
12926         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
12927         FREE((void*)this_ptr);
12928         Persist_free(this_ptr_conv);
12929 }
12930
12931 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
12932         LDKu8slice ser_ref;
12933         ser_ref.datalen = *((uint32_t*)ser);
12934         ser_ref.data = (int8_t*)(ser + 4);
12935         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
12936         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
12937         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
12938         return (uint64_t)ret_conv;
12939 }
12940
12941 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
12942         LDKOutPoint this_obj_conv;
12943         this_obj_conv.inner = (void*)(this_obj & (~1));
12944         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12945         OutPoint_free(this_obj_conv);
12946 }
12947
12948 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
12949         LDKOutPoint this_ptr_conv;
12950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12951         this_ptr_conv.is_owned = false;
12952         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12953         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
12954         return ret_arr;
12955 }
12956
12957 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
12958         LDKOutPoint this_ptr_conv;
12959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12960         this_ptr_conv.is_owned = false;
12961         LDKThirtyTwoBytes val_ref;
12962         CHECK(*((uint32_t*)val) == 32);
12963         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12964         OutPoint_set_txid(&this_ptr_conv, val_ref);
12965 }
12966
12967 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
12968         LDKOutPoint this_ptr_conv;
12969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12970         this_ptr_conv.is_owned = false;
12971         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
12972         return ret_val;
12973 }
12974
12975 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
12976         LDKOutPoint this_ptr_conv;
12977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12978         this_ptr_conv.is_owned = false;
12979         OutPoint_set_index(&this_ptr_conv, val);
12980 }
12981
12982 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
12983         LDKThirtyTwoBytes txid_arg_ref;
12984         CHECK(*((uint32_t*)txid_arg) == 32);
12985         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
12986         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
12987         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12988         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12989         uint64_t ret_ref = (uint64_t)ret_var.inner;
12990         if (ret_var.is_owned) {
12991                 ret_ref |= 1;
12992         }
12993         return ret_ref;
12994 }
12995
12996 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
12997         LDKOutPoint orig_conv;
12998         orig_conv.inner = (void*)(orig & (~1));
12999         orig_conv.is_owned = false;
13000         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
13001         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13002         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13003         uint64_t ret_ref = (uint64_t)ret_var.inner;
13004         if (ret_var.is_owned) {
13005                 ret_ref |= 1;
13006         }
13007         return ret_ref;
13008 }
13009
13010 jboolean  __attribute__((visibility("default"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
13011         LDKOutPoint a_conv;
13012         a_conv.inner = (void*)(a & (~1));
13013         a_conv.is_owned = false;
13014         LDKOutPoint b_conv;
13015         b_conv.inner = (void*)(b & (~1));
13016         b_conv.is_owned = false;
13017         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
13018         return ret_val;
13019 }
13020
13021 int64_t  __attribute__((visibility("default"))) TS_OutPoint_hash(uint32_t o) {
13022         LDKOutPoint o_conv;
13023         o_conv.inner = (void*)(o & (~1));
13024         o_conv.is_owned = false;
13025         int64_t ret_val = OutPoint_hash(&o_conv);
13026         return ret_val;
13027 }
13028
13029 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
13030         LDKOutPoint this_arg_conv;
13031         this_arg_conv.inner = (void*)(this_arg & (~1));
13032         this_arg_conv.is_owned = false;
13033         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13034         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
13035         return ret_arr;
13036 }
13037
13038 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
13039         LDKOutPoint obj_conv;
13040         obj_conv.inner = (void*)(obj & (~1));
13041         obj_conv.is_owned = false;
13042         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
13043         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13044         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13045         CVec_u8Z_free(ret_var);
13046         return ret_arr;
13047 }
13048
13049 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
13050         LDKu8slice ser_ref;
13051         ser_ref.datalen = *((uint32_t*)ser);
13052         ser_ref.data = (int8_t*)(ser + 4);
13053         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
13054         *ret_conv = OutPoint_read(ser_ref);
13055         return (uint64_t)ret_conv;
13056 }
13057
13058 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
13059         LDKDelayedPaymentOutputDescriptor this_obj_conv;
13060         this_obj_conv.inner = (void*)(this_obj & (~1));
13061         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13062         DelayedPaymentOutputDescriptor_free(this_obj_conv);
13063 }
13064
13065 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
13066         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13068         this_ptr_conv.is_owned = false;
13069         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
13070         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13071         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13072         uint64_t ret_ref = (uint64_t)ret_var.inner;
13073         if (ret_var.is_owned) {
13074                 ret_ref |= 1;
13075         }
13076         return ret_ref;
13077 }
13078
13079 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
13080         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13082         this_ptr_conv.is_owned = false;
13083         LDKOutPoint val_conv;
13084         val_conv.inner = (void*)(val & (~1));
13085         val_conv.is_owned = (val & 1) || (val == 0);
13086         val_conv = OutPoint_clone(&val_conv);
13087         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
13088 }
13089
13090 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
13091         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13093         this_ptr_conv.is_owned = false;
13094         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13095         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
13096         return ret_arr;
13097 }
13098
13099 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
13100         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13102         this_ptr_conv.is_owned = false;
13103         LDKPublicKey val_ref;
13104         CHECK(*((uint32_t*)val) == 33);
13105         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13106         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
13107 }
13108
13109 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
13110         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13112         this_ptr_conv.is_owned = false;
13113         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
13114         return ret_val;
13115 }
13116
13117 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
13118         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13120         this_ptr_conv.is_owned = false;
13121         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
13122 }
13123
13124 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
13125         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13127         this_ptr_conv.is_owned = false;
13128         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
13129         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
13130 }
13131
13132 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
13133         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13135         this_ptr_conv.is_owned = false;
13136         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13137         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
13138         return ret_arr;
13139 }
13140
13141 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
13142         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13144         this_ptr_conv.is_owned = false;
13145         LDKPublicKey val_ref;
13146         CHECK(*((uint32_t*)val) == 33);
13147         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13148         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
13149 }
13150
13151 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
13152         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13154         this_ptr_conv.is_owned = false;
13155         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13156         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
13157         return ret_arr;
13158 }
13159
13160 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
13161         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13163         this_ptr_conv.is_owned = false;
13164         LDKThirtyTwoBytes val_ref;
13165         CHECK(*((uint32_t*)val) == 32);
13166         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13167         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
13168 }
13169
13170 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
13171         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13173         this_ptr_conv.is_owned = false;
13174         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
13175         return ret_val;
13176 }
13177
13178 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
13179         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
13180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13181         this_ptr_conv.is_owned = false;
13182         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
13183 }
13184
13185 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) {
13186         LDKOutPoint outpoint_arg_conv;
13187         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
13188         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
13189         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
13190         LDKPublicKey per_commitment_point_arg_ref;
13191         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
13192         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
13193         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
13194         LDKPublicKey revocation_pubkey_arg_ref;
13195         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
13196         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
13197         LDKThirtyTwoBytes channel_keys_id_arg_ref;
13198         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
13199         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
13200         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);
13201         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13202         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13203         uint64_t ret_ref = (uint64_t)ret_var.inner;
13204         if (ret_var.is_owned) {
13205                 ret_ref |= 1;
13206         }
13207         return ret_ref;
13208 }
13209
13210 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
13211         LDKDelayedPaymentOutputDescriptor orig_conv;
13212         orig_conv.inner = (void*)(orig & (~1));
13213         orig_conv.is_owned = false;
13214         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
13215         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13216         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13217         uint64_t ret_ref = (uint64_t)ret_var.inner;
13218         if (ret_var.is_owned) {
13219                 ret_ref |= 1;
13220         }
13221         return ret_ref;
13222 }
13223
13224 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
13225         LDKDelayedPaymentOutputDescriptor obj_conv;
13226         obj_conv.inner = (void*)(obj & (~1));
13227         obj_conv.is_owned = false;
13228         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
13229         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13230         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13231         CVec_u8Z_free(ret_var);
13232         return ret_arr;
13233 }
13234
13235 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
13236         LDKu8slice ser_ref;
13237         ser_ref.datalen = *((uint32_t*)ser);
13238         ser_ref.data = (int8_t*)(ser + 4);
13239         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13240         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
13241         return (uint64_t)ret_conv;
13242 }
13243
13244 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
13245         LDKStaticPaymentOutputDescriptor this_obj_conv;
13246         this_obj_conv.inner = (void*)(this_obj & (~1));
13247         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13248         StaticPaymentOutputDescriptor_free(this_obj_conv);
13249 }
13250
13251 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
13252         LDKStaticPaymentOutputDescriptor this_ptr_conv;
13253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13254         this_ptr_conv.is_owned = false;
13255         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
13256         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13257         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13258         uint64_t ret_ref = (uint64_t)ret_var.inner;
13259         if (ret_var.is_owned) {
13260                 ret_ref |= 1;
13261         }
13262         return ret_ref;
13263 }
13264
13265 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
13266         LDKStaticPaymentOutputDescriptor this_ptr_conv;
13267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13268         this_ptr_conv.is_owned = false;
13269         LDKOutPoint val_conv;
13270         val_conv.inner = (void*)(val & (~1));
13271         val_conv.is_owned = (val & 1) || (val == 0);
13272         val_conv = OutPoint_clone(&val_conv);
13273         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
13274 }
13275
13276 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
13277         LDKStaticPaymentOutputDescriptor this_ptr_conv;
13278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13279         this_ptr_conv.is_owned = false;
13280         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
13281         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
13282 }
13283
13284 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
13285         LDKStaticPaymentOutputDescriptor this_ptr_conv;
13286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13287         this_ptr_conv.is_owned = false;
13288         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13289         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
13290         return ret_arr;
13291 }
13292
13293 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
13294         LDKStaticPaymentOutputDescriptor this_ptr_conv;
13295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13296         this_ptr_conv.is_owned = false;
13297         LDKThirtyTwoBytes val_ref;
13298         CHECK(*((uint32_t*)val) == 32);
13299         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13300         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
13301 }
13302
13303 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
13304         LDKStaticPaymentOutputDescriptor this_ptr_conv;
13305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13306         this_ptr_conv.is_owned = false;
13307         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
13308         return ret_val;
13309 }
13310
13311 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
13312         LDKStaticPaymentOutputDescriptor this_ptr_conv;
13313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13314         this_ptr_conv.is_owned = false;
13315         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
13316 }
13317
13318 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) {
13319         LDKOutPoint outpoint_arg_conv;
13320         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
13321         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
13322         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
13323         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
13324         LDKThirtyTwoBytes channel_keys_id_arg_ref;
13325         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
13326         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
13327         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
13328         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13329         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13330         uint64_t ret_ref = (uint64_t)ret_var.inner;
13331         if (ret_var.is_owned) {
13332                 ret_ref |= 1;
13333         }
13334         return ret_ref;
13335 }
13336
13337 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
13338         LDKStaticPaymentOutputDescriptor orig_conv;
13339         orig_conv.inner = (void*)(orig & (~1));
13340         orig_conv.is_owned = false;
13341         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
13342         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13343         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13344         uint64_t ret_ref = (uint64_t)ret_var.inner;
13345         if (ret_var.is_owned) {
13346                 ret_ref |= 1;
13347         }
13348         return ret_ref;
13349 }
13350
13351 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
13352         LDKStaticPaymentOutputDescriptor obj_conv;
13353         obj_conv.inner = (void*)(obj & (~1));
13354         obj_conv.is_owned = false;
13355         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
13356         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13357         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13358         CVec_u8Z_free(ret_var);
13359         return ret_arr;
13360 }
13361
13362 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
13363         LDKu8slice ser_ref;
13364         ser_ref.datalen = *((uint32_t*)ser);
13365         ser_ref.data = (int8_t*)(ser + 4);
13366         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13367         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
13368         return (uint64_t)ret_conv;
13369 }
13370
13371 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
13372         if ((this_ptr & 1) != 0) return;
13373         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
13374         FREE((void*)this_ptr);
13375         SpendableOutputDescriptor_free(this_ptr_conv);
13376 }
13377
13378 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
13379         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
13380         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
13381         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
13382         uint64_t ret_ref = (uint64_t)ret_copy;
13383         return ret_ref;
13384 }
13385
13386 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
13387         LDKOutPoint outpoint_conv;
13388         outpoint_conv.inner = (void*)(outpoint & (~1));
13389         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
13390         outpoint_conv = OutPoint_clone(&outpoint_conv);
13391         LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
13392         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
13393         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
13394         uint64_t ret_ref = (uint64_t)ret_copy;
13395         return ret_ref;
13396 }
13397
13398 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
13399         LDKDelayedPaymentOutputDescriptor a_conv;
13400         a_conv.inner = (void*)(a & (~1));
13401         a_conv.is_owned = (a & 1) || (a == 0);
13402         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
13403         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
13404         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
13405         uint64_t ret_ref = (uint64_t)ret_copy;
13406         return ret_ref;
13407 }
13408
13409 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
13410         LDKStaticPaymentOutputDescriptor a_conv;
13411         a_conv.inner = (void*)(a & (~1));
13412         a_conv.is_owned = (a & 1) || (a == 0);
13413         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
13414         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
13415         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
13416         uint64_t ret_ref = (uint64_t)ret_copy;
13417         return ret_ref;
13418 }
13419
13420 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
13421         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
13422         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
13423         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13424         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13425         CVec_u8Z_free(ret_var);
13426         return ret_arr;
13427 }
13428
13429 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
13430         LDKu8slice ser_ref;
13431         ser_ref.datalen = *((uint32_t*)ser);
13432         ser_ref.data = (int8_t*)(ser + 4);
13433         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13434         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
13435         return (uint64_t)ret_conv;
13436 }
13437
13438 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
13439         if ((this_ptr & 1) != 0) return;
13440         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
13441         FREE((void*)this_ptr);
13442         BaseSign_free(this_ptr_conv);
13443 }
13444
13445 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
13446         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
13447         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
13448         *ret = Sign_clone(orig_conv);
13449         return (uint64_t)ret;
13450 }
13451
13452 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
13453         if ((this_ptr & 1) != 0) return;
13454         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
13455         FREE((void*)this_ptr);
13456         Sign_free(this_ptr_conv);
13457 }
13458
13459 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
13460         if ((this_ptr & 1) != 0) return;
13461         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
13462         FREE((void*)this_ptr);
13463         KeysInterface_free(this_ptr_conv);
13464 }
13465
13466 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
13467         LDKInMemorySigner this_obj_conv;
13468         this_obj_conv.inner = (void*)(this_obj & (~1));
13469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13470         InMemorySigner_free(this_obj_conv);
13471 }
13472
13473 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
13474         LDKInMemorySigner this_ptr_conv;
13475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13476         this_ptr_conv.is_owned = false;
13477         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13478         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
13479         return ret_arr;
13480 }
13481
13482 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
13483         LDKInMemorySigner this_ptr_conv;
13484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13485         this_ptr_conv.is_owned = false;
13486         LDKSecretKey val_ref;
13487         CHECK(*((uint32_t*)val) == 32);
13488         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
13489         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
13490 }
13491
13492 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
13493         LDKInMemorySigner this_ptr_conv;
13494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13495         this_ptr_conv.is_owned = false;
13496         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13497         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
13498         return ret_arr;
13499 }
13500
13501 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
13502         LDKInMemorySigner this_ptr_conv;
13503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13504         this_ptr_conv.is_owned = false;
13505         LDKSecretKey val_ref;
13506         CHECK(*((uint32_t*)val) == 32);
13507         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
13508         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
13509 }
13510
13511 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
13512         LDKInMemorySigner this_ptr_conv;
13513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13514         this_ptr_conv.is_owned = false;
13515         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13516         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
13517         return ret_arr;
13518 }
13519
13520 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
13521         LDKInMemorySigner this_ptr_conv;
13522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13523         this_ptr_conv.is_owned = false;
13524         LDKSecretKey val_ref;
13525         CHECK(*((uint32_t*)val) == 32);
13526         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
13527         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
13528 }
13529
13530 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
13531         LDKInMemorySigner this_ptr_conv;
13532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13533         this_ptr_conv.is_owned = false;
13534         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13535         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
13536         return ret_arr;
13537 }
13538
13539 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
13540         LDKInMemorySigner this_ptr_conv;
13541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13542         this_ptr_conv.is_owned = false;
13543         LDKSecretKey val_ref;
13544         CHECK(*((uint32_t*)val) == 32);
13545         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
13546         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
13547 }
13548
13549 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
13550         LDKInMemorySigner this_ptr_conv;
13551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13552         this_ptr_conv.is_owned = false;
13553         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13554         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
13555         return ret_arr;
13556 }
13557
13558 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
13559         LDKInMemorySigner this_ptr_conv;
13560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13561         this_ptr_conv.is_owned = false;
13562         LDKSecretKey val_ref;
13563         CHECK(*((uint32_t*)val) == 32);
13564         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
13565         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
13566 }
13567
13568 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
13569         LDKInMemorySigner this_ptr_conv;
13570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13571         this_ptr_conv.is_owned = false;
13572         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13573         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
13574         return ret_arr;
13575 }
13576
13577 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
13578         LDKInMemorySigner this_ptr_conv;
13579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13580         this_ptr_conv.is_owned = false;
13581         LDKThirtyTwoBytes val_ref;
13582         CHECK(*((uint32_t*)val) == 32);
13583         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13584         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
13585 }
13586
13587 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
13588         LDKInMemorySigner orig_conv;
13589         orig_conv.inner = (void*)(orig & (~1));
13590         orig_conv.is_owned = false;
13591         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
13592         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13593         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13594         uint64_t ret_ref = (uint64_t)ret_var.inner;
13595         if (ret_var.is_owned) {
13596                 ret_ref |= 1;
13597         }
13598         return ret_ref;
13599 }
13600
13601 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) {
13602         LDKSecretKey funding_key_ref;
13603         CHECK(*((uint32_t*)funding_key) == 32);
13604         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
13605         LDKSecretKey revocation_base_key_ref;
13606         CHECK(*((uint32_t*)revocation_base_key) == 32);
13607         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
13608         LDKSecretKey payment_key_ref;
13609         CHECK(*((uint32_t*)payment_key) == 32);
13610         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
13611         LDKSecretKey delayed_payment_base_key_ref;
13612         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
13613         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
13614         LDKSecretKey htlc_base_key_ref;
13615         CHECK(*((uint32_t*)htlc_base_key) == 32);
13616         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
13617         LDKThirtyTwoBytes commitment_seed_ref;
13618         CHECK(*((uint32_t*)commitment_seed) == 32);
13619         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
13620         LDKThirtyTwoBytes channel_keys_id_ref;
13621         CHECK(*((uint32_t*)channel_keys_id) == 32);
13622         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
13623         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);
13624         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13625         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13626         uint64_t ret_ref = (uint64_t)ret_var.inner;
13627         if (ret_var.is_owned) {
13628                 ret_ref |= 1;
13629         }
13630         return ret_ref;
13631 }
13632
13633 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
13634         LDKInMemorySigner this_arg_conv;
13635         this_arg_conv.inner = (void*)(this_arg & (~1));
13636         this_arg_conv.is_owned = false;
13637         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
13638         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13639         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13640         uint64_t ret_ref = (uint64_t)ret_var.inner;
13641         if (ret_var.is_owned) {
13642                 ret_ref |= 1;
13643         }
13644         return ret_ref;
13645 }
13646
13647 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
13648         LDKInMemorySigner this_arg_conv;
13649         this_arg_conv.inner = (void*)(this_arg & (~1));
13650         this_arg_conv.is_owned = false;
13651         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
13652         return ret_val;
13653 }
13654
13655 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
13656         LDKInMemorySigner this_arg_conv;
13657         this_arg_conv.inner = (void*)(this_arg & (~1));
13658         this_arg_conv.is_owned = false;
13659         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
13660         return ret_val;
13661 }
13662
13663 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
13664         LDKInMemorySigner this_arg_conv;
13665         this_arg_conv.inner = (void*)(this_arg & (~1));
13666         this_arg_conv.is_owned = false;
13667         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
13668         return ret_val;
13669 }
13670
13671 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
13672         LDKInMemorySigner this_arg_conv;
13673         this_arg_conv.inner = (void*)(this_arg & (~1));
13674         this_arg_conv.is_owned = false;
13675         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
13676         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13677         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13678         uint64_t ret_ref = (uint64_t)ret_var.inner;
13679         if (ret_var.is_owned) {
13680                 ret_ref |= 1;
13681         }
13682         return ret_ref;
13683 }
13684
13685 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
13686         LDKInMemorySigner this_arg_conv;
13687         this_arg_conv.inner = (void*)(this_arg & (~1));
13688         this_arg_conv.is_owned = false;
13689         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
13690         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13691         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13692         uint64_t ret_ref = (uint64_t)ret_var.inner;
13693         if (ret_var.is_owned) {
13694                 ret_ref |= 1;
13695         }
13696         return ret_ref;
13697 }
13698
13699 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) {
13700         LDKInMemorySigner this_arg_conv;
13701         this_arg_conv.inner = (void*)(this_arg & (~1));
13702         this_arg_conv.is_owned = false;
13703         LDKTransaction spend_tx_ref;
13704         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
13705         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
13706         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
13707         spend_tx_ref.data_is_owned = true;
13708         LDKStaticPaymentOutputDescriptor descriptor_conv;
13709         descriptor_conv.inner = (void*)(descriptor & (~1));
13710         descriptor_conv.is_owned = false;
13711         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13712         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
13713         return (uint64_t)ret_conv;
13714 }
13715
13716 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) {
13717         LDKInMemorySigner this_arg_conv;
13718         this_arg_conv.inner = (void*)(this_arg & (~1));
13719         this_arg_conv.is_owned = false;
13720         LDKTransaction spend_tx_ref;
13721         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
13722         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
13723         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
13724         spend_tx_ref.data_is_owned = true;
13725         LDKDelayedPaymentOutputDescriptor descriptor_conv;
13726         descriptor_conv.inner = (void*)(descriptor & (~1));
13727         descriptor_conv.is_owned = false;
13728         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13729         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
13730         return (uint64_t)ret_conv;
13731 }
13732
13733 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
13734         LDKInMemorySigner this_arg_conv;
13735         this_arg_conv.inner = (void*)(this_arg & (~1));
13736         this_arg_conv.is_owned = false;
13737         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
13738         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
13739         return (uint64_t)ret;
13740 }
13741
13742 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
13743         LDKInMemorySigner this_arg_conv;
13744         this_arg_conv.inner = (void*)(this_arg & (~1));
13745         this_arg_conv.is_owned = false;
13746         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
13747         *ret = InMemorySigner_as_Sign(&this_arg_conv);
13748         return (uint64_t)ret;
13749 }
13750
13751 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
13752         LDKInMemorySigner obj_conv;
13753         obj_conv.inner = (void*)(obj & (~1));
13754         obj_conv.is_owned = false;
13755         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
13756         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13757         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13758         CVec_u8Z_free(ret_var);
13759         return ret_arr;
13760 }
13761
13762 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
13763         LDKu8slice ser_ref;
13764         ser_ref.datalen = *((uint32_t*)ser);
13765         ser_ref.data = (int8_t*)(ser + 4);
13766         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13767         *ret_conv = InMemorySigner_read(ser_ref);
13768         return (uint64_t)ret_conv;
13769 }
13770
13771 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
13772         LDKKeysManager this_obj_conv;
13773         this_obj_conv.inner = (void*)(this_obj & (~1));
13774         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13775         KeysManager_free(this_obj_conv);
13776 }
13777
13778 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
13779         unsigned char seed_arr[32];
13780         CHECK(*((uint32_t*)seed) == 32);
13781         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
13782         unsigned char (*seed_ref)[32] = &seed_arr;
13783         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
13784         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13785         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13786         uint64_t ret_ref = (uint64_t)ret_var.inner;
13787         if (ret_var.is_owned) {
13788                 ret_ref |= 1;
13789         }
13790         return ret_ref;
13791 }
13792
13793 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
13794         LDKKeysManager this_arg_conv;
13795         this_arg_conv.inner = (void*)(this_arg & (~1));
13796         this_arg_conv.is_owned = false;
13797         unsigned char params_arr[32];
13798         CHECK(*((uint32_t*)params) == 32);
13799         memcpy(params_arr, (uint8_t*)(params + 4), 32);
13800         unsigned char (*params_ref)[32] = &params_arr;
13801         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
13802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13804         uint64_t ret_ref = (uint64_t)ret_var.inner;
13805         if (ret_var.is_owned) {
13806                 ret_ref |= 1;
13807         }
13808         return ret_ref;
13809 }
13810
13811 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) {
13812         LDKKeysManager this_arg_conv;
13813         this_arg_conv.inner = (void*)(this_arg & (~1));
13814         this_arg_conv.is_owned = false;
13815         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
13816         descriptors_constr.datalen = *((uint32_t*)descriptors);
13817         if (descriptors_constr.datalen > 0)
13818                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
13819         else
13820                 descriptors_constr.data = NULL;
13821         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
13822         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
13823                 uint32_t descriptors_conv_27 = descriptors_vals[b];
13824                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
13825                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
13826                 descriptors_constr.data[b] = descriptors_conv_27_conv;
13827         }
13828         LDKCVec_TxOutZ outputs_constr;
13829         outputs_constr.datalen = *((uint32_t*)outputs);
13830         if (outputs_constr.datalen > 0)
13831                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
13832         else
13833                 outputs_constr.data = NULL;
13834         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
13835         for (size_t h = 0; h < outputs_constr.datalen; h++) {
13836                 uint32_t outputs_conv_7 = outputs_vals[h];
13837                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
13838                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
13839                 outputs_constr.data[h] = outputs_conv_7_conv;
13840         }
13841         LDKCVec_u8Z change_destination_script_ref;
13842         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
13843         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
13844         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
13845         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13846         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
13847         return (uint64_t)ret_conv;
13848 }
13849
13850 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
13851         LDKKeysManager this_arg_conv;
13852         this_arg_conv.inner = (void*)(this_arg & (~1));
13853         this_arg_conv.is_owned = false;
13854         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
13855         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
13856         return (uint64_t)ret;
13857 }
13858
13859 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
13860         LDKChannelManager this_obj_conv;
13861         this_obj_conv.inner = (void*)(this_obj & (~1));
13862         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13863         ChannelManager_free(this_obj_conv);
13864 }
13865
13866 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
13867         LDKChainParameters this_obj_conv;
13868         this_obj_conv.inner = (void*)(this_obj & (~1));
13869         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13870         ChainParameters_free(this_obj_conv);
13871 }
13872
13873 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
13874         LDKChainParameters this_ptr_conv;
13875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13876         this_ptr_conv.is_owned = false;
13877         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
13878         return ret_conv;
13879 }
13880
13881 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
13882         LDKChainParameters this_ptr_conv;
13883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13884         this_ptr_conv.is_owned = false;
13885         LDKNetwork val_conv = LDKNetwork_from_js(val);
13886         ChainParameters_set_network(&this_ptr_conv, val_conv);
13887 }
13888
13889 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
13890         LDKChainParameters this_ptr_conv;
13891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13892         this_ptr_conv.is_owned = false;
13893         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
13894         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13895         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13896         uint64_t ret_ref = (uint64_t)ret_var.inner;
13897         if (ret_var.is_owned) {
13898                 ret_ref |= 1;
13899         }
13900         return ret_ref;
13901 }
13902
13903 void  __attribute__((visibility("default"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
13904         LDKChainParameters this_ptr_conv;
13905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13906         this_ptr_conv.is_owned = false;
13907         LDKBestBlock val_conv;
13908         val_conv.inner = (void*)(val & (~1));
13909         val_conv.is_owned = (val & 1) || (val == 0);
13910         val_conv = BestBlock_clone(&val_conv);
13911         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
13912 }
13913
13914 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
13915         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
13916         LDKBestBlock best_block_arg_conv;
13917         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
13918         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
13919         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
13920         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
13921         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13922         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13923         uint64_t ret_ref = (uint64_t)ret_var.inner;
13924         if (ret_var.is_owned) {
13925                 ret_ref |= 1;
13926         }
13927         return ret_ref;
13928 }
13929
13930 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32_t orig) {
13931         LDKChainParameters orig_conv;
13932         orig_conv.inner = (void*)(orig & (~1));
13933         orig_conv.is_owned = false;
13934         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
13935         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13936         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13937         uint64_t ret_ref = (uint64_t)ret_var.inner;
13938         if (ret_var.is_owned) {
13939                 ret_ref |= 1;
13940         }
13941         return ret_ref;
13942 }
13943
13944 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
13945         LDKChannelCounterparty this_obj_conv;
13946         this_obj_conv.inner = (void*)(this_obj & (~1));
13947         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13948         ChannelCounterparty_free(this_obj_conv);
13949 }
13950
13951 int8_tArray  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
13952         LDKChannelCounterparty this_ptr_conv;
13953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13954         this_ptr_conv.is_owned = false;
13955         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13956         memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
13957         return ret_arr;
13958 }
13959
13960 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
13961         LDKChannelCounterparty this_ptr_conv;
13962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13963         this_ptr_conv.is_owned = false;
13964         LDKPublicKey val_ref;
13965         CHECK(*((uint32_t*)val) == 33);
13966         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13967         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
13968 }
13969
13970 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
13971         LDKChannelCounterparty this_ptr_conv;
13972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13973         this_ptr_conv.is_owned = false;
13974         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
13975         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13976         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13977         uint64_t ret_ref = (uint64_t)ret_var.inner;
13978         if (ret_var.is_owned) {
13979                 ret_ref |= 1;
13980         }
13981         return ret_ref;
13982 }
13983
13984 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
13985         LDKChannelCounterparty this_ptr_conv;
13986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13987         this_ptr_conv.is_owned = false;
13988         LDKInitFeatures val_conv;
13989         val_conv.inner = (void*)(val & (~1));
13990         val_conv.is_owned = (val & 1) || (val == 0);
13991         val_conv = InitFeatures_clone(&val_conv);
13992         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
13993 }
13994
13995 int64_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
13996         LDKChannelCounterparty this_ptr_conv;
13997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13998         this_ptr_conv.is_owned = false;
13999         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
14000         return ret_val;
14001 }
14002
14003 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
14004         LDKChannelCounterparty this_ptr_conv;
14005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14006         this_ptr_conv.is_owned = false;
14007         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
14008 }
14009
14010 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(uint32_t orig) {
14011         LDKChannelCounterparty orig_conv;
14012         orig_conv.inner = (void*)(orig & (~1));
14013         orig_conv.is_owned = false;
14014         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
14015         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14016         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14017         uint64_t ret_ref = (uint64_t)ret_var.inner;
14018         if (ret_var.is_owned) {
14019                 ret_ref |= 1;
14020         }
14021         return ret_ref;
14022 }
14023
14024 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
14025         LDKChannelDetails this_obj_conv;
14026         this_obj_conv.inner = (void*)(this_obj & (~1));
14027         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14028         ChannelDetails_free(this_obj_conv);
14029 }
14030
14031 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
14032         LDKChannelDetails this_ptr_conv;
14033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14034         this_ptr_conv.is_owned = false;
14035         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14036         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
14037         return ret_arr;
14038 }
14039
14040 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14041         LDKChannelDetails this_ptr_conv;
14042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14043         this_ptr_conv.is_owned = false;
14044         LDKThirtyTwoBytes val_ref;
14045         CHECK(*((uint32_t*)val) == 32);
14046         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14047         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
14048 }
14049
14050 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
14051         LDKChannelDetails this_ptr_conv;
14052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14053         this_ptr_conv.is_owned = false;
14054         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
14055         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14056         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14057         uint64_t ret_ref = (uint64_t)ret_var.inner;
14058         if (ret_var.is_owned) {
14059                 ret_ref |= 1;
14060         }
14061         return ret_ref;
14062 }
14063
14064 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
14065         LDKChannelDetails this_ptr_conv;
14066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14067         this_ptr_conv.is_owned = false;
14068         LDKChannelCounterparty val_conv;
14069         val_conv.inner = (void*)(val & (~1));
14070         val_conv.is_owned = (val & 1) || (val == 0);
14071         val_conv = ChannelCounterparty_clone(&val_conv);
14072         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
14073 }
14074
14075 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
14076         LDKChannelDetails this_ptr_conv;
14077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14078         this_ptr_conv.is_owned = false;
14079         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
14080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14082         uint64_t ret_ref = (uint64_t)ret_var.inner;
14083         if (ret_var.is_owned) {
14084                 ret_ref |= 1;
14085         }
14086         return ret_ref;
14087 }
14088
14089 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
14090         LDKChannelDetails this_ptr_conv;
14091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14092         this_ptr_conv.is_owned = false;
14093         LDKOutPoint val_conv;
14094         val_conv.inner = (void*)(val & (~1));
14095         val_conv.is_owned = (val & 1) || (val == 0);
14096         val_conv = OutPoint_clone(&val_conv);
14097         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
14098 }
14099
14100 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
14101         LDKChannelDetails this_ptr_conv;
14102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14103         this_ptr_conv.is_owned = false;
14104         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14105         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
14106         uint64_t ret_ref = (uint64_t)ret_copy;
14107         return ret_ref;
14108 }
14109
14110 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
14111         LDKChannelDetails this_ptr_conv;
14112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14113         this_ptr_conv.is_owned = false;
14114         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
14115         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
14116 }
14117
14118 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
14119         LDKChannelDetails this_ptr_conv;
14120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14121         this_ptr_conv.is_owned = false;
14122         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
14123         return ret_val;
14124 }
14125
14126 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
14127         LDKChannelDetails this_ptr_conv;
14128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14129         this_ptr_conv.is_owned = false;
14130         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
14131 }
14132
14133 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
14134         LDKChannelDetails this_ptr_conv;
14135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14136         this_ptr_conv.is_owned = false;
14137         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14138         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
14139         uint64_t ret_ref = (uint64_t)ret_copy;
14140         return ret_ref;
14141 }
14142
14143 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
14144         LDKChannelDetails this_ptr_conv;
14145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14146         this_ptr_conv.is_owned = false;
14147         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
14148         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
14149 }
14150
14151 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
14152         LDKChannelDetails this_ptr_conv;
14153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14154         this_ptr_conv.is_owned = false;
14155         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
14156         return ret_val;
14157 }
14158
14159 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
14160         LDKChannelDetails this_ptr_conv;
14161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14162         this_ptr_conv.is_owned = false;
14163         ChannelDetails_set_user_id(&this_ptr_conv, val);
14164 }
14165
14166 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
14167         LDKChannelDetails this_ptr_conv;
14168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14169         this_ptr_conv.is_owned = false;
14170         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
14171         return ret_val;
14172 }
14173
14174 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
14175         LDKChannelDetails this_ptr_conv;
14176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14177         this_ptr_conv.is_owned = false;
14178         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
14179 }
14180
14181 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
14182         LDKChannelDetails this_ptr_conv;
14183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14184         this_ptr_conv.is_owned = false;
14185         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
14186         return ret_val;
14187 }
14188
14189 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
14190         LDKChannelDetails this_ptr_conv;
14191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14192         this_ptr_conv.is_owned = false;
14193         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
14194 }
14195
14196 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
14197         LDKChannelDetails this_ptr_conv;
14198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14199         this_ptr_conv.is_owned = false;
14200         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14201         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
14202         uint64_t ret_ref = (uint64_t)ret_copy;
14203         return ret_ref;
14204 }
14205
14206 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
14207         LDKChannelDetails this_ptr_conv;
14208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14209         this_ptr_conv.is_owned = false;
14210         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
14211         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
14212 }
14213
14214 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
14215         LDKChannelDetails this_ptr_conv;
14216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14217         this_ptr_conv.is_owned = false;
14218         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14219         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
14220         uint64_t ret_ref = (uint64_t)ret_copy;
14221         return ret_ref;
14222 }
14223
14224 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_spend_delay(uint32_t this_ptr, uint32_t val) {
14225         LDKChannelDetails this_ptr_conv;
14226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14227         this_ptr_conv.is_owned = false;
14228         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
14229         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
14230 }
14231
14232 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
14233         LDKChannelDetails this_ptr_conv;
14234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14235         this_ptr_conv.is_owned = false;
14236         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
14237         return ret_val;
14238 }
14239
14240 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
14241         LDKChannelDetails this_ptr_conv;
14242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14243         this_ptr_conv.is_owned = false;
14244         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
14245 }
14246
14247 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
14248         LDKChannelDetails this_ptr_conv;
14249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14250         this_ptr_conv.is_owned = false;
14251         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
14252         return ret_val;
14253 }
14254
14255 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
14256         LDKChannelDetails this_ptr_conv;
14257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14258         this_ptr_conv.is_owned = false;
14259         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
14260 }
14261
14262 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
14263         LDKChannelDetails this_ptr_conv;
14264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14265         this_ptr_conv.is_owned = false;
14266         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
14267         return ret_val;
14268 }
14269
14270 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
14271         LDKChannelDetails this_ptr_conv;
14272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14273         this_ptr_conv.is_owned = false;
14274         ChannelDetails_set_is_usable(&this_ptr_conv, val);
14275 }
14276
14277 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
14278         LDKChannelDetails this_ptr_conv;
14279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14280         this_ptr_conv.is_owned = false;
14281         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
14282         return ret_val;
14283 }
14284
14285 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
14286         LDKChannelDetails this_ptr_conv;
14287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14288         this_ptr_conv.is_owned = false;
14289         ChannelDetails_set_is_public(&this_ptr_conv, val);
14290 }
14291
14292 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint32_t counterparty_arg, uint32_t funding_txo_arg, uint32_t short_channel_id_arg, int64_t channel_value_satoshis_arg, uint32_t unspendable_punishment_reserve_arg, int64_t user_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, uint32_t confirmations_required_arg, uint32_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
14293         LDKThirtyTwoBytes channel_id_arg_ref;
14294         CHECK(*((uint32_t*)channel_id_arg) == 32);
14295         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
14296         LDKChannelCounterparty counterparty_arg_conv;
14297         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
14298         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
14299         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
14300         LDKOutPoint funding_txo_arg_conv;
14301         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
14302         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
14303         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
14304         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
14305         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
14306         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
14307         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
14308         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
14309         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14310         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14311         uint64_t ret_ref = (uint64_t)ret_var.inner;
14312         if (ret_var.is_owned) {
14313                 ret_ref |= 1;
14314         }
14315         return ret_ref;
14316 }
14317
14318 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
14319         LDKChannelDetails orig_conv;
14320         orig_conv.inner = (void*)(orig & (~1));
14321         orig_conv.is_owned = false;
14322         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
14323         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14324         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14325         uint64_t ret_ref = (uint64_t)ret_var.inner;
14326         if (ret_var.is_owned) {
14327                 ret_ref |= 1;
14328         }
14329         return ret_ref;
14330 }
14331
14332 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
14333         if ((this_ptr & 1) != 0) return;
14334         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
14335         FREE((void*)this_ptr);
14336         PaymentSendFailure_free(this_ptr_conv);
14337 }
14338
14339 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
14340         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
14341         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
14342         *ret_copy = PaymentSendFailure_clone(orig_conv);
14343         uint64_t ret_ref = (uint64_t)ret_copy;
14344         return ret_ref;
14345 }
14346
14347 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
14348         LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1);
14349         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
14350         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
14351         uint64_t ret_ref = (uint64_t)ret_copy;
14352         return ret_ref;
14353 }
14354
14355 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
14356         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
14357         a_constr.datalen = *((uint32_t*)a);
14358         if (a_constr.datalen > 0)
14359                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
14360         else
14361                 a_constr.data = NULL;
14362         uint32_t* a_vals = (uint32_t*)(a + 4);
14363         for (size_t w = 0; w < a_constr.datalen; w++) {
14364                 uint32_t a_conv_22 = a_vals[w];
14365                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
14366                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
14367                 a_constr.data[w] = a_conv_22_conv;
14368         }
14369         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
14370         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
14371         uint64_t ret_ref = (uint64_t)ret_copy;
14372         return ret_ref;
14373 }
14374
14375 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
14376         LDKCVec_APIErrorZ a_constr;
14377         a_constr.datalen = *((uint32_t*)a);
14378         if (a_constr.datalen > 0)
14379                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
14380         else
14381                 a_constr.data = NULL;
14382         uint32_t* a_vals = (uint32_t*)(a + 4);
14383         for (size_t k = 0; k < a_constr.datalen; k++) {
14384                 uint32_t a_conv_10 = a_vals[k];
14385                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
14386                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
14387                 a_constr.data[k] = a_conv_10_conv;
14388         }
14389         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
14390         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
14391         uint64_t ret_ref = (uint64_t)ret_copy;
14392         return ret_ref;
14393 }
14394
14395 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_partial_failure(uint32_tArray a) {
14396         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
14397         a_constr.datalen = *((uint32_t*)a);
14398         if (a_constr.datalen > 0)
14399                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
14400         else
14401                 a_constr.data = NULL;
14402         uint32_t* a_vals = (uint32_t*)(a + 4);
14403         for (size_t w = 0; w < a_constr.datalen; w++) {
14404                 uint32_t a_conv_22 = a_vals[w];
14405                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
14406                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
14407                 a_constr.data[w] = a_conv_22_conv;
14408         }
14409         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
14410         *ret_copy = PaymentSendFailure_partial_failure(a_constr);
14411         uint64_t ret_ref = (uint64_t)ret_copy;
14412         return ret_ref;
14413 }
14414
14415 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) {
14416         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
14417         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
14418         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
14419         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14420         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
14421         LDKUserConfig config_conv;
14422         config_conv.inner = (void*)(config & (~1));
14423         config_conv.is_owned = (config & 1) || (config == 0);
14424         config_conv = UserConfig_clone(&config_conv);
14425         LDKChainParameters params_conv;
14426         params_conv.inner = (void*)(params & (~1));
14427         params_conv.is_owned = (params & 1) || (params == 0);
14428         params_conv = ChainParameters_clone(&params_conv);
14429         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
14430         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14431         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14432         uint64_t ret_ref = (uint64_t)ret_var.inner;
14433         if (ret_var.is_owned) {
14434                 ret_ref |= 1;
14435         }
14436         return ret_ref;
14437 }
14438
14439 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
14440         LDKChannelManager this_arg_conv;
14441         this_arg_conv.inner = (void*)(this_arg & (~1));
14442         this_arg_conv.is_owned = false;
14443         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
14444         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14445         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14446         uint64_t ret_ref = (uint64_t)ret_var.inner;
14447         if (ret_var.is_owned) {
14448                 ret_ref |= 1;
14449         }
14450         return ret_ref;
14451 }
14452
14453 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_channel(uint32_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_id, uint32_t override_config) {
14454         LDKChannelManager this_arg_conv;
14455         this_arg_conv.inner = (void*)(this_arg & (~1));
14456         this_arg_conv.is_owned = false;
14457         LDKPublicKey their_network_key_ref;
14458         CHECK(*((uint32_t*)their_network_key) == 33);
14459         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
14460         LDKUserConfig override_config_conv;
14461         override_config_conv.inner = (void*)(override_config & (~1));
14462         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
14463         override_config_conv = UserConfig_clone(&override_config_conv);
14464         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14465         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
14466         return (uint64_t)ret_conv;
14467 }
14468
14469 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
14470         LDKChannelManager this_arg_conv;
14471         this_arg_conv.inner = (void*)(this_arg & (~1));
14472         this_arg_conv.is_owned = false;
14473         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
14474         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14475         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14476         for (size_t q = 0; q < ret_var.datalen; q++) {
14477                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
14478                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14479                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14480                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
14481                 if (ret_conv_16_var.is_owned) {
14482                         ret_conv_16_ref |= 1;
14483                 }
14484                 ret_arr_ptr[q] = ret_conv_16_ref;
14485         }
14486         FREE(ret_var.data);
14487         return ret_arr;
14488 }
14489
14490 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
14491         LDKChannelManager this_arg_conv;
14492         this_arg_conv.inner = (void*)(this_arg & (~1));
14493         this_arg_conv.is_owned = false;
14494         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
14495         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14496         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14497         for (size_t q = 0; q < ret_var.datalen; q++) {
14498                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
14499                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14500                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14501                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
14502                 if (ret_conv_16_var.is_owned) {
14503                         ret_conv_16_ref |= 1;
14504                 }
14505                 ret_arr_ptr[q] = ret_conv_16_ref;
14506         }
14507         FREE(ret_var.data);
14508         return ret_arr;
14509 }
14510
14511 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
14512         LDKChannelManager this_arg_conv;
14513         this_arg_conv.inner = (void*)(this_arg & (~1));
14514         this_arg_conv.is_owned = false;
14515         unsigned char channel_id_arr[32];
14516         CHECK(*((uint32_t*)channel_id) == 32);
14517         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
14518         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
14519         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14520         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
14521         return (uint64_t)ret_conv;
14522 }
14523
14524 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) {
14525         LDKChannelManager this_arg_conv;
14526         this_arg_conv.inner = (void*)(this_arg & (~1));
14527         this_arg_conv.is_owned = false;
14528         unsigned char channel_id_arr[32];
14529         CHECK(*((uint32_t*)channel_id) == 32);
14530         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
14531         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
14532         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14533         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
14534         return (uint64_t)ret_conv;
14535 }
14536
14537 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
14538         LDKChannelManager this_arg_conv;
14539         this_arg_conv.inner = (void*)(this_arg & (~1));
14540         this_arg_conv.is_owned = false;
14541         unsigned char channel_id_arr[32];
14542         CHECK(*((uint32_t*)channel_id) == 32);
14543         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
14544         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
14545         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14546         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
14547         return (uint64_t)ret_conv;
14548 }
14549
14550 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
14551         LDKChannelManager this_arg_conv;
14552         this_arg_conv.inner = (void*)(this_arg & (~1));
14553         this_arg_conv.is_owned = false;
14554         ChannelManager_force_close_all_channels(&this_arg_conv);
14555 }
14556
14557 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
14558         LDKChannelManager this_arg_conv;
14559         this_arg_conv.inner = (void*)(this_arg & (~1));
14560         this_arg_conv.is_owned = false;
14561         LDKRoute route_conv;
14562         route_conv.inner = (void*)(route & (~1));
14563         route_conv.is_owned = false;
14564         LDKThirtyTwoBytes payment_hash_ref;
14565         CHECK(*((uint32_t*)payment_hash) == 32);
14566         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
14567         LDKThirtyTwoBytes payment_secret_ref;
14568         CHECK(*((uint32_t*)payment_secret) == 32);
14569         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
14570         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14571         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
14572         return (uint64_t)ret_conv;
14573 }
14574
14575 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_spontaneous_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_preimage) {
14576         LDKChannelManager this_arg_conv;
14577         this_arg_conv.inner = (void*)(this_arg & (~1));
14578         this_arg_conv.is_owned = false;
14579         LDKRoute route_conv;
14580         route_conv.inner = (void*)(route & (~1));
14581         route_conv.is_owned = false;
14582         LDKThirtyTwoBytes payment_preimage_ref;
14583         CHECK(*((uint32_t*)payment_preimage) == 32);
14584         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
14585         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
14586         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
14587         return (uint64_t)ret_conv;
14588 }
14589
14590 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
14591         LDKChannelManager this_arg_conv;
14592         this_arg_conv.inner = (void*)(this_arg & (~1));
14593         this_arg_conv.is_owned = false;
14594         unsigned char temporary_channel_id_arr[32];
14595         CHECK(*((uint32_t*)temporary_channel_id) == 32);
14596         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
14597         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
14598         LDKTransaction funding_transaction_ref;
14599         funding_transaction_ref.datalen = *((uint32_t*)funding_transaction);
14600         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
14601         memcpy(funding_transaction_ref.data, (uint8_t*)(funding_transaction + 4), funding_transaction_ref.datalen);
14602         funding_transaction_ref.data_is_owned = true;
14603         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14604         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
14605         return (uint64_t)ret_conv;
14606 }
14607
14608 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
14609         LDKChannelManager this_arg_conv;
14610         this_arg_conv.inner = (void*)(this_arg & (~1));
14611         this_arg_conv.is_owned = false;
14612         LDKThreeBytes rgb_ref;
14613         CHECK(*((uint32_t*)rgb) == 3);
14614         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
14615         LDKThirtyTwoBytes alias_ref;
14616         CHECK(*((uint32_t*)alias) == 32);
14617         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
14618         LDKCVec_NetAddressZ addresses_constr;
14619         addresses_constr.datalen = *((uint32_t*)addresses);
14620         if (addresses_constr.datalen > 0)
14621                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14622         else
14623                 addresses_constr.data = NULL;
14624         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
14625         for (size_t m = 0; m < addresses_constr.datalen; m++) {
14626                 uint32_t addresses_conv_12 = addresses_vals[m];
14627                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
14628                 addresses_constr.data[m] = addresses_conv_12_conv;
14629         }
14630         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
14631 }
14632
14633 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
14634         LDKChannelManager this_arg_conv;
14635         this_arg_conv.inner = (void*)(this_arg & (~1));
14636         this_arg_conv.is_owned = false;
14637         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
14638 }
14639
14640 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
14641         LDKChannelManager this_arg_conv;
14642         this_arg_conv.inner = (void*)(this_arg & (~1));
14643         this_arg_conv.is_owned = false;
14644         ChannelManager_timer_tick_occurred(&this_arg_conv);
14645 }
14646
14647 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
14648         LDKChannelManager this_arg_conv;
14649         this_arg_conv.inner = (void*)(this_arg & (~1));
14650         this_arg_conv.is_owned = false;
14651         unsigned char payment_hash_arr[32];
14652         CHECK(*((uint32_t*)payment_hash) == 32);
14653         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
14654         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
14655         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
14656         return ret_val;
14657 }
14658
14659 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
14660         LDKChannelManager this_arg_conv;
14661         this_arg_conv.inner = (void*)(this_arg & (~1));
14662         this_arg_conv.is_owned = false;
14663         LDKThirtyTwoBytes payment_preimage_ref;
14664         CHECK(*((uint32_t*)payment_preimage) == 32);
14665         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
14666         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
14667         return ret_val;
14668 }
14669
14670 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
14671         LDKChannelManager this_arg_conv;
14672         this_arg_conv.inner = (void*)(this_arg & (~1));
14673         this_arg_conv.is_owned = false;
14674         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14675         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
14676         return ret_arr;
14677 }
14678
14679 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
14680         LDKChannelManager this_arg_conv;
14681         this_arg_conv.inner = (void*)(this_arg & (~1));
14682         this_arg_conv.is_owned = false;
14683         LDKOutPoint funding_txo_conv;
14684         funding_txo_conv.inner = (void*)(funding_txo & (~1));
14685         funding_txo_conv.is_owned = false;
14686         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
14687 }
14688
14689 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) {
14690         LDKChannelManager this_arg_conv;
14691         this_arg_conv.inner = (void*)(this_arg & (~1));
14692         this_arg_conv.is_owned = false;
14693         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
14694         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14695         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
14696         return (uint64_t)ret_ref;
14697 }
14698
14699 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) {
14700         LDKChannelManager this_arg_conv;
14701         this_arg_conv.inner = (void*)(this_arg & (~1));
14702         this_arg_conv.is_owned = false;
14703         LDKThirtyTwoBytes payment_hash_ref;
14704         CHECK(*((uint32_t*)payment_hash) == 32);
14705         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
14706         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
14707         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14708         *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);
14709         return (uint64_t)ret_conv;
14710 }
14711
14712 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
14713         LDKChannelManager this_arg_conv;
14714         this_arg_conv.inner = (void*)(this_arg & (~1));
14715         this_arg_conv.is_owned = false;
14716         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
14717         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
14718         return (uint64_t)ret;
14719 }
14720
14721 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
14722         LDKChannelManager this_arg_conv;
14723         this_arg_conv.inner = (void*)(this_arg & (~1));
14724         this_arg_conv.is_owned = false;
14725         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
14726         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
14727         return (uint64_t)ret;
14728 }
14729
14730 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
14731         LDKChannelManager this_arg_conv;
14732         this_arg_conv.inner = (void*)(this_arg & (~1));
14733         this_arg_conv.is_owned = false;
14734         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
14735         *ret = ChannelManager_as_Listen(&this_arg_conv);
14736         return (uint64_t)ret;
14737 }
14738
14739 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
14740         LDKChannelManager this_arg_conv;
14741         this_arg_conv.inner = (void*)(this_arg & (~1));
14742         this_arg_conv.is_owned = false;
14743         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
14744         *ret = ChannelManager_as_Confirm(&this_arg_conv);
14745         return (uint64_t)ret;
14746 }
14747
14748 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
14749         LDKChannelManager this_arg_conv;
14750         this_arg_conv.inner = (void*)(this_arg & (~1));
14751         this_arg_conv.is_owned = false;
14752         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
14753         return ret_val;
14754 }
14755
14756 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
14757         LDKChannelManager this_arg_conv;
14758         this_arg_conv.inner = (void*)(this_arg & (~1));
14759         this_arg_conv.is_owned = false;
14760         ChannelManager_await_persistable_update(&this_arg_conv);
14761 }
14762
14763 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
14764         LDKChannelManager this_arg_conv;
14765         this_arg_conv.inner = (void*)(this_arg & (~1));
14766         this_arg_conv.is_owned = false;
14767         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
14768         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14769         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14770         uint64_t ret_ref = (uint64_t)ret_var.inner;
14771         if (ret_var.is_owned) {
14772                 ret_ref |= 1;
14773         }
14774         return ret_ref;
14775 }
14776
14777 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
14778         LDKChannelManager this_arg_conv;
14779         this_arg_conv.inner = (void*)(this_arg & (~1));
14780         this_arg_conv.is_owned = false;
14781         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
14782         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
14783         return (uint64_t)ret;
14784 }
14785
14786 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
14787         LDKChannelManager obj_conv;
14788         obj_conv.inner = (void*)(obj & (~1));
14789         obj_conv.is_owned = false;
14790         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
14791         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14792         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14793         CVec_u8Z_free(ret_var);
14794         return ret_arr;
14795 }
14796
14797 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
14798         LDKChannelManagerReadArgs this_obj_conv;
14799         this_obj_conv.inner = (void*)(this_obj & (~1));
14800         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14801         ChannelManagerReadArgs_free(this_obj_conv);
14802 }
14803
14804 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
14805         LDKChannelManagerReadArgs this_ptr_conv;
14806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14807         this_ptr_conv.is_owned = false;
14808         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
14809         return ret_ret;
14810 }
14811
14812 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
14813         LDKChannelManagerReadArgs this_ptr_conv;
14814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14815         this_ptr_conv.is_owned = false;
14816         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
14817         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
14818 }
14819
14820 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
14821         LDKChannelManagerReadArgs this_ptr_conv;
14822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14823         this_ptr_conv.is_owned = false;
14824         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
14825         return ret_ret;
14826 }
14827
14828 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
14829         LDKChannelManagerReadArgs this_ptr_conv;
14830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14831         this_ptr_conv.is_owned = false;
14832         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
14833         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
14834 }
14835
14836 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
14837         LDKChannelManagerReadArgs this_ptr_conv;
14838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14839         this_ptr_conv.is_owned = false;
14840         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
14841         return ret_ret;
14842 }
14843
14844 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
14845         LDKChannelManagerReadArgs this_ptr_conv;
14846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14847         this_ptr_conv.is_owned = false;
14848         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
14849         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
14850 }
14851
14852 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
14853         LDKChannelManagerReadArgs this_ptr_conv;
14854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14855         this_ptr_conv.is_owned = false;
14856         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
14857         return ret_ret;
14858 }
14859
14860 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
14861         LDKChannelManagerReadArgs this_ptr_conv;
14862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14863         this_ptr_conv.is_owned = false;
14864         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
14865         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
14866 }
14867
14868 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
14869         LDKChannelManagerReadArgs this_ptr_conv;
14870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14871         this_ptr_conv.is_owned = false;
14872         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
14873         return ret_ret;
14874 }
14875
14876 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
14877         LDKChannelManagerReadArgs this_ptr_conv;
14878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14879         this_ptr_conv.is_owned = false;
14880         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
14881         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
14882 }
14883
14884 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
14885         LDKChannelManagerReadArgs this_ptr_conv;
14886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14887         this_ptr_conv.is_owned = false;
14888         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
14889         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14890         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14891         uint64_t ret_ref = (uint64_t)ret_var.inner;
14892         if (ret_var.is_owned) {
14893                 ret_ref |= 1;
14894         }
14895         return ret_ref;
14896 }
14897
14898 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
14899         LDKChannelManagerReadArgs this_ptr_conv;
14900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14901         this_ptr_conv.is_owned = false;
14902         LDKUserConfig val_conv;
14903         val_conv.inner = (void*)(val & (~1));
14904         val_conv.is_owned = (val & 1) || (val == 0);
14905         val_conv = UserConfig_clone(&val_conv);
14906         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
14907 }
14908
14909 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) {
14910         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
14911         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14912         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
14913         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
14914         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14915         LDKUserConfig default_config_conv;
14916         default_config_conv.inner = (void*)(default_config & (~1));
14917         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
14918         default_config_conv = UserConfig_clone(&default_config_conv);
14919         LDKCVec_ChannelMonitorZ channel_monitors_constr;
14920         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
14921         if (channel_monitors_constr.datalen > 0)
14922                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
14923         else
14924                 channel_monitors_constr.data = NULL;
14925         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
14926         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
14927                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
14928                 LDKChannelMonitor channel_monitors_conv_16_conv;
14929                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
14930                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
14931                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
14932         }
14933         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);
14934         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14935         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14936         uint64_t ret_ref = (uint64_t)ret_var.inner;
14937         if (ret_var.is_owned) {
14938                 ret_ref |= 1;
14939         }
14940         return ret_ref;
14941 }
14942
14943 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
14944         LDKu8slice ser_ref;
14945         ser_ref.datalen = *((uint32_t*)ser);
14946         ser_ref.data = (int8_t*)(ser + 4);
14947         LDKChannelManagerReadArgs arg_conv;
14948         arg_conv.inner = (void*)(arg & (~1));
14949         arg_conv.is_owned = (arg & 1) || (arg == 0);
14950         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
14951         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14952         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
14953         return (uint64_t)ret_conv;
14954 }
14955
14956 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
14957         LDKDecodeError this_obj_conv;
14958         this_obj_conv.inner = (void*)(this_obj & (~1));
14959         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14960         DecodeError_free(this_obj_conv);
14961 }
14962
14963 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
14964         LDKDecodeError orig_conv;
14965         orig_conv.inner = (void*)(orig & (~1));
14966         orig_conv.is_owned = false;
14967         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
14968         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14969         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14970         uint64_t ret_ref = (uint64_t)ret_var.inner;
14971         if (ret_var.is_owned) {
14972                 ret_ref |= 1;
14973         }
14974         return ret_ref;
14975 }
14976
14977 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
14978         LDKInit this_obj_conv;
14979         this_obj_conv.inner = (void*)(this_obj & (~1));
14980         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14981         Init_free(this_obj_conv);
14982 }
14983
14984 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
14985         LDKInit this_ptr_conv;
14986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14987         this_ptr_conv.is_owned = false;
14988         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
14989         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14990         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14991         uint64_t ret_ref = (uint64_t)ret_var.inner;
14992         if (ret_var.is_owned) {
14993                 ret_ref |= 1;
14994         }
14995         return ret_ref;
14996 }
14997
14998 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
14999         LDKInit this_ptr_conv;
15000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15001         this_ptr_conv.is_owned = false;
15002         LDKInitFeatures val_conv;
15003         val_conv.inner = (void*)(val & (~1));
15004         val_conv.is_owned = (val & 1) || (val == 0);
15005         val_conv = InitFeatures_clone(&val_conv);
15006         Init_set_features(&this_ptr_conv, val_conv);
15007 }
15008
15009 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
15010         LDKInitFeatures features_arg_conv;
15011         features_arg_conv.inner = (void*)(features_arg & (~1));
15012         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
15013         features_arg_conv = InitFeatures_clone(&features_arg_conv);
15014         LDKInit ret_var = Init_new(features_arg_conv);
15015         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15016         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15017         uint64_t ret_ref = (uint64_t)ret_var.inner;
15018         if (ret_var.is_owned) {
15019                 ret_ref |= 1;
15020         }
15021         return ret_ref;
15022 }
15023
15024 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
15025         LDKInit orig_conv;
15026         orig_conv.inner = (void*)(orig & (~1));
15027         orig_conv.is_owned = false;
15028         LDKInit ret_var = Init_clone(&orig_conv);
15029         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15030         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15031         uint64_t ret_ref = (uint64_t)ret_var.inner;
15032         if (ret_var.is_owned) {
15033                 ret_ref |= 1;
15034         }
15035         return ret_ref;
15036 }
15037
15038 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
15039         LDKErrorMessage this_obj_conv;
15040         this_obj_conv.inner = (void*)(this_obj & (~1));
15041         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15042         ErrorMessage_free(this_obj_conv);
15043 }
15044
15045 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
15046         LDKErrorMessage this_ptr_conv;
15047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15048         this_ptr_conv.is_owned = false;
15049         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15050         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
15051         return ret_arr;
15052 }
15053
15054 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15055         LDKErrorMessage this_ptr_conv;
15056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15057         this_ptr_conv.is_owned = false;
15058         LDKThirtyTwoBytes val_ref;
15059         CHECK(*((uint32_t*)val) == 32);
15060         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15061         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
15062 }
15063
15064 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
15065         LDKErrorMessage this_ptr_conv;
15066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15067         this_ptr_conv.is_owned = false;
15068         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
15069         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
15070         Str_free(ret_str);
15071         return ret_conv;
15072 }
15073
15074 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
15075         LDKErrorMessage this_ptr_conv;
15076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15077         this_ptr_conv.is_owned = false;
15078         LDKStr val_conv = str_ref_to_owned_c(val);
15079         ErrorMessage_set_data(&this_ptr_conv, val_conv);
15080 }
15081
15082 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
15083         LDKThirtyTwoBytes channel_id_arg_ref;
15084         CHECK(*((uint32_t*)channel_id_arg) == 32);
15085         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15086         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
15087         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
15088         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15089         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15090         uint64_t ret_ref = (uint64_t)ret_var.inner;
15091         if (ret_var.is_owned) {
15092                 ret_ref |= 1;
15093         }
15094         return ret_ref;
15095 }
15096
15097 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
15098         LDKErrorMessage orig_conv;
15099         orig_conv.inner = (void*)(orig & (~1));
15100         orig_conv.is_owned = false;
15101         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
15102         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15103         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15104         uint64_t ret_ref = (uint64_t)ret_var.inner;
15105         if (ret_var.is_owned) {
15106                 ret_ref |= 1;
15107         }
15108         return ret_ref;
15109 }
15110
15111 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
15112         LDKPing this_obj_conv;
15113         this_obj_conv.inner = (void*)(this_obj & (~1));
15114         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15115         Ping_free(this_obj_conv);
15116 }
15117
15118 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
15119         LDKPing this_ptr_conv;
15120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15121         this_ptr_conv.is_owned = false;
15122         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
15123         return ret_val;
15124 }
15125
15126 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
15127         LDKPing this_ptr_conv;
15128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15129         this_ptr_conv.is_owned = false;
15130         Ping_set_ponglen(&this_ptr_conv, val);
15131 }
15132
15133 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
15134         LDKPing this_ptr_conv;
15135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15136         this_ptr_conv.is_owned = false;
15137         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
15138         return ret_val;
15139 }
15140
15141 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
15142         LDKPing this_ptr_conv;
15143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15144         this_ptr_conv.is_owned = false;
15145         Ping_set_byteslen(&this_ptr_conv, val);
15146 }
15147
15148 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
15149         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
15150         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15151         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15152         uint64_t ret_ref = (uint64_t)ret_var.inner;
15153         if (ret_var.is_owned) {
15154                 ret_ref |= 1;
15155         }
15156         return ret_ref;
15157 }
15158
15159 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
15160         LDKPing orig_conv;
15161         orig_conv.inner = (void*)(orig & (~1));
15162         orig_conv.is_owned = false;
15163         LDKPing ret_var = Ping_clone(&orig_conv);
15164         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15165         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15166         uint64_t ret_ref = (uint64_t)ret_var.inner;
15167         if (ret_var.is_owned) {
15168                 ret_ref |= 1;
15169         }
15170         return ret_ref;
15171 }
15172
15173 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
15174         LDKPong this_obj_conv;
15175         this_obj_conv.inner = (void*)(this_obj & (~1));
15176         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15177         Pong_free(this_obj_conv);
15178 }
15179
15180 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
15181         LDKPong this_ptr_conv;
15182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15183         this_ptr_conv.is_owned = false;
15184         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
15185         return ret_val;
15186 }
15187
15188 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
15189         LDKPong this_ptr_conv;
15190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15191         this_ptr_conv.is_owned = false;
15192         Pong_set_byteslen(&this_ptr_conv, val);
15193 }
15194
15195 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
15196         LDKPong ret_var = Pong_new(byteslen_arg);
15197         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15198         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15199         uint64_t ret_ref = (uint64_t)ret_var.inner;
15200         if (ret_var.is_owned) {
15201                 ret_ref |= 1;
15202         }
15203         return ret_ref;
15204 }
15205
15206 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
15207         LDKPong orig_conv;
15208         orig_conv.inner = (void*)(orig & (~1));
15209         orig_conv.is_owned = false;
15210         LDKPong ret_var = Pong_clone(&orig_conv);
15211         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15212         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15213         uint64_t ret_ref = (uint64_t)ret_var.inner;
15214         if (ret_var.is_owned) {
15215                 ret_ref |= 1;
15216         }
15217         return ret_ref;
15218 }
15219
15220 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
15221         LDKOpenChannel this_obj_conv;
15222         this_obj_conv.inner = (void*)(this_obj & (~1));
15223         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15224         OpenChannel_free(this_obj_conv);
15225 }
15226
15227 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
15228         LDKOpenChannel this_ptr_conv;
15229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15230         this_ptr_conv.is_owned = false;
15231         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15232         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
15233         return ret_arr;
15234 }
15235
15236 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
15237         LDKOpenChannel this_ptr_conv;
15238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15239         this_ptr_conv.is_owned = false;
15240         LDKThirtyTwoBytes val_ref;
15241         CHECK(*((uint32_t*)val) == 32);
15242         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15243         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
15244 }
15245
15246 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
15247         LDKOpenChannel this_ptr_conv;
15248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15249         this_ptr_conv.is_owned = false;
15250         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15251         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
15252         return ret_arr;
15253 }
15254
15255 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
15256         LDKOpenChannel this_ptr_conv;
15257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15258         this_ptr_conv.is_owned = false;
15259         LDKThirtyTwoBytes val_ref;
15260         CHECK(*((uint32_t*)val) == 32);
15261         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15262         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
15263 }
15264
15265 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
15266         LDKOpenChannel this_ptr_conv;
15267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15268         this_ptr_conv.is_owned = false;
15269         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
15270         return ret_val;
15271 }
15272
15273 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
15274         LDKOpenChannel this_ptr_conv;
15275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15276         this_ptr_conv.is_owned = false;
15277         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
15278 }
15279
15280 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
15281         LDKOpenChannel this_ptr_conv;
15282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15283         this_ptr_conv.is_owned = false;
15284         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
15285         return ret_val;
15286 }
15287
15288 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
15289         LDKOpenChannel this_ptr_conv;
15290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15291         this_ptr_conv.is_owned = false;
15292         OpenChannel_set_push_msat(&this_ptr_conv, val);
15293 }
15294
15295 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
15296         LDKOpenChannel this_ptr_conv;
15297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15298         this_ptr_conv.is_owned = false;
15299         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
15300         return ret_val;
15301 }
15302
15303 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
15304         LDKOpenChannel this_ptr_conv;
15305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15306         this_ptr_conv.is_owned = false;
15307         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
15308 }
15309
15310 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
15311         LDKOpenChannel this_ptr_conv;
15312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15313         this_ptr_conv.is_owned = false;
15314         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
15315         return ret_val;
15316 }
15317
15318 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
15319         LDKOpenChannel this_ptr_conv;
15320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15321         this_ptr_conv.is_owned = false;
15322         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
15323 }
15324
15325 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
15326         LDKOpenChannel this_ptr_conv;
15327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15328         this_ptr_conv.is_owned = false;
15329         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
15330         return ret_val;
15331 }
15332
15333 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
15334         LDKOpenChannel this_ptr_conv;
15335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15336         this_ptr_conv.is_owned = false;
15337         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
15338 }
15339
15340 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
15341         LDKOpenChannel this_ptr_conv;
15342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15343         this_ptr_conv.is_owned = false;
15344         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
15345         return ret_val;
15346 }
15347
15348 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
15349         LDKOpenChannel this_ptr_conv;
15350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15351         this_ptr_conv.is_owned = false;
15352         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
15353 }
15354
15355 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
15356         LDKOpenChannel this_ptr_conv;
15357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15358         this_ptr_conv.is_owned = false;
15359         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
15360         return ret_val;
15361 }
15362
15363 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
15364         LDKOpenChannel this_ptr_conv;
15365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15366         this_ptr_conv.is_owned = false;
15367         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
15368 }
15369
15370 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
15371         LDKOpenChannel this_ptr_conv;
15372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15373         this_ptr_conv.is_owned = false;
15374         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
15375         return ret_val;
15376 }
15377
15378 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
15379         LDKOpenChannel this_ptr_conv;
15380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15381         this_ptr_conv.is_owned = false;
15382         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
15383 }
15384
15385 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
15386         LDKOpenChannel this_ptr_conv;
15387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15388         this_ptr_conv.is_owned = false;
15389         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
15390         return ret_val;
15391 }
15392
15393 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
15394         LDKOpenChannel this_ptr_conv;
15395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15396         this_ptr_conv.is_owned = false;
15397         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
15398 }
15399
15400 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
15401         LDKOpenChannel this_ptr_conv;
15402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15403         this_ptr_conv.is_owned = false;
15404         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15405         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
15406         return ret_arr;
15407 }
15408
15409 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
15410         LDKOpenChannel this_ptr_conv;
15411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15412         this_ptr_conv.is_owned = false;
15413         LDKPublicKey val_ref;
15414         CHECK(*((uint32_t*)val) == 33);
15415         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15416         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
15417 }
15418
15419 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
15420         LDKOpenChannel this_ptr_conv;
15421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15422         this_ptr_conv.is_owned = false;
15423         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15424         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
15425         return ret_arr;
15426 }
15427
15428 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
15429         LDKOpenChannel this_ptr_conv;
15430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15431         this_ptr_conv.is_owned = false;
15432         LDKPublicKey val_ref;
15433         CHECK(*((uint32_t*)val) == 33);
15434         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15435         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
15436 }
15437
15438 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
15439         LDKOpenChannel this_ptr_conv;
15440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15441         this_ptr_conv.is_owned = false;
15442         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15443         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
15444         return ret_arr;
15445 }
15446
15447 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
15448         LDKOpenChannel this_ptr_conv;
15449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15450         this_ptr_conv.is_owned = false;
15451         LDKPublicKey val_ref;
15452         CHECK(*((uint32_t*)val) == 33);
15453         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15454         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
15455 }
15456
15457 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
15458         LDKOpenChannel this_ptr_conv;
15459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15460         this_ptr_conv.is_owned = false;
15461         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15462         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
15463         return ret_arr;
15464 }
15465
15466 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
15467         LDKOpenChannel this_ptr_conv;
15468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15469         this_ptr_conv.is_owned = false;
15470         LDKPublicKey val_ref;
15471         CHECK(*((uint32_t*)val) == 33);
15472         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15473         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
15474 }
15475
15476 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
15477         LDKOpenChannel this_ptr_conv;
15478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15479         this_ptr_conv.is_owned = false;
15480         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15481         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
15482         return ret_arr;
15483 }
15484
15485 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
15486         LDKOpenChannel this_ptr_conv;
15487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15488         this_ptr_conv.is_owned = false;
15489         LDKPublicKey val_ref;
15490         CHECK(*((uint32_t*)val) == 33);
15491         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15492         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
15493 }
15494
15495 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
15496         LDKOpenChannel this_ptr_conv;
15497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15498         this_ptr_conv.is_owned = false;
15499         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15500         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
15501         return ret_arr;
15502 }
15503
15504 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
15505         LDKOpenChannel this_ptr_conv;
15506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15507         this_ptr_conv.is_owned = false;
15508         LDKPublicKey val_ref;
15509         CHECK(*((uint32_t*)val) == 33);
15510         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15511         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
15512 }
15513
15514 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
15515         LDKOpenChannel this_ptr_conv;
15516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15517         this_ptr_conv.is_owned = false;
15518         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
15519         return ret_val;
15520 }
15521
15522 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
15523         LDKOpenChannel this_ptr_conv;
15524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15525         this_ptr_conv.is_owned = false;
15526         OpenChannel_set_channel_flags(&this_ptr_conv, val);
15527 }
15528
15529 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
15530         LDKOpenChannel orig_conv;
15531         orig_conv.inner = (void*)(orig & (~1));
15532         orig_conv.is_owned = false;
15533         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
15534         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15535         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15536         uint64_t ret_ref = (uint64_t)ret_var.inner;
15537         if (ret_var.is_owned) {
15538                 ret_ref |= 1;
15539         }
15540         return ret_ref;
15541 }
15542
15543 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
15544         LDKAcceptChannel this_obj_conv;
15545         this_obj_conv.inner = (void*)(this_obj & (~1));
15546         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15547         AcceptChannel_free(this_obj_conv);
15548 }
15549
15550 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
15551         LDKAcceptChannel this_ptr_conv;
15552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15553         this_ptr_conv.is_owned = false;
15554         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15555         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
15556         return ret_arr;
15557 }
15558
15559 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
15560         LDKAcceptChannel this_ptr_conv;
15561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15562         this_ptr_conv.is_owned = false;
15563         LDKThirtyTwoBytes val_ref;
15564         CHECK(*((uint32_t*)val) == 32);
15565         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15566         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
15567 }
15568
15569 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
15570         LDKAcceptChannel this_ptr_conv;
15571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15572         this_ptr_conv.is_owned = false;
15573         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
15574         return ret_val;
15575 }
15576
15577 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
15578         LDKAcceptChannel this_ptr_conv;
15579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15580         this_ptr_conv.is_owned = false;
15581         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
15582 }
15583
15584 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
15585         LDKAcceptChannel this_ptr_conv;
15586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15587         this_ptr_conv.is_owned = false;
15588         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
15589         return ret_val;
15590 }
15591
15592 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
15593         LDKAcceptChannel this_ptr_conv;
15594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15595         this_ptr_conv.is_owned = false;
15596         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
15597 }
15598
15599 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
15600         LDKAcceptChannel this_ptr_conv;
15601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15602         this_ptr_conv.is_owned = false;
15603         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
15604         return ret_val;
15605 }
15606
15607 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
15608         LDKAcceptChannel this_ptr_conv;
15609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15610         this_ptr_conv.is_owned = false;
15611         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
15612 }
15613
15614 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
15615         LDKAcceptChannel this_ptr_conv;
15616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15617         this_ptr_conv.is_owned = false;
15618         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
15619         return ret_val;
15620 }
15621
15622 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
15623         LDKAcceptChannel this_ptr_conv;
15624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15625         this_ptr_conv.is_owned = false;
15626         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
15627 }
15628
15629 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
15630         LDKAcceptChannel this_ptr_conv;
15631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15632         this_ptr_conv.is_owned = false;
15633         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
15634         return ret_val;
15635 }
15636
15637 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
15638         LDKAcceptChannel this_ptr_conv;
15639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15640         this_ptr_conv.is_owned = false;
15641         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
15642 }
15643
15644 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
15645         LDKAcceptChannel this_ptr_conv;
15646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15647         this_ptr_conv.is_owned = false;
15648         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
15649         return ret_val;
15650 }
15651
15652 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
15653         LDKAcceptChannel this_ptr_conv;
15654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15655         this_ptr_conv.is_owned = false;
15656         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
15657 }
15658
15659 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
15660         LDKAcceptChannel this_ptr_conv;
15661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15662         this_ptr_conv.is_owned = false;
15663         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
15664         return ret_val;
15665 }
15666
15667 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
15668         LDKAcceptChannel this_ptr_conv;
15669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15670         this_ptr_conv.is_owned = false;
15671         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
15672 }
15673
15674 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
15675         LDKAcceptChannel this_ptr_conv;
15676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15677         this_ptr_conv.is_owned = false;
15678         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15679         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
15680         return ret_arr;
15681 }
15682
15683 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
15684         LDKAcceptChannel this_ptr_conv;
15685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15686         this_ptr_conv.is_owned = false;
15687         LDKPublicKey val_ref;
15688         CHECK(*((uint32_t*)val) == 33);
15689         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15690         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
15691 }
15692
15693 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
15694         LDKAcceptChannel this_ptr_conv;
15695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15696         this_ptr_conv.is_owned = false;
15697         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15698         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
15699         return ret_arr;
15700 }
15701
15702 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
15703         LDKAcceptChannel this_ptr_conv;
15704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15705         this_ptr_conv.is_owned = false;
15706         LDKPublicKey val_ref;
15707         CHECK(*((uint32_t*)val) == 33);
15708         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15709         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
15710 }
15711
15712 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
15713         LDKAcceptChannel this_ptr_conv;
15714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15715         this_ptr_conv.is_owned = false;
15716         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15717         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
15718         return ret_arr;
15719 }
15720
15721 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
15722         LDKAcceptChannel this_ptr_conv;
15723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15724         this_ptr_conv.is_owned = false;
15725         LDKPublicKey val_ref;
15726         CHECK(*((uint32_t*)val) == 33);
15727         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15728         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
15729 }
15730
15731 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
15732         LDKAcceptChannel this_ptr_conv;
15733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15734         this_ptr_conv.is_owned = false;
15735         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15736         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
15737         return ret_arr;
15738 }
15739
15740 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
15741         LDKAcceptChannel this_ptr_conv;
15742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15743         this_ptr_conv.is_owned = false;
15744         LDKPublicKey val_ref;
15745         CHECK(*((uint32_t*)val) == 33);
15746         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15747         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
15748 }
15749
15750 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
15751         LDKAcceptChannel this_ptr_conv;
15752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15753         this_ptr_conv.is_owned = false;
15754         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15755         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
15756         return ret_arr;
15757 }
15758
15759 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
15760         LDKAcceptChannel this_ptr_conv;
15761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15762         this_ptr_conv.is_owned = false;
15763         LDKPublicKey val_ref;
15764         CHECK(*((uint32_t*)val) == 33);
15765         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15766         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
15767 }
15768
15769 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
15770         LDKAcceptChannel this_ptr_conv;
15771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15772         this_ptr_conv.is_owned = false;
15773         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15774         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
15775         return ret_arr;
15776 }
15777
15778 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
15779         LDKAcceptChannel this_ptr_conv;
15780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15781         this_ptr_conv.is_owned = false;
15782         LDKPublicKey val_ref;
15783         CHECK(*((uint32_t*)val) == 33);
15784         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15785         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
15786 }
15787
15788 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
15789         LDKAcceptChannel orig_conv;
15790         orig_conv.inner = (void*)(orig & (~1));
15791         orig_conv.is_owned = false;
15792         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
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         uint64_t 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_FundingCreated_free(uint32_t this_obj) {
15803         LDKFundingCreated this_obj_conv;
15804         this_obj_conv.inner = (void*)(this_obj & (~1));
15805         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15806         FundingCreated_free(this_obj_conv);
15807 }
15808
15809 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
15810         LDKFundingCreated this_ptr_conv;
15811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15812         this_ptr_conv.is_owned = false;
15813         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15814         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
15815         return ret_arr;
15816 }
15817
15818 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
15819         LDKFundingCreated this_ptr_conv;
15820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15821         this_ptr_conv.is_owned = false;
15822         LDKThirtyTwoBytes val_ref;
15823         CHECK(*((uint32_t*)val) == 32);
15824         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15825         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
15826 }
15827
15828 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
15829         LDKFundingCreated this_ptr_conv;
15830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15831         this_ptr_conv.is_owned = false;
15832         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15833         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
15834         return ret_arr;
15835 }
15836
15837 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
15838         LDKFundingCreated this_ptr_conv;
15839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15840         this_ptr_conv.is_owned = false;
15841         LDKThirtyTwoBytes val_ref;
15842         CHECK(*((uint32_t*)val) == 32);
15843         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15844         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
15845 }
15846
15847 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
15848         LDKFundingCreated this_ptr_conv;
15849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15850         this_ptr_conv.is_owned = false;
15851         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
15852         return ret_val;
15853 }
15854
15855 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
15856         LDKFundingCreated this_ptr_conv;
15857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15858         this_ptr_conv.is_owned = false;
15859         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
15860 }
15861
15862 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
15863         LDKFundingCreated this_ptr_conv;
15864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15865         this_ptr_conv.is_owned = false;
15866         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15867         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
15868         return ret_arr;
15869 }
15870
15871 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
15872         LDKFundingCreated this_ptr_conv;
15873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15874         this_ptr_conv.is_owned = false;
15875         LDKSignature val_ref;
15876         CHECK(*((uint32_t*)val) == 64);
15877         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15878         FundingCreated_set_signature(&this_ptr_conv, val_ref);
15879 }
15880
15881 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) {
15882         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
15883         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
15884         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
15885         LDKThirtyTwoBytes funding_txid_arg_ref;
15886         CHECK(*((uint32_t*)funding_txid_arg) == 32);
15887         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
15888         LDKSignature signature_arg_ref;
15889         CHECK(*((uint32_t*)signature_arg) == 64);
15890         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15891         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
15892         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15893         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15894         uint64_t ret_ref = (uint64_t)ret_var.inner;
15895         if (ret_var.is_owned) {
15896                 ret_ref |= 1;
15897         }
15898         return ret_ref;
15899 }
15900
15901 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
15902         LDKFundingCreated orig_conv;
15903         orig_conv.inner = (void*)(orig & (~1));
15904         orig_conv.is_owned = false;
15905         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
15906         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15907         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15908         uint64_t ret_ref = (uint64_t)ret_var.inner;
15909         if (ret_var.is_owned) {
15910                 ret_ref |= 1;
15911         }
15912         return ret_ref;
15913 }
15914
15915 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
15916         LDKFundingSigned this_obj_conv;
15917         this_obj_conv.inner = (void*)(this_obj & (~1));
15918         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15919         FundingSigned_free(this_obj_conv);
15920 }
15921
15922 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
15923         LDKFundingSigned this_ptr_conv;
15924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15925         this_ptr_conv.is_owned = false;
15926         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15927         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
15928         return ret_arr;
15929 }
15930
15931 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15932         LDKFundingSigned this_ptr_conv;
15933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15934         this_ptr_conv.is_owned = false;
15935         LDKThirtyTwoBytes val_ref;
15936         CHECK(*((uint32_t*)val) == 32);
15937         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15938         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
15939 }
15940
15941 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
15942         LDKFundingSigned this_ptr_conv;
15943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15944         this_ptr_conv.is_owned = false;
15945         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15946         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
15947         return ret_arr;
15948 }
15949
15950 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
15951         LDKFundingSigned this_ptr_conv;
15952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15953         this_ptr_conv.is_owned = false;
15954         LDKSignature val_ref;
15955         CHECK(*((uint32_t*)val) == 64);
15956         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15957         FundingSigned_set_signature(&this_ptr_conv, val_ref);
15958 }
15959
15960 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
15961         LDKThirtyTwoBytes channel_id_arg_ref;
15962         CHECK(*((uint32_t*)channel_id_arg) == 32);
15963         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15964         LDKSignature signature_arg_ref;
15965         CHECK(*((uint32_t*)signature_arg) == 64);
15966         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15967         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
15968         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15969         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15970         uint64_t ret_ref = (uint64_t)ret_var.inner;
15971         if (ret_var.is_owned) {
15972                 ret_ref |= 1;
15973         }
15974         return ret_ref;
15975 }
15976
15977 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
15978         LDKFundingSigned orig_conv;
15979         orig_conv.inner = (void*)(orig & (~1));
15980         orig_conv.is_owned = false;
15981         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
15982         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15983         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15984         uint64_t ret_ref = (uint64_t)ret_var.inner;
15985         if (ret_var.is_owned) {
15986                 ret_ref |= 1;
15987         }
15988         return ret_ref;
15989 }
15990
15991 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
15992         LDKFundingLocked this_obj_conv;
15993         this_obj_conv.inner = (void*)(this_obj & (~1));
15994         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15995         FundingLocked_free(this_obj_conv);
15996 }
15997
15998 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
15999         LDKFundingLocked this_ptr_conv;
16000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16001         this_ptr_conv.is_owned = false;
16002         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16003         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
16004         return ret_arr;
16005 }
16006
16007 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16008         LDKFundingLocked this_ptr_conv;
16009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16010         this_ptr_conv.is_owned = false;
16011         LDKThirtyTwoBytes val_ref;
16012         CHECK(*((uint32_t*)val) == 32);
16013         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16014         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
16015 }
16016
16017 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
16018         LDKFundingLocked this_ptr_conv;
16019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16020         this_ptr_conv.is_owned = false;
16021         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16022         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
16023         return ret_arr;
16024 }
16025
16026 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
16027         LDKFundingLocked this_ptr_conv;
16028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16029         this_ptr_conv.is_owned = false;
16030         LDKPublicKey val_ref;
16031         CHECK(*((uint32_t*)val) == 33);
16032         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16033         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
16034 }
16035
16036 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
16037         LDKThirtyTwoBytes channel_id_arg_ref;
16038         CHECK(*((uint32_t*)channel_id_arg) == 32);
16039         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16040         LDKPublicKey next_per_commitment_point_arg_ref;
16041         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
16042         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
16043         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
16044         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16045         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16046         uint64_t ret_ref = (uint64_t)ret_var.inner;
16047         if (ret_var.is_owned) {
16048                 ret_ref |= 1;
16049         }
16050         return ret_ref;
16051 }
16052
16053 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
16054         LDKFundingLocked orig_conv;
16055         orig_conv.inner = (void*)(orig & (~1));
16056         orig_conv.is_owned = false;
16057         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
16058         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16059         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16060         uint64_t ret_ref = (uint64_t)ret_var.inner;
16061         if (ret_var.is_owned) {
16062                 ret_ref |= 1;
16063         }
16064         return ret_ref;
16065 }
16066
16067 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
16068         LDKShutdown this_obj_conv;
16069         this_obj_conv.inner = (void*)(this_obj & (~1));
16070         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16071         Shutdown_free(this_obj_conv);
16072 }
16073
16074 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
16075         LDKShutdown this_ptr_conv;
16076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16077         this_ptr_conv.is_owned = false;
16078         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16079         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
16080         return ret_arr;
16081 }
16082
16083 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16084         LDKShutdown this_ptr_conv;
16085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16086         this_ptr_conv.is_owned = false;
16087         LDKThirtyTwoBytes val_ref;
16088         CHECK(*((uint32_t*)val) == 32);
16089         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16090         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
16091 }
16092
16093 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
16094         LDKShutdown this_ptr_conv;
16095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16096         this_ptr_conv.is_owned = false;
16097         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
16098         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16099         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16100         return ret_arr;
16101 }
16102
16103 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
16104         LDKShutdown this_ptr_conv;
16105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16106         this_ptr_conv.is_owned = false;
16107         LDKCVec_u8Z val_ref;
16108         val_ref.datalen = *((uint32_t*)val);
16109         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
16110         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
16111         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
16112 }
16113
16114 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
16115         LDKThirtyTwoBytes channel_id_arg_ref;
16116         CHECK(*((uint32_t*)channel_id_arg) == 32);
16117         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16118         LDKCVec_u8Z scriptpubkey_arg_ref;
16119         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
16120         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
16121         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
16122         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
16123         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16124         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16125         uint64_t ret_ref = (uint64_t)ret_var.inner;
16126         if (ret_var.is_owned) {
16127                 ret_ref |= 1;
16128         }
16129         return ret_ref;
16130 }
16131
16132 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
16133         LDKShutdown orig_conv;
16134         orig_conv.inner = (void*)(orig & (~1));
16135         orig_conv.is_owned = false;
16136         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
16137         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16138         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16139         uint64_t ret_ref = (uint64_t)ret_var.inner;
16140         if (ret_var.is_owned) {
16141                 ret_ref |= 1;
16142         }
16143         return ret_ref;
16144 }
16145
16146 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
16147         LDKClosingSignedFeeRange this_obj_conv;
16148         this_obj_conv.inner = (void*)(this_obj & (~1));
16149         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16150         ClosingSignedFeeRange_free(this_obj_conv);
16151 }
16152
16153 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
16154         LDKClosingSignedFeeRange this_ptr_conv;
16155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16156         this_ptr_conv.is_owned = false;
16157         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
16158         return ret_val;
16159 }
16160
16161 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
16162         LDKClosingSignedFeeRange this_ptr_conv;
16163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16164         this_ptr_conv.is_owned = false;
16165         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
16166 }
16167
16168 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
16169         LDKClosingSignedFeeRange this_ptr_conv;
16170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16171         this_ptr_conv.is_owned = false;
16172         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
16173         return ret_val;
16174 }
16175
16176 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
16177         LDKClosingSignedFeeRange this_ptr_conv;
16178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16179         this_ptr_conv.is_owned = false;
16180         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
16181 }
16182
16183 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
16184         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
16185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16187         uint64_t ret_ref = (uint64_t)ret_var.inner;
16188         if (ret_var.is_owned) {
16189                 ret_ref |= 1;
16190         }
16191         return ret_ref;
16192 }
16193
16194 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
16195         LDKClosingSignedFeeRange orig_conv;
16196         orig_conv.inner = (void*)(orig & (~1));
16197         orig_conv.is_owned = false;
16198         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
16199         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16200         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16201         uint64_t ret_ref = (uint64_t)ret_var.inner;
16202         if (ret_var.is_owned) {
16203                 ret_ref |= 1;
16204         }
16205         return ret_ref;
16206 }
16207
16208 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
16209         LDKClosingSigned this_obj_conv;
16210         this_obj_conv.inner = (void*)(this_obj & (~1));
16211         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16212         ClosingSigned_free(this_obj_conv);
16213 }
16214
16215 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
16216         LDKClosingSigned this_ptr_conv;
16217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16218         this_ptr_conv.is_owned = false;
16219         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16220         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
16221         return ret_arr;
16222 }
16223
16224 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16225         LDKClosingSigned this_ptr_conv;
16226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16227         this_ptr_conv.is_owned = false;
16228         LDKThirtyTwoBytes val_ref;
16229         CHECK(*((uint32_t*)val) == 32);
16230         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16231         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
16232 }
16233
16234 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
16235         LDKClosingSigned this_ptr_conv;
16236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16237         this_ptr_conv.is_owned = false;
16238         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
16239         return ret_val;
16240 }
16241
16242 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
16243         LDKClosingSigned this_ptr_conv;
16244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16245         this_ptr_conv.is_owned = false;
16246         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
16247 }
16248
16249 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
16250         LDKClosingSigned this_ptr_conv;
16251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16252         this_ptr_conv.is_owned = false;
16253         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16254         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
16255         return ret_arr;
16256 }
16257
16258 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
16259         LDKClosingSigned this_ptr_conv;
16260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16261         this_ptr_conv.is_owned = false;
16262         LDKSignature val_ref;
16263         CHECK(*((uint32_t*)val) == 64);
16264         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16265         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
16266 }
16267
16268 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
16269         LDKClosingSigned this_ptr_conv;
16270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16271         this_ptr_conv.is_owned = false;
16272         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
16273         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16274         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16275         uint64_t ret_ref = (uint64_t)ret_var.inner;
16276         if (ret_var.is_owned) {
16277                 ret_ref |= 1;
16278         }
16279         return ret_ref;
16280 }
16281
16282 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
16283         LDKClosingSigned this_ptr_conv;
16284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16285         this_ptr_conv.is_owned = false;
16286         LDKClosingSignedFeeRange val_conv;
16287         val_conv.inner = (void*)(val & (~1));
16288         val_conv.is_owned = (val & 1) || (val == 0);
16289         val_conv = ClosingSignedFeeRange_clone(&val_conv);
16290         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
16291 }
16292
16293 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) {
16294         LDKThirtyTwoBytes channel_id_arg_ref;
16295         CHECK(*((uint32_t*)channel_id_arg) == 32);
16296         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16297         LDKSignature signature_arg_ref;
16298         CHECK(*((uint32_t*)signature_arg) == 64);
16299         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
16300         LDKClosingSignedFeeRange fee_range_arg_conv;
16301         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
16302         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
16303         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
16304         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
16305         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16306         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16307         uint64_t ret_ref = (uint64_t)ret_var.inner;
16308         if (ret_var.is_owned) {
16309                 ret_ref |= 1;
16310         }
16311         return ret_ref;
16312 }
16313
16314 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
16315         LDKClosingSigned orig_conv;
16316         orig_conv.inner = (void*)(orig & (~1));
16317         orig_conv.is_owned = false;
16318         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
16319         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16320         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16321         uint64_t ret_ref = (uint64_t)ret_var.inner;
16322         if (ret_var.is_owned) {
16323                 ret_ref |= 1;
16324         }
16325         return ret_ref;
16326 }
16327
16328 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
16329         LDKUpdateAddHTLC this_obj_conv;
16330         this_obj_conv.inner = (void*)(this_obj & (~1));
16331         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16332         UpdateAddHTLC_free(this_obj_conv);
16333 }
16334
16335 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
16336         LDKUpdateAddHTLC this_ptr_conv;
16337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16338         this_ptr_conv.is_owned = false;
16339         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16340         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
16341         return ret_arr;
16342 }
16343
16344 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16345         LDKUpdateAddHTLC this_ptr_conv;
16346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16347         this_ptr_conv.is_owned = false;
16348         LDKThirtyTwoBytes val_ref;
16349         CHECK(*((uint32_t*)val) == 32);
16350         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16351         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
16352 }
16353
16354 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
16355         LDKUpdateAddHTLC this_ptr_conv;
16356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16357         this_ptr_conv.is_owned = false;
16358         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
16359         return ret_val;
16360 }
16361
16362 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
16363         LDKUpdateAddHTLC this_ptr_conv;
16364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16365         this_ptr_conv.is_owned = false;
16366         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
16367 }
16368
16369 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
16370         LDKUpdateAddHTLC this_ptr_conv;
16371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16372         this_ptr_conv.is_owned = false;
16373         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
16374         return ret_val;
16375 }
16376
16377 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
16378         LDKUpdateAddHTLC this_ptr_conv;
16379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16380         this_ptr_conv.is_owned = false;
16381         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
16382 }
16383
16384 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
16385         LDKUpdateAddHTLC this_ptr_conv;
16386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16387         this_ptr_conv.is_owned = false;
16388         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16389         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
16390         return ret_arr;
16391 }
16392
16393 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
16394         LDKUpdateAddHTLC this_ptr_conv;
16395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16396         this_ptr_conv.is_owned = false;
16397         LDKThirtyTwoBytes val_ref;
16398         CHECK(*((uint32_t*)val) == 32);
16399         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16400         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
16401 }
16402
16403 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
16404         LDKUpdateAddHTLC this_ptr_conv;
16405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16406         this_ptr_conv.is_owned = false;
16407         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
16408         return ret_val;
16409 }
16410
16411 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
16412         LDKUpdateAddHTLC this_ptr_conv;
16413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16414         this_ptr_conv.is_owned = false;
16415         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
16416 }
16417
16418 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
16419         LDKUpdateAddHTLC orig_conv;
16420         orig_conv.inner = (void*)(orig & (~1));
16421         orig_conv.is_owned = false;
16422         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
16423         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16424         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16425         uint64_t ret_ref = (uint64_t)ret_var.inner;
16426         if (ret_var.is_owned) {
16427                 ret_ref |= 1;
16428         }
16429         return ret_ref;
16430 }
16431
16432 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
16433         LDKUpdateFulfillHTLC this_obj_conv;
16434         this_obj_conv.inner = (void*)(this_obj & (~1));
16435         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16436         UpdateFulfillHTLC_free(this_obj_conv);
16437 }
16438
16439 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
16440         LDKUpdateFulfillHTLC this_ptr_conv;
16441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16442         this_ptr_conv.is_owned = false;
16443         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16444         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
16445         return ret_arr;
16446 }
16447
16448 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16449         LDKUpdateFulfillHTLC this_ptr_conv;
16450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16451         this_ptr_conv.is_owned = false;
16452         LDKThirtyTwoBytes val_ref;
16453         CHECK(*((uint32_t*)val) == 32);
16454         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16455         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
16456 }
16457
16458 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
16459         LDKUpdateFulfillHTLC this_ptr_conv;
16460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16461         this_ptr_conv.is_owned = false;
16462         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
16463         return ret_val;
16464 }
16465
16466 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
16467         LDKUpdateFulfillHTLC this_ptr_conv;
16468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16469         this_ptr_conv.is_owned = false;
16470         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
16471 }
16472
16473 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
16474         LDKUpdateFulfillHTLC this_ptr_conv;
16475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16476         this_ptr_conv.is_owned = false;
16477         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16478         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
16479         return ret_arr;
16480 }
16481
16482 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
16483         LDKUpdateFulfillHTLC this_ptr_conv;
16484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16485         this_ptr_conv.is_owned = false;
16486         LDKThirtyTwoBytes val_ref;
16487         CHECK(*((uint32_t*)val) == 32);
16488         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16489         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
16490 }
16491
16492 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
16493         LDKThirtyTwoBytes channel_id_arg_ref;
16494         CHECK(*((uint32_t*)channel_id_arg) == 32);
16495         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16496         LDKThirtyTwoBytes payment_preimage_arg_ref;
16497         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
16498         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
16499         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
16500         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16501         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16502         uint64_t ret_ref = (uint64_t)ret_var.inner;
16503         if (ret_var.is_owned) {
16504                 ret_ref |= 1;
16505         }
16506         return ret_ref;
16507 }
16508
16509 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
16510         LDKUpdateFulfillHTLC orig_conv;
16511         orig_conv.inner = (void*)(orig & (~1));
16512         orig_conv.is_owned = false;
16513         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
16514         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16515         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16516         uint64_t ret_ref = (uint64_t)ret_var.inner;
16517         if (ret_var.is_owned) {
16518                 ret_ref |= 1;
16519         }
16520         return ret_ref;
16521 }
16522
16523 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
16524         LDKUpdateFailHTLC this_obj_conv;
16525         this_obj_conv.inner = (void*)(this_obj & (~1));
16526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16527         UpdateFailHTLC_free(this_obj_conv);
16528 }
16529
16530 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
16531         LDKUpdateFailHTLC this_ptr_conv;
16532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16533         this_ptr_conv.is_owned = false;
16534         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16535         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
16536         return ret_arr;
16537 }
16538
16539 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16540         LDKUpdateFailHTLC this_ptr_conv;
16541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16542         this_ptr_conv.is_owned = false;
16543         LDKThirtyTwoBytes val_ref;
16544         CHECK(*((uint32_t*)val) == 32);
16545         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16546         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
16547 }
16548
16549 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
16550         LDKUpdateFailHTLC this_ptr_conv;
16551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16552         this_ptr_conv.is_owned = false;
16553         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
16554         return ret_val;
16555 }
16556
16557 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
16558         LDKUpdateFailHTLC this_ptr_conv;
16559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16560         this_ptr_conv.is_owned = false;
16561         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
16562 }
16563
16564 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
16565         LDKUpdateFailHTLC orig_conv;
16566         orig_conv.inner = (void*)(orig & (~1));
16567         orig_conv.is_owned = false;
16568         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
16569         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16570         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16571         uint64_t ret_ref = (uint64_t)ret_var.inner;
16572         if (ret_var.is_owned) {
16573                 ret_ref |= 1;
16574         }
16575         return ret_ref;
16576 }
16577
16578 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
16579         LDKUpdateFailMalformedHTLC this_obj_conv;
16580         this_obj_conv.inner = (void*)(this_obj & (~1));
16581         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16582         UpdateFailMalformedHTLC_free(this_obj_conv);
16583 }
16584
16585 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
16586         LDKUpdateFailMalformedHTLC this_ptr_conv;
16587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16588         this_ptr_conv.is_owned = false;
16589         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16590         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
16591         return ret_arr;
16592 }
16593
16594 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16595         LDKUpdateFailMalformedHTLC this_ptr_conv;
16596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16597         this_ptr_conv.is_owned = false;
16598         LDKThirtyTwoBytes val_ref;
16599         CHECK(*((uint32_t*)val) == 32);
16600         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16601         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
16602 }
16603
16604 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
16605         LDKUpdateFailMalformedHTLC this_ptr_conv;
16606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16607         this_ptr_conv.is_owned = false;
16608         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
16609         return ret_val;
16610 }
16611
16612 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
16613         LDKUpdateFailMalformedHTLC this_ptr_conv;
16614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16615         this_ptr_conv.is_owned = false;
16616         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
16617 }
16618
16619 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
16620         LDKUpdateFailMalformedHTLC this_ptr_conv;
16621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16622         this_ptr_conv.is_owned = false;
16623         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
16624         return ret_val;
16625 }
16626
16627 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
16628         LDKUpdateFailMalformedHTLC this_ptr_conv;
16629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16630         this_ptr_conv.is_owned = false;
16631         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
16632 }
16633
16634 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
16635         LDKUpdateFailMalformedHTLC orig_conv;
16636         orig_conv.inner = (void*)(orig & (~1));
16637         orig_conv.is_owned = false;
16638         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
16639         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16640         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16641         uint64_t ret_ref = (uint64_t)ret_var.inner;
16642         if (ret_var.is_owned) {
16643                 ret_ref |= 1;
16644         }
16645         return ret_ref;
16646 }
16647
16648 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
16649         LDKCommitmentSigned this_obj_conv;
16650         this_obj_conv.inner = (void*)(this_obj & (~1));
16651         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16652         CommitmentSigned_free(this_obj_conv);
16653 }
16654
16655 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
16656         LDKCommitmentSigned this_ptr_conv;
16657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16658         this_ptr_conv.is_owned = false;
16659         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16660         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
16661         return ret_arr;
16662 }
16663
16664 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16665         LDKCommitmentSigned this_ptr_conv;
16666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16667         this_ptr_conv.is_owned = false;
16668         LDKThirtyTwoBytes val_ref;
16669         CHECK(*((uint32_t*)val) == 32);
16670         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16671         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
16672 }
16673
16674 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
16675         LDKCommitmentSigned this_ptr_conv;
16676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16677         this_ptr_conv.is_owned = false;
16678         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16679         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
16680         return ret_arr;
16681 }
16682
16683 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
16684         LDKCommitmentSigned this_ptr_conv;
16685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16686         this_ptr_conv.is_owned = false;
16687         LDKSignature val_ref;
16688         CHECK(*((uint32_t*)val) == 64);
16689         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16690         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
16691 }
16692
16693 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
16694         LDKCommitmentSigned this_ptr_conv;
16695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16696         this_ptr_conv.is_owned = false;
16697         LDKCVec_SignatureZ val_constr;
16698         val_constr.datalen = *((uint32_t*)val);
16699         if (val_constr.datalen > 0)
16700                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16701         else
16702                 val_constr.data = NULL;
16703         int8_tArray* val_vals = (int8_tArray*)(val + 4);
16704         for (size_t m = 0; m < val_constr.datalen; m++) {
16705                 int8_tArray val_conv_12 = val_vals[m];
16706                 LDKSignature val_conv_12_ref;
16707                 CHECK(*((uint32_t*)val_conv_12) == 64);
16708                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
16709                 val_constr.data[m] = val_conv_12_ref;
16710         }
16711         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
16712 }
16713
16714 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
16715         LDKThirtyTwoBytes channel_id_arg_ref;
16716         CHECK(*((uint32_t*)channel_id_arg) == 32);
16717         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16718         LDKSignature signature_arg_ref;
16719         CHECK(*((uint32_t*)signature_arg) == 64);
16720         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
16721         LDKCVec_SignatureZ htlc_signatures_arg_constr;
16722         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
16723         if (htlc_signatures_arg_constr.datalen > 0)
16724                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16725         else
16726                 htlc_signatures_arg_constr.data = NULL;
16727         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
16728         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
16729                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
16730                 LDKSignature htlc_signatures_arg_conv_12_ref;
16731                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
16732                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
16733                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
16734         }
16735         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
16736         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16737         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16738         uint64_t ret_ref = (uint64_t)ret_var.inner;
16739         if (ret_var.is_owned) {
16740                 ret_ref |= 1;
16741         }
16742         return ret_ref;
16743 }
16744
16745 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
16746         LDKCommitmentSigned orig_conv;
16747         orig_conv.inner = (void*)(orig & (~1));
16748         orig_conv.is_owned = false;
16749         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
16750         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16751         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16752         uint64_t ret_ref = (uint64_t)ret_var.inner;
16753         if (ret_var.is_owned) {
16754                 ret_ref |= 1;
16755         }
16756         return ret_ref;
16757 }
16758
16759 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
16760         LDKRevokeAndACK this_obj_conv;
16761         this_obj_conv.inner = (void*)(this_obj & (~1));
16762         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16763         RevokeAndACK_free(this_obj_conv);
16764 }
16765
16766 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
16767         LDKRevokeAndACK this_ptr_conv;
16768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16769         this_ptr_conv.is_owned = false;
16770         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16771         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
16772         return ret_arr;
16773 }
16774
16775 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16776         LDKRevokeAndACK this_ptr_conv;
16777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16778         this_ptr_conv.is_owned = false;
16779         LDKThirtyTwoBytes val_ref;
16780         CHECK(*((uint32_t*)val) == 32);
16781         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16782         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
16783 }
16784
16785 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
16786         LDKRevokeAndACK this_ptr_conv;
16787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16788         this_ptr_conv.is_owned = false;
16789         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16790         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
16791         return ret_arr;
16792 }
16793
16794 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
16795         LDKRevokeAndACK this_ptr_conv;
16796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16797         this_ptr_conv.is_owned = false;
16798         LDKThirtyTwoBytes val_ref;
16799         CHECK(*((uint32_t*)val) == 32);
16800         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16801         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
16802 }
16803
16804 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
16805         LDKRevokeAndACK this_ptr_conv;
16806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16807         this_ptr_conv.is_owned = false;
16808         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16809         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
16810         return ret_arr;
16811 }
16812
16813 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
16814         LDKRevokeAndACK this_ptr_conv;
16815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16816         this_ptr_conv.is_owned = false;
16817         LDKPublicKey val_ref;
16818         CHECK(*((uint32_t*)val) == 33);
16819         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16820         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
16821 }
16822
16823 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) {
16824         LDKThirtyTwoBytes channel_id_arg_ref;
16825         CHECK(*((uint32_t*)channel_id_arg) == 32);
16826         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16827         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
16828         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
16829         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
16830         LDKPublicKey next_per_commitment_point_arg_ref;
16831         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
16832         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
16833         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
16834         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16835         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16836         uint64_t ret_ref = (uint64_t)ret_var.inner;
16837         if (ret_var.is_owned) {
16838                 ret_ref |= 1;
16839         }
16840         return ret_ref;
16841 }
16842
16843 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
16844         LDKRevokeAndACK orig_conv;
16845         orig_conv.inner = (void*)(orig & (~1));
16846         orig_conv.is_owned = false;
16847         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
16848         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16849         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16850         uint64_t ret_ref = (uint64_t)ret_var.inner;
16851         if (ret_var.is_owned) {
16852                 ret_ref |= 1;
16853         }
16854         return ret_ref;
16855 }
16856
16857 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
16858         LDKUpdateFee this_obj_conv;
16859         this_obj_conv.inner = (void*)(this_obj & (~1));
16860         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16861         UpdateFee_free(this_obj_conv);
16862 }
16863
16864 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
16865         LDKUpdateFee this_ptr_conv;
16866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16867         this_ptr_conv.is_owned = false;
16868         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16869         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
16870         return ret_arr;
16871 }
16872
16873 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16874         LDKUpdateFee this_ptr_conv;
16875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16876         this_ptr_conv.is_owned = false;
16877         LDKThirtyTwoBytes val_ref;
16878         CHECK(*((uint32_t*)val) == 32);
16879         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16880         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
16881 }
16882
16883 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
16884         LDKUpdateFee this_ptr_conv;
16885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16886         this_ptr_conv.is_owned = false;
16887         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
16888         return ret_val;
16889 }
16890
16891 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
16892         LDKUpdateFee this_ptr_conv;
16893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16894         this_ptr_conv.is_owned = false;
16895         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
16896 }
16897
16898 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
16899         LDKThirtyTwoBytes channel_id_arg_ref;
16900         CHECK(*((uint32_t*)channel_id_arg) == 32);
16901         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16902         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
16903         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16904         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16905         uint64_t ret_ref = (uint64_t)ret_var.inner;
16906         if (ret_var.is_owned) {
16907                 ret_ref |= 1;
16908         }
16909         return ret_ref;
16910 }
16911
16912 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
16913         LDKUpdateFee orig_conv;
16914         orig_conv.inner = (void*)(orig & (~1));
16915         orig_conv.is_owned = false;
16916         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
16917         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16918         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16919         uint64_t ret_ref = (uint64_t)ret_var.inner;
16920         if (ret_var.is_owned) {
16921                 ret_ref |= 1;
16922         }
16923         return ret_ref;
16924 }
16925
16926 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
16927         LDKDataLossProtect this_obj_conv;
16928         this_obj_conv.inner = (void*)(this_obj & (~1));
16929         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16930         DataLossProtect_free(this_obj_conv);
16931 }
16932
16933 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
16934         LDKDataLossProtect this_ptr_conv;
16935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16936         this_ptr_conv.is_owned = false;
16937         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16938         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
16939         return ret_arr;
16940 }
16941
16942 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
16943         LDKDataLossProtect this_ptr_conv;
16944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16945         this_ptr_conv.is_owned = false;
16946         LDKThirtyTwoBytes val_ref;
16947         CHECK(*((uint32_t*)val) == 32);
16948         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16949         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
16950 }
16951
16952 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
16953         LDKDataLossProtect this_ptr_conv;
16954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16955         this_ptr_conv.is_owned = false;
16956         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16957         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
16958         return ret_arr;
16959 }
16960
16961 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
16962         LDKDataLossProtect this_ptr_conv;
16963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16964         this_ptr_conv.is_owned = false;
16965         LDKPublicKey val_ref;
16966         CHECK(*((uint32_t*)val) == 33);
16967         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16968         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
16969 }
16970
16971 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
16972         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
16973         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
16974         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
16975         LDKPublicKey my_current_per_commitment_point_arg_ref;
16976         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
16977         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
16978         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
16979         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16980         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16981         uint64_t ret_ref = (uint64_t)ret_var.inner;
16982         if (ret_var.is_owned) {
16983                 ret_ref |= 1;
16984         }
16985         return ret_ref;
16986 }
16987
16988 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
16989         LDKDataLossProtect orig_conv;
16990         orig_conv.inner = (void*)(orig & (~1));
16991         orig_conv.is_owned = false;
16992         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
16993         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16994         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16995         uint64_t ret_ref = (uint64_t)ret_var.inner;
16996         if (ret_var.is_owned) {
16997                 ret_ref |= 1;
16998         }
16999         return ret_ref;
17000 }
17001
17002 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
17003         LDKChannelReestablish this_obj_conv;
17004         this_obj_conv.inner = (void*)(this_obj & (~1));
17005         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17006         ChannelReestablish_free(this_obj_conv);
17007 }
17008
17009 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
17010         LDKChannelReestablish this_ptr_conv;
17011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17012         this_ptr_conv.is_owned = false;
17013         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17014         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
17015         return ret_arr;
17016 }
17017
17018 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17019         LDKChannelReestablish this_ptr_conv;
17020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17021         this_ptr_conv.is_owned = false;
17022         LDKThirtyTwoBytes val_ref;
17023         CHECK(*((uint32_t*)val) == 32);
17024         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17025         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
17026 }
17027
17028 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
17029         LDKChannelReestablish this_ptr_conv;
17030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17031         this_ptr_conv.is_owned = false;
17032         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
17033         return ret_val;
17034 }
17035
17036 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
17037         LDKChannelReestablish this_ptr_conv;
17038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17039         this_ptr_conv.is_owned = false;
17040         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
17041 }
17042
17043 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
17044         LDKChannelReestablish this_ptr_conv;
17045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17046         this_ptr_conv.is_owned = false;
17047         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
17048         return ret_val;
17049 }
17050
17051 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
17052         LDKChannelReestablish this_ptr_conv;
17053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17054         this_ptr_conv.is_owned = false;
17055         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
17056 }
17057
17058 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
17059         LDKChannelReestablish orig_conv;
17060         orig_conv.inner = (void*)(orig & (~1));
17061         orig_conv.is_owned = false;
17062         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
17063         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17064         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17065         uint64_t ret_ref = (uint64_t)ret_var.inner;
17066         if (ret_var.is_owned) {
17067                 ret_ref |= 1;
17068         }
17069         return ret_ref;
17070 }
17071
17072 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
17073         LDKAnnouncementSignatures this_obj_conv;
17074         this_obj_conv.inner = (void*)(this_obj & (~1));
17075         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17076         AnnouncementSignatures_free(this_obj_conv);
17077 }
17078
17079 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
17080         LDKAnnouncementSignatures this_ptr_conv;
17081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17082         this_ptr_conv.is_owned = false;
17083         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17084         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
17085         return ret_arr;
17086 }
17087
17088 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17089         LDKAnnouncementSignatures this_ptr_conv;
17090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17091         this_ptr_conv.is_owned = false;
17092         LDKThirtyTwoBytes val_ref;
17093         CHECK(*((uint32_t*)val) == 32);
17094         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17095         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
17096 }
17097
17098 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
17099         LDKAnnouncementSignatures this_ptr_conv;
17100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17101         this_ptr_conv.is_owned = false;
17102         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
17103         return ret_val;
17104 }
17105
17106 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
17107         LDKAnnouncementSignatures this_ptr_conv;
17108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17109         this_ptr_conv.is_owned = false;
17110         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
17111 }
17112
17113 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
17114         LDKAnnouncementSignatures this_ptr_conv;
17115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17116         this_ptr_conv.is_owned = false;
17117         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17118         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
17119         return ret_arr;
17120 }
17121
17122 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
17123         LDKAnnouncementSignatures this_ptr_conv;
17124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17125         this_ptr_conv.is_owned = false;
17126         LDKSignature val_ref;
17127         CHECK(*((uint32_t*)val) == 64);
17128         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17129         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
17130 }
17131
17132 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
17133         LDKAnnouncementSignatures this_ptr_conv;
17134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17135         this_ptr_conv.is_owned = false;
17136         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17137         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
17138         return ret_arr;
17139 }
17140
17141 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
17142         LDKAnnouncementSignatures this_ptr_conv;
17143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17144         this_ptr_conv.is_owned = false;
17145         LDKSignature val_ref;
17146         CHECK(*((uint32_t*)val) == 64);
17147         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17148         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
17149 }
17150
17151 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) {
17152         LDKThirtyTwoBytes channel_id_arg_ref;
17153         CHECK(*((uint32_t*)channel_id_arg) == 32);
17154         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17155         LDKSignature node_signature_arg_ref;
17156         CHECK(*((uint32_t*)node_signature_arg) == 64);
17157         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
17158         LDKSignature bitcoin_signature_arg_ref;
17159         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
17160         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
17161         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
17162         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17163         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17164         uint64_t ret_ref = (uint64_t)ret_var.inner;
17165         if (ret_var.is_owned) {
17166                 ret_ref |= 1;
17167         }
17168         return ret_ref;
17169 }
17170
17171 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
17172         LDKAnnouncementSignatures orig_conv;
17173         orig_conv.inner = (void*)(orig & (~1));
17174         orig_conv.is_owned = false;
17175         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
17176         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17177         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17178         uint64_t ret_ref = (uint64_t)ret_var.inner;
17179         if (ret_var.is_owned) {
17180                 ret_ref |= 1;
17181         }
17182         return ret_ref;
17183 }
17184
17185 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
17186         if ((this_ptr & 1) != 0) return;
17187         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
17188         FREE((void*)this_ptr);
17189         NetAddress_free(this_ptr_conv);
17190 }
17191
17192 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
17193         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
17194         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
17195         *ret_copy = NetAddress_clone(orig_conv);
17196         uint64_t ret_ref = (uint64_t)ret_copy;
17197         return ret_ref;
17198 }
17199
17200 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
17201         LDKFourBytes addr_ref;
17202         CHECK(*((uint32_t*)addr) == 4);
17203         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 4);
17204         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
17205         *ret_copy = NetAddress_ipv4(addr_ref, port);
17206         uint64_t ret_ref = (uint64_t)ret_copy;
17207         return ret_ref;
17208 }
17209
17210 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
17211         LDKSixteenBytes addr_ref;
17212         CHECK(*((uint32_t*)addr) == 16);
17213         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 16);
17214         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
17215         *ret_copy = NetAddress_ipv6(addr_ref, port);
17216         uint64_t ret_ref = (uint64_t)ret_copy;
17217         return ret_ref;
17218 }
17219
17220 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v2(int8_tArray addr, int16_t port) {
17221         LDKTenBytes addr_ref;
17222         CHECK(*((uint32_t*)addr) == 10);
17223         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 10);
17224         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
17225         *ret_copy = NetAddress_onion_v2(addr_ref, port);
17226         uint64_t ret_ref = (uint64_t)ret_copy;
17227         return ret_ref;
17228 }
17229
17230 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v3(int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
17231         LDKThirtyTwoBytes ed25519_pubkey_ref;
17232         CHECK(*((uint32_t*)ed25519_pubkey) == 32);
17233         memcpy(ed25519_pubkey_ref.data, (uint8_t*)(ed25519_pubkey + 4), 32);
17234         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
17235         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
17236         uint64_t ret_ref = (uint64_t)ret_copy;
17237         return ret_ref;
17238 }
17239
17240 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
17241         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
17242         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
17243         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17244         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17245         CVec_u8Z_free(ret_var);
17246         return ret_arr;
17247 }
17248
17249 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
17250         LDKu8slice ser_ref;
17251         ser_ref.datalen = *((uint32_t*)ser);
17252         ser_ref.data = (int8_t*)(ser + 4);
17253         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
17254         *ret_conv = Result_read(ser_ref);
17255         return (uint64_t)ret_conv;
17256 }
17257
17258 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
17259         LDKu8slice ser_ref;
17260         ser_ref.datalen = *((uint32_t*)ser);
17261         ser_ref.data = (int8_t*)(ser + 4);
17262         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17263         *ret_conv = NetAddress_read(ser_ref);
17264         return (uint64_t)ret_conv;
17265 }
17266
17267 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
17268         LDKUnsignedNodeAnnouncement this_obj_conv;
17269         this_obj_conv.inner = (void*)(this_obj & (~1));
17270         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17271         UnsignedNodeAnnouncement_free(this_obj_conv);
17272 }
17273
17274 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
17275         LDKUnsignedNodeAnnouncement this_ptr_conv;
17276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17277         this_ptr_conv.is_owned = false;
17278         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
17279         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17280         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17281         uint64_t ret_ref = (uint64_t)ret_var.inner;
17282         if (ret_var.is_owned) {
17283                 ret_ref |= 1;
17284         }
17285         return ret_ref;
17286 }
17287
17288 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
17289         LDKUnsignedNodeAnnouncement this_ptr_conv;
17290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17291         this_ptr_conv.is_owned = false;
17292         LDKNodeFeatures val_conv;
17293         val_conv.inner = (void*)(val & (~1));
17294         val_conv.is_owned = (val & 1) || (val == 0);
17295         val_conv = NodeFeatures_clone(&val_conv);
17296         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
17297 }
17298
17299 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
17300         LDKUnsignedNodeAnnouncement this_ptr_conv;
17301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17302         this_ptr_conv.is_owned = false;
17303         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
17304         return ret_val;
17305 }
17306
17307 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
17308         LDKUnsignedNodeAnnouncement this_ptr_conv;
17309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17310         this_ptr_conv.is_owned = false;
17311         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
17312 }
17313
17314 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
17315         LDKUnsignedNodeAnnouncement this_ptr_conv;
17316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17317         this_ptr_conv.is_owned = false;
17318         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17319         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
17320         return ret_arr;
17321 }
17322
17323 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
17324         LDKUnsignedNodeAnnouncement this_ptr_conv;
17325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17326         this_ptr_conv.is_owned = false;
17327         LDKPublicKey val_ref;
17328         CHECK(*((uint32_t*)val) == 33);
17329         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17330         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
17331 }
17332
17333 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
17334         LDKUnsignedNodeAnnouncement this_ptr_conv;
17335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17336         this_ptr_conv.is_owned = false;
17337         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
17338         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
17339         return ret_arr;
17340 }
17341
17342 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
17343         LDKUnsignedNodeAnnouncement this_ptr_conv;
17344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17345         this_ptr_conv.is_owned = false;
17346         LDKThreeBytes val_ref;
17347         CHECK(*((uint32_t*)val) == 3);
17348         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
17349         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
17350 }
17351
17352 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
17353         LDKUnsignedNodeAnnouncement this_ptr_conv;
17354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17355         this_ptr_conv.is_owned = false;
17356         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17357         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
17358         return ret_arr;
17359 }
17360
17361 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
17362         LDKUnsignedNodeAnnouncement this_ptr_conv;
17363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17364         this_ptr_conv.is_owned = false;
17365         LDKThirtyTwoBytes val_ref;
17366         CHECK(*((uint32_t*)val) == 32);
17367         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17368         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
17369 }
17370
17371 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
17372         LDKUnsignedNodeAnnouncement this_ptr_conv;
17373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17374         this_ptr_conv.is_owned = false;
17375         LDKCVec_NetAddressZ val_constr;
17376         val_constr.datalen = *((uint32_t*)val);
17377         if (val_constr.datalen > 0)
17378                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17379         else
17380                 val_constr.data = NULL;
17381         uint32_t* val_vals = (uint32_t*)(val + 4);
17382         for (size_t m = 0; m < val_constr.datalen; m++) {
17383                 uint32_t val_conv_12 = val_vals[m];
17384                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
17385                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
17386                 val_constr.data[m] = val_conv_12_conv;
17387         }
17388         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
17389 }
17390
17391 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
17392         LDKUnsignedNodeAnnouncement orig_conv;
17393         orig_conv.inner = (void*)(orig & (~1));
17394         orig_conv.is_owned = false;
17395         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
17396         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17397         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17398         uint64_t ret_ref = (uint64_t)ret_var.inner;
17399         if (ret_var.is_owned) {
17400                 ret_ref |= 1;
17401         }
17402         return ret_ref;
17403 }
17404
17405 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
17406         LDKNodeAnnouncement this_obj_conv;
17407         this_obj_conv.inner = (void*)(this_obj & (~1));
17408         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17409         NodeAnnouncement_free(this_obj_conv);
17410 }
17411
17412 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
17413         LDKNodeAnnouncement this_ptr_conv;
17414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17415         this_ptr_conv.is_owned = false;
17416         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17417         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
17418         return ret_arr;
17419 }
17420
17421 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
17422         LDKNodeAnnouncement this_ptr_conv;
17423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17424         this_ptr_conv.is_owned = false;
17425         LDKSignature val_ref;
17426         CHECK(*((uint32_t*)val) == 64);
17427         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17428         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
17429 }
17430
17431 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
17432         LDKNodeAnnouncement this_ptr_conv;
17433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17434         this_ptr_conv.is_owned = false;
17435         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
17436         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17437         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17438         uint64_t ret_ref = (uint64_t)ret_var.inner;
17439         if (ret_var.is_owned) {
17440                 ret_ref |= 1;
17441         }
17442         return ret_ref;
17443 }
17444
17445 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
17446         LDKNodeAnnouncement this_ptr_conv;
17447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17448         this_ptr_conv.is_owned = false;
17449         LDKUnsignedNodeAnnouncement val_conv;
17450         val_conv.inner = (void*)(val & (~1));
17451         val_conv.is_owned = (val & 1) || (val == 0);
17452         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
17453         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
17454 }
17455
17456 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
17457         LDKSignature signature_arg_ref;
17458         CHECK(*((uint32_t*)signature_arg) == 64);
17459         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
17460         LDKUnsignedNodeAnnouncement contents_arg_conv;
17461         contents_arg_conv.inner = (void*)(contents_arg & (~1));
17462         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
17463         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
17464         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
17465         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17466         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17467         uint64_t ret_ref = (uint64_t)ret_var.inner;
17468         if (ret_var.is_owned) {
17469                 ret_ref |= 1;
17470         }
17471         return ret_ref;
17472 }
17473
17474 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
17475         LDKNodeAnnouncement orig_conv;
17476         orig_conv.inner = (void*)(orig & (~1));
17477         orig_conv.is_owned = false;
17478         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
17479         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17480         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17481         uint64_t ret_ref = (uint64_t)ret_var.inner;
17482         if (ret_var.is_owned) {
17483                 ret_ref |= 1;
17484         }
17485         return ret_ref;
17486 }
17487
17488 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
17489         LDKUnsignedChannelAnnouncement this_obj_conv;
17490         this_obj_conv.inner = (void*)(this_obj & (~1));
17491         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17492         UnsignedChannelAnnouncement_free(this_obj_conv);
17493 }
17494
17495 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
17496         LDKUnsignedChannelAnnouncement this_ptr_conv;
17497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17498         this_ptr_conv.is_owned = false;
17499         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
17500         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17501         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17502         uint64_t ret_ref = (uint64_t)ret_var.inner;
17503         if (ret_var.is_owned) {
17504                 ret_ref |= 1;
17505         }
17506         return ret_ref;
17507 }
17508
17509 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
17510         LDKUnsignedChannelAnnouncement this_ptr_conv;
17511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17512         this_ptr_conv.is_owned = false;
17513         LDKChannelFeatures val_conv;
17514         val_conv.inner = (void*)(val & (~1));
17515         val_conv.is_owned = (val & 1) || (val == 0);
17516         val_conv = ChannelFeatures_clone(&val_conv);
17517         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
17518 }
17519
17520 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
17521         LDKUnsignedChannelAnnouncement this_ptr_conv;
17522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17523         this_ptr_conv.is_owned = false;
17524         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17525         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
17526         return ret_arr;
17527 }
17528
17529 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17530         LDKUnsignedChannelAnnouncement this_ptr_conv;
17531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17532         this_ptr_conv.is_owned = false;
17533         LDKThirtyTwoBytes val_ref;
17534         CHECK(*((uint32_t*)val) == 32);
17535         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17536         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
17537 }
17538
17539 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
17540         LDKUnsignedChannelAnnouncement this_ptr_conv;
17541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17542         this_ptr_conv.is_owned = false;
17543         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
17544         return ret_val;
17545 }
17546
17547 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
17548         LDKUnsignedChannelAnnouncement this_ptr_conv;
17549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17550         this_ptr_conv.is_owned = false;
17551         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
17552 }
17553
17554 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
17555         LDKUnsignedChannelAnnouncement this_ptr_conv;
17556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17557         this_ptr_conv.is_owned = false;
17558         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17559         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
17560         return ret_arr;
17561 }
17562
17563 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
17564         LDKUnsignedChannelAnnouncement this_ptr_conv;
17565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17566         this_ptr_conv.is_owned = false;
17567         LDKPublicKey val_ref;
17568         CHECK(*((uint32_t*)val) == 33);
17569         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17570         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
17571 }
17572
17573 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
17574         LDKUnsignedChannelAnnouncement this_ptr_conv;
17575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17576         this_ptr_conv.is_owned = false;
17577         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17578         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
17579         return ret_arr;
17580 }
17581
17582 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
17583         LDKUnsignedChannelAnnouncement this_ptr_conv;
17584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17585         this_ptr_conv.is_owned = false;
17586         LDKPublicKey val_ref;
17587         CHECK(*((uint32_t*)val) == 33);
17588         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17589         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
17590 }
17591
17592 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
17593         LDKUnsignedChannelAnnouncement this_ptr_conv;
17594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17595         this_ptr_conv.is_owned = false;
17596         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17597         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
17598         return ret_arr;
17599 }
17600
17601 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
17602         LDKUnsignedChannelAnnouncement this_ptr_conv;
17603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17604         this_ptr_conv.is_owned = false;
17605         LDKPublicKey val_ref;
17606         CHECK(*((uint32_t*)val) == 33);
17607         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17608         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
17609 }
17610
17611 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
17612         LDKUnsignedChannelAnnouncement this_ptr_conv;
17613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17614         this_ptr_conv.is_owned = false;
17615         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17616         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
17617         return ret_arr;
17618 }
17619
17620 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
17621         LDKUnsignedChannelAnnouncement this_ptr_conv;
17622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17623         this_ptr_conv.is_owned = false;
17624         LDKPublicKey val_ref;
17625         CHECK(*((uint32_t*)val) == 33);
17626         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17627         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
17628 }
17629
17630 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
17631         LDKUnsignedChannelAnnouncement orig_conv;
17632         orig_conv.inner = (void*)(orig & (~1));
17633         orig_conv.is_owned = false;
17634         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
17635         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17636         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17637         uint64_t ret_ref = (uint64_t)ret_var.inner;
17638         if (ret_var.is_owned) {
17639                 ret_ref |= 1;
17640         }
17641         return ret_ref;
17642 }
17643
17644 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
17645         LDKChannelAnnouncement this_obj_conv;
17646         this_obj_conv.inner = (void*)(this_obj & (~1));
17647         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17648         ChannelAnnouncement_free(this_obj_conv);
17649 }
17650
17651 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
17652         LDKChannelAnnouncement this_ptr_conv;
17653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17654         this_ptr_conv.is_owned = false;
17655         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17656         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
17657         return ret_arr;
17658 }
17659
17660 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
17661         LDKChannelAnnouncement this_ptr_conv;
17662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17663         this_ptr_conv.is_owned = false;
17664         LDKSignature val_ref;
17665         CHECK(*((uint32_t*)val) == 64);
17666         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17667         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
17668 }
17669
17670 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
17671         LDKChannelAnnouncement this_ptr_conv;
17672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17673         this_ptr_conv.is_owned = false;
17674         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17675         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
17676         return ret_arr;
17677 }
17678
17679 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
17680         LDKChannelAnnouncement this_ptr_conv;
17681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17682         this_ptr_conv.is_owned = false;
17683         LDKSignature val_ref;
17684         CHECK(*((uint32_t*)val) == 64);
17685         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17686         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
17687 }
17688
17689 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
17690         LDKChannelAnnouncement this_ptr_conv;
17691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17692         this_ptr_conv.is_owned = false;
17693         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17694         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
17695         return ret_arr;
17696 }
17697
17698 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
17699         LDKChannelAnnouncement this_ptr_conv;
17700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17701         this_ptr_conv.is_owned = false;
17702         LDKSignature val_ref;
17703         CHECK(*((uint32_t*)val) == 64);
17704         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17705         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
17706 }
17707
17708 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
17709         LDKChannelAnnouncement this_ptr_conv;
17710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17711         this_ptr_conv.is_owned = false;
17712         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17713         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
17714         return ret_arr;
17715 }
17716
17717 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
17718         LDKChannelAnnouncement this_ptr_conv;
17719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17720         this_ptr_conv.is_owned = false;
17721         LDKSignature val_ref;
17722         CHECK(*((uint32_t*)val) == 64);
17723         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17724         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
17725 }
17726
17727 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
17728         LDKChannelAnnouncement this_ptr_conv;
17729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17730         this_ptr_conv.is_owned = false;
17731         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
17732         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17733         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17734         uint64_t ret_ref = (uint64_t)ret_var.inner;
17735         if (ret_var.is_owned) {
17736                 ret_ref |= 1;
17737         }
17738         return ret_ref;
17739 }
17740
17741 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
17742         LDKChannelAnnouncement this_ptr_conv;
17743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17744         this_ptr_conv.is_owned = false;
17745         LDKUnsignedChannelAnnouncement val_conv;
17746         val_conv.inner = (void*)(val & (~1));
17747         val_conv.is_owned = (val & 1) || (val == 0);
17748         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
17749         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
17750 }
17751
17752 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) {
17753         LDKSignature node_signature_1_arg_ref;
17754         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
17755         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
17756         LDKSignature node_signature_2_arg_ref;
17757         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
17758         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
17759         LDKSignature bitcoin_signature_1_arg_ref;
17760         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
17761         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
17762         LDKSignature bitcoin_signature_2_arg_ref;
17763         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
17764         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
17765         LDKUnsignedChannelAnnouncement contents_arg_conv;
17766         contents_arg_conv.inner = (void*)(contents_arg & (~1));
17767         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
17768         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
17769         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);
17770         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17771         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17772         uint64_t ret_ref = (uint64_t)ret_var.inner;
17773         if (ret_var.is_owned) {
17774                 ret_ref |= 1;
17775         }
17776         return ret_ref;
17777 }
17778
17779 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
17780         LDKChannelAnnouncement orig_conv;
17781         orig_conv.inner = (void*)(orig & (~1));
17782         orig_conv.is_owned = false;
17783         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
17784         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17785         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17786         uint64_t ret_ref = (uint64_t)ret_var.inner;
17787         if (ret_var.is_owned) {
17788                 ret_ref |= 1;
17789         }
17790         return ret_ref;
17791 }
17792
17793 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
17794         LDKUnsignedChannelUpdate this_obj_conv;
17795         this_obj_conv.inner = (void*)(this_obj & (~1));
17796         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17797         UnsignedChannelUpdate_free(this_obj_conv);
17798 }
17799
17800 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
17801         LDKUnsignedChannelUpdate this_ptr_conv;
17802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17803         this_ptr_conv.is_owned = false;
17804         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17805         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
17806         return ret_arr;
17807 }
17808
17809 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17810         LDKUnsignedChannelUpdate this_ptr_conv;
17811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17812         this_ptr_conv.is_owned = false;
17813         LDKThirtyTwoBytes val_ref;
17814         CHECK(*((uint32_t*)val) == 32);
17815         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17816         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
17817 }
17818
17819 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
17820         LDKUnsignedChannelUpdate this_ptr_conv;
17821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17822         this_ptr_conv.is_owned = false;
17823         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
17824         return ret_val;
17825 }
17826
17827 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
17828         LDKUnsignedChannelUpdate this_ptr_conv;
17829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17830         this_ptr_conv.is_owned = false;
17831         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
17832 }
17833
17834 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
17835         LDKUnsignedChannelUpdate this_ptr_conv;
17836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17837         this_ptr_conv.is_owned = false;
17838         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
17839         return ret_val;
17840 }
17841
17842 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
17843         LDKUnsignedChannelUpdate this_ptr_conv;
17844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17845         this_ptr_conv.is_owned = false;
17846         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
17847 }
17848
17849 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
17850         LDKUnsignedChannelUpdate this_ptr_conv;
17851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17852         this_ptr_conv.is_owned = false;
17853         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
17854         return ret_val;
17855 }
17856
17857 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
17858         LDKUnsignedChannelUpdate this_ptr_conv;
17859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17860         this_ptr_conv.is_owned = false;
17861         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
17862 }
17863
17864 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
17865         LDKUnsignedChannelUpdate this_ptr_conv;
17866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17867         this_ptr_conv.is_owned = false;
17868         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
17869         return ret_val;
17870 }
17871
17872 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
17873         LDKUnsignedChannelUpdate this_ptr_conv;
17874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17875         this_ptr_conv.is_owned = false;
17876         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
17877 }
17878
17879 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
17880         LDKUnsignedChannelUpdate this_ptr_conv;
17881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17882         this_ptr_conv.is_owned = false;
17883         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
17884         return ret_val;
17885 }
17886
17887 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
17888         LDKUnsignedChannelUpdate this_ptr_conv;
17889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17890         this_ptr_conv.is_owned = false;
17891         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
17892 }
17893
17894 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
17895         LDKUnsignedChannelUpdate this_ptr_conv;
17896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17897         this_ptr_conv.is_owned = false;
17898         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
17899         return ret_val;
17900 }
17901
17902 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
17903         LDKUnsignedChannelUpdate this_ptr_conv;
17904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17905         this_ptr_conv.is_owned = false;
17906         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
17907 }
17908
17909 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
17910         LDKUnsignedChannelUpdate this_ptr_conv;
17911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17912         this_ptr_conv.is_owned = false;
17913         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
17914         return ret_val;
17915 }
17916
17917 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
17918         LDKUnsignedChannelUpdate this_ptr_conv;
17919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17920         this_ptr_conv.is_owned = false;
17921         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
17922 }
17923
17924 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
17925         LDKUnsignedChannelUpdate orig_conv;
17926         orig_conv.inner = (void*)(orig & (~1));
17927         orig_conv.is_owned = false;
17928         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
17929         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17930         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17931         uint64_t ret_ref = (uint64_t)ret_var.inner;
17932         if (ret_var.is_owned) {
17933                 ret_ref |= 1;
17934         }
17935         return ret_ref;
17936 }
17937
17938 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
17939         LDKChannelUpdate this_obj_conv;
17940         this_obj_conv.inner = (void*)(this_obj & (~1));
17941         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17942         ChannelUpdate_free(this_obj_conv);
17943 }
17944
17945 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
17946         LDKChannelUpdate this_ptr_conv;
17947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17948         this_ptr_conv.is_owned = false;
17949         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17950         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
17951         return ret_arr;
17952 }
17953
17954 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
17955         LDKChannelUpdate this_ptr_conv;
17956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17957         this_ptr_conv.is_owned = false;
17958         LDKSignature val_ref;
17959         CHECK(*((uint32_t*)val) == 64);
17960         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17961         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
17962 }
17963
17964 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
17965         LDKChannelUpdate this_ptr_conv;
17966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17967         this_ptr_conv.is_owned = false;
17968         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
17969         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17970         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17971         uint64_t ret_ref = (uint64_t)ret_var.inner;
17972         if (ret_var.is_owned) {
17973                 ret_ref |= 1;
17974         }
17975         return ret_ref;
17976 }
17977
17978 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
17979         LDKChannelUpdate this_ptr_conv;
17980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17981         this_ptr_conv.is_owned = false;
17982         LDKUnsignedChannelUpdate val_conv;
17983         val_conv.inner = (void*)(val & (~1));
17984         val_conv.is_owned = (val & 1) || (val == 0);
17985         val_conv = UnsignedChannelUpdate_clone(&val_conv);
17986         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
17987 }
17988
17989 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
17990         LDKSignature signature_arg_ref;
17991         CHECK(*((uint32_t*)signature_arg) == 64);
17992         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
17993         LDKUnsignedChannelUpdate contents_arg_conv;
17994         contents_arg_conv.inner = (void*)(contents_arg & (~1));
17995         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
17996         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
17997         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
17998         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17999         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18000         uint64_t ret_ref = (uint64_t)ret_var.inner;
18001         if (ret_var.is_owned) {
18002                 ret_ref |= 1;
18003         }
18004         return ret_ref;
18005 }
18006
18007 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
18008         LDKChannelUpdate orig_conv;
18009         orig_conv.inner = (void*)(orig & (~1));
18010         orig_conv.is_owned = false;
18011         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
18012         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18013         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18014         uint64_t ret_ref = (uint64_t)ret_var.inner;
18015         if (ret_var.is_owned) {
18016                 ret_ref |= 1;
18017         }
18018         return ret_ref;
18019 }
18020
18021 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
18022         LDKQueryChannelRange this_obj_conv;
18023         this_obj_conv.inner = (void*)(this_obj & (~1));
18024         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18025         QueryChannelRange_free(this_obj_conv);
18026 }
18027
18028 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
18029         LDKQueryChannelRange this_ptr_conv;
18030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18031         this_ptr_conv.is_owned = false;
18032         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18033         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
18034         return ret_arr;
18035 }
18036
18037 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
18038         LDKQueryChannelRange this_ptr_conv;
18039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18040         this_ptr_conv.is_owned = false;
18041         LDKThirtyTwoBytes val_ref;
18042         CHECK(*((uint32_t*)val) == 32);
18043         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18044         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
18045 }
18046
18047 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
18048         LDKQueryChannelRange this_ptr_conv;
18049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18050         this_ptr_conv.is_owned = false;
18051         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
18052         return ret_val;
18053 }
18054
18055 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
18056         LDKQueryChannelRange this_ptr_conv;
18057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18058         this_ptr_conv.is_owned = false;
18059         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
18060 }
18061
18062 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
18063         LDKQueryChannelRange this_ptr_conv;
18064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18065         this_ptr_conv.is_owned = false;
18066         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
18067         return ret_val;
18068 }
18069
18070 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
18071         LDKQueryChannelRange this_ptr_conv;
18072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18073         this_ptr_conv.is_owned = false;
18074         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
18075 }
18076
18077 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
18078         LDKThirtyTwoBytes chain_hash_arg_ref;
18079         CHECK(*((uint32_t*)chain_hash_arg) == 32);
18080         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
18081         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
18082         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18083         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18084         uint64_t ret_ref = (uint64_t)ret_var.inner;
18085         if (ret_var.is_owned) {
18086                 ret_ref |= 1;
18087         }
18088         return ret_ref;
18089 }
18090
18091 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
18092         LDKQueryChannelRange orig_conv;
18093         orig_conv.inner = (void*)(orig & (~1));
18094         orig_conv.is_owned = false;
18095         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
18096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18098         uint64_t ret_ref = (uint64_t)ret_var.inner;
18099         if (ret_var.is_owned) {
18100                 ret_ref |= 1;
18101         }
18102         return ret_ref;
18103 }
18104
18105 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
18106         LDKReplyChannelRange this_obj_conv;
18107         this_obj_conv.inner = (void*)(this_obj & (~1));
18108         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18109         ReplyChannelRange_free(this_obj_conv);
18110 }
18111
18112 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
18113         LDKReplyChannelRange this_ptr_conv;
18114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18115         this_ptr_conv.is_owned = false;
18116         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18117         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
18118         return ret_arr;
18119 }
18120
18121 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
18122         LDKReplyChannelRange this_ptr_conv;
18123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18124         this_ptr_conv.is_owned = false;
18125         LDKThirtyTwoBytes val_ref;
18126         CHECK(*((uint32_t*)val) == 32);
18127         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18128         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
18129 }
18130
18131 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
18132         LDKReplyChannelRange this_ptr_conv;
18133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18134         this_ptr_conv.is_owned = false;
18135         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
18136         return ret_val;
18137 }
18138
18139 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
18140         LDKReplyChannelRange this_ptr_conv;
18141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18142         this_ptr_conv.is_owned = false;
18143         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
18144 }
18145
18146 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
18147         LDKReplyChannelRange this_ptr_conv;
18148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18149         this_ptr_conv.is_owned = false;
18150         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
18151         return ret_val;
18152 }
18153
18154 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
18155         LDKReplyChannelRange this_ptr_conv;
18156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18157         this_ptr_conv.is_owned = false;
18158         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
18159 }
18160
18161 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
18162         LDKReplyChannelRange this_ptr_conv;
18163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18164         this_ptr_conv.is_owned = false;
18165         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
18166         return ret_val;
18167 }
18168
18169 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
18170         LDKReplyChannelRange this_ptr_conv;
18171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18172         this_ptr_conv.is_owned = false;
18173         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
18174 }
18175
18176 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
18177         LDKReplyChannelRange this_ptr_conv;
18178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18179         this_ptr_conv.is_owned = false;
18180         LDKCVec_u64Z val_constr;
18181         val_constr.datalen = *((uint32_t*)val);
18182         if (val_constr.datalen > 0)
18183                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
18184         else
18185                 val_constr.data = NULL;
18186         int64_t* val_vals = (int64_t*)(val + 4);
18187         for (size_t i = 0; i < val_constr.datalen; i++) {
18188                 int64_t val_conv_8 = val_vals[i];
18189                 val_constr.data[i] = val_conv_8;
18190         }
18191         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
18192 }
18193
18194 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) {
18195         LDKThirtyTwoBytes chain_hash_arg_ref;
18196         CHECK(*((uint32_t*)chain_hash_arg) == 32);
18197         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
18198         LDKCVec_u64Z short_channel_ids_arg_constr;
18199         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
18200         if (short_channel_ids_arg_constr.datalen > 0)
18201                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
18202         else
18203                 short_channel_ids_arg_constr.data = NULL;
18204         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
18205         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
18206                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
18207                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
18208         }
18209         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
18210         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18211         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18212         uint64_t ret_ref = (uint64_t)ret_var.inner;
18213         if (ret_var.is_owned) {
18214                 ret_ref |= 1;
18215         }
18216         return ret_ref;
18217 }
18218
18219 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
18220         LDKReplyChannelRange orig_conv;
18221         orig_conv.inner = (void*)(orig & (~1));
18222         orig_conv.is_owned = false;
18223         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
18224         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18225         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18226         uint64_t ret_ref = (uint64_t)ret_var.inner;
18227         if (ret_var.is_owned) {
18228                 ret_ref |= 1;
18229         }
18230         return ret_ref;
18231 }
18232
18233 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
18234         LDKQueryShortChannelIds this_obj_conv;
18235         this_obj_conv.inner = (void*)(this_obj & (~1));
18236         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18237         QueryShortChannelIds_free(this_obj_conv);
18238 }
18239
18240 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
18241         LDKQueryShortChannelIds this_ptr_conv;
18242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18243         this_ptr_conv.is_owned = false;
18244         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18245         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
18246         return ret_arr;
18247 }
18248
18249 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
18250         LDKQueryShortChannelIds this_ptr_conv;
18251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18252         this_ptr_conv.is_owned = false;
18253         LDKThirtyTwoBytes val_ref;
18254         CHECK(*((uint32_t*)val) == 32);
18255         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18256         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
18257 }
18258
18259 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
18260         LDKQueryShortChannelIds this_ptr_conv;
18261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18262         this_ptr_conv.is_owned = false;
18263         LDKCVec_u64Z val_constr;
18264         val_constr.datalen = *((uint32_t*)val);
18265         if (val_constr.datalen > 0)
18266                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
18267         else
18268                 val_constr.data = NULL;
18269         int64_t* val_vals = (int64_t*)(val + 4);
18270         for (size_t i = 0; i < val_constr.datalen; i++) {
18271                 int64_t val_conv_8 = val_vals[i];
18272                 val_constr.data[i] = val_conv_8;
18273         }
18274         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
18275 }
18276
18277 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
18278         LDKThirtyTwoBytes chain_hash_arg_ref;
18279         CHECK(*((uint32_t*)chain_hash_arg) == 32);
18280         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
18281         LDKCVec_u64Z short_channel_ids_arg_constr;
18282         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
18283         if (short_channel_ids_arg_constr.datalen > 0)
18284                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
18285         else
18286                 short_channel_ids_arg_constr.data = NULL;
18287         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
18288         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
18289                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
18290                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
18291         }
18292         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
18293         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18294         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18295         uint64_t ret_ref = (uint64_t)ret_var.inner;
18296         if (ret_var.is_owned) {
18297                 ret_ref |= 1;
18298         }
18299         return ret_ref;
18300 }
18301
18302 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
18303         LDKQueryShortChannelIds orig_conv;
18304         orig_conv.inner = (void*)(orig & (~1));
18305         orig_conv.is_owned = false;
18306         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
18307         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18308         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18309         uint64_t ret_ref = (uint64_t)ret_var.inner;
18310         if (ret_var.is_owned) {
18311                 ret_ref |= 1;
18312         }
18313         return ret_ref;
18314 }
18315
18316 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
18317         LDKReplyShortChannelIdsEnd this_obj_conv;
18318         this_obj_conv.inner = (void*)(this_obj & (~1));
18319         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18320         ReplyShortChannelIdsEnd_free(this_obj_conv);
18321 }
18322
18323 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
18324         LDKReplyShortChannelIdsEnd this_ptr_conv;
18325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18326         this_ptr_conv.is_owned = false;
18327         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18328         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
18329         return ret_arr;
18330 }
18331
18332 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
18333         LDKReplyShortChannelIdsEnd this_ptr_conv;
18334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18335         this_ptr_conv.is_owned = false;
18336         LDKThirtyTwoBytes val_ref;
18337         CHECK(*((uint32_t*)val) == 32);
18338         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18339         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
18340 }
18341
18342 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
18343         LDKReplyShortChannelIdsEnd this_ptr_conv;
18344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18345         this_ptr_conv.is_owned = false;
18346         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
18347         return ret_val;
18348 }
18349
18350 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
18351         LDKReplyShortChannelIdsEnd this_ptr_conv;
18352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18353         this_ptr_conv.is_owned = false;
18354         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
18355 }
18356
18357 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
18358         LDKThirtyTwoBytes chain_hash_arg_ref;
18359         CHECK(*((uint32_t*)chain_hash_arg) == 32);
18360         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
18361         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
18362         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18363         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18364         uint64_t ret_ref = (uint64_t)ret_var.inner;
18365         if (ret_var.is_owned) {
18366                 ret_ref |= 1;
18367         }
18368         return ret_ref;
18369 }
18370
18371 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
18372         LDKReplyShortChannelIdsEnd orig_conv;
18373         orig_conv.inner = (void*)(orig & (~1));
18374         orig_conv.is_owned = false;
18375         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
18376         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18377         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18378         uint64_t ret_ref = (uint64_t)ret_var.inner;
18379         if (ret_var.is_owned) {
18380                 ret_ref |= 1;
18381         }
18382         return ret_ref;
18383 }
18384
18385 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
18386         LDKGossipTimestampFilter this_obj_conv;
18387         this_obj_conv.inner = (void*)(this_obj & (~1));
18388         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18389         GossipTimestampFilter_free(this_obj_conv);
18390 }
18391
18392 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
18393         LDKGossipTimestampFilter this_ptr_conv;
18394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18395         this_ptr_conv.is_owned = false;
18396         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18397         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
18398         return ret_arr;
18399 }
18400
18401 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
18402         LDKGossipTimestampFilter this_ptr_conv;
18403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18404         this_ptr_conv.is_owned = false;
18405         LDKThirtyTwoBytes val_ref;
18406         CHECK(*((uint32_t*)val) == 32);
18407         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18408         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
18409 }
18410
18411 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
18412         LDKGossipTimestampFilter this_ptr_conv;
18413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18414         this_ptr_conv.is_owned = false;
18415         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
18416         return ret_val;
18417 }
18418
18419 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
18420         LDKGossipTimestampFilter this_ptr_conv;
18421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18422         this_ptr_conv.is_owned = false;
18423         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
18424 }
18425
18426 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
18427         LDKGossipTimestampFilter this_ptr_conv;
18428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18429         this_ptr_conv.is_owned = false;
18430         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
18431         return ret_val;
18432 }
18433
18434 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
18435         LDKGossipTimestampFilter this_ptr_conv;
18436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18437         this_ptr_conv.is_owned = false;
18438         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
18439 }
18440
18441 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
18442         LDKThirtyTwoBytes chain_hash_arg_ref;
18443         CHECK(*((uint32_t*)chain_hash_arg) == 32);
18444         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
18445         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
18446         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18447         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18448         uint64_t ret_ref = (uint64_t)ret_var.inner;
18449         if (ret_var.is_owned) {
18450                 ret_ref |= 1;
18451         }
18452         return ret_ref;
18453 }
18454
18455 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
18456         LDKGossipTimestampFilter orig_conv;
18457         orig_conv.inner = (void*)(orig & (~1));
18458         orig_conv.is_owned = false;
18459         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
18460         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18461         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18462         uint64_t ret_ref = (uint64_t)ret_var.inner;
18463         if (ret_var.is_owned) {
18464                 ret_ref |= 1;
18465         }
18466         return ret_ref;
18467 }
18468
18469 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
18470         if ((this_ptr & 1) != 0) return;
18471         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
18472         FREE((void*)this_ptr);
18473         ErrorAction_free(this_ptr_conv);
18474 }
18475
18476 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
18477         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
18478         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
18479         *ret_copy = ErrorAction_clone(orig_conv);
18480         uint64_t ret_ref = (uint64_t)ret_copy;
18481         return ret_ref;
18482 }
18483
18484 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
18485         LDKErrorMessage msg_conv;
18486         msg_conv.inner = (void*)(msg & (~1));
18487         msg_conv.is_owned = (msg & 1) || (msg == 0);
18488         msg_conv = ErrorMessage_clone(&msg_conv);
18489         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
18490         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
18491         uint64_t ret_ref = (uint64_t)ret_copy;
18492         return ret_ref;
18493 }
18494
18495 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_error() {
18496         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
18497         *ret_copy = ErrorAction_ignore_error();
18498         uint64_t ret_ref = (uint64_t)ret_copy;
18499         return ret_ref;
18500 }
18501
18502 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
18503         LDKLevel a_conv = LDKLevel_from_js(a);
18504         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
18505         *ret_copy = ErrorAction_ignore_and_log(a_conv);
18506         uint64_t ret_ref = (uint64_t)ret_copy;
18507         return ret_ref;
18508 }
18509
18510 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_send_error_message(uint32_t msg) {
18511         LDKErrorMessage msg_conv;
18512         msg_conv.inner = (void*)(msg & (~1));
18513         msg_conv.is_owned = (msg & 1) || (msg == 0);
18514         msg_conv = ErrorMessage_clone(&msg_conv);
18515         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
18516         *ret_copy = ErrorAction_send_error_message(msg_conv);
18517         uint64_t ret_ref = (uint64_t)ret_copy;
18518         return ret_ref;
18519 }
18520
18521 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
18522         LDKLightningError this_obj_conv;
18523         this_obj_conv.inner = (void*)(this_obj & (~1));
18524         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18525         LightningError_free(this_obj_conv);
18526 }
18527
18528 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
18529         LDKLightningError this_ptr_conv;
18530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18531         this_ptr_conv.is_owned = false;
18532         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
18533         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
18534         Str_free(ret_str);
18535         return ret_conv;
18536 }
18537
18538 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
18539         LDKLightningError this_ptr_conv;
18540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18541         this_ptr_conv.is_owned = false;
18542         LDKStr val_conv = str_ref_to_owned_c(val);
18543         LightningError_set_err(&this_ptr_conv, val_conv);
18544 }
18545
18546 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
18547         LDKLightningError this_ptr_conv;
18548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18549         this_ptr_conv.is_owned = false;
18550         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
18551         *ret_copy = LightningError_get_action(&this_ptr_conv);
18552         uint64_t ret_ref = (uint64_t)ret_copy;
18553         return ret_ref;
18554 }
18555
18556 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
18557         LDKLightningError this_ptr_conv;
18558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18559         this_ptr_conv.is_owned = false;
18560         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
18561         LightningError_set_action(&this_ptr_conv, val_conv);
18562 }
18563
18564 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
18565         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
18566         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
18567         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
18568         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18569         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18570         uint64_t ret_ref = (uint64_t)ret_var.inner;
18571         if (ret_var.is_owned) {
18572                 ret_ref |= 1;
18573         }
18574         return ret_ref;
18575 }
18576
18577 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
18578         LDKLightningError orig_conv;
18579         orig_conv.inner = (void*)(orig & (~1));
18580         orig_conv.is_owned = false;
18581         LDKLightningError ret_var = LightningError_clone(&orig_conv);
18582         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18583         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18584         uint64_t ret_ref = (uint64_t)ret_var.inner;
18585         if (ret_var.is_owned) {
18586                 ret_ref |= 1;
18587         }
18588         return ret_ref;
18589 }
18590
18591 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
18592         LDKCommitmentUpdate this_obj_conv;
18593         this_obj_conv.inner = (void*)(this_obj & (~1));
18594         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18595         CommitmentUpdate_free(this_obj_conv);
18596 }
18597
18598 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
18599         LDKCommitmentUpdate this_ptr_conv;
18600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18601         this_ptr_conv.is_owned = false;
18602         LDKCVec_UpdateAddHTLCZ val_constr;
18603         val_constr.datalen = *((uint32_t*)val);
18604         if (val_constr.datalen > 0)
18605                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
18606         else
18607                 val_constr.data = NULL;
18608         uint32_t* val_vals = (uint32_t*)(val + 4);
18609         for (size_t p = 0; p < val_constr.datalen; p++) {
18610                 uint32_t val_conv_15 = val_vals[p];
18611                 LDKUpdateAddHTLC val_conv_15_conv;
18612                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
18613                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
18614                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
18615                 val_constr.data[p] = val_conv_15_conv;
18616         }
18617         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
18618 }
18619
18620 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
18621         LDKCommitmentUpdate this_ptr_conv;
18622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18623         this_ptr_conv.is_owned = false;
18624         LDKCVec_UpdateFulfillHTLCZ val_constr;
18625         val_constr.datalen = *((uint32_t*)val);
18626         if (val_constr.datalen > 0)
18627                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
18628         else
18629                 val_constr.data = NULL;
18630         uint32_t* val_vals = (uint32_t*)(val + 4);
18631         for (size_t t = 0; t < val_constr.datalen; t++) {
18632                 uint32_t val_conv_19 = val_vals[t];
18633                 LDKUpdateFulfillHTLC val_conv_19_conv;
18634                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
18635                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
18636                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
18637                 val_constr.data[t] = val_conv_19_conv;
18638         }
18639         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
18640 }
18641
18642 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
18643         LDKCommitmentUpdate this_ptr_conv;
18644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18645         this_ptr_conv.is_owned = false;
18646         LDKCVec_UpdateFailHTLCZ val_constr;
18647         val_constr.datalen = *((uint32_t*)val);
18648         if (val_constr.datalen > 0)
18649                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
18650         else
18651                 val_constr.data = NULL;
18652         uint32_t* val_vals = (uint32_t*)(val + 4);
18653         for (size_t q = 0; q < val_constr.datalen; q++) {
18654                 uint32_t val_conv_16 = val_vals[q];
18655                 LDKUpdateFailHTLC val_conv_16_conv;
18656                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
18657                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
18658                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
18659                 val_constr.data[q] = val_conv_16_conv;
18660         }
18661         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
18662 }
18663
18664 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
18665         LDKCommitmentUpdate this_ptr_conv;
18666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18667         this_ptr_conv.is_owned = false;
18668         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
18669         val_constr.datalen = *((uint32_t*)val);
18670         if (val_constr.datalen > 0)
18671                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
18672         else
18673                 val_constr.data = NULL;
18674         uint32_t* val_vals = (uint32_t*)(val + 4);
18675         for (size_t z = 0; z < val_constr.datalen; z++) {
18676                 uint32_t val_conv_25 = val_vals[z];
18677                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
18678                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
18679                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
18680                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
18681                 val_constr.data[z] = val_conv_25_conv;
18682         }
18683         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
18684 }
18685
18686 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
18687         LDKCommitmentUpdate this_ptr_conv;
18688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18689         this_ptr_conv.is_owned = false;
18690         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
18691         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18692         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18693         uint64_t ret_ref = (uint64_t)ret_var.inner;
18694         if (ret_var.is_owned) {
18695                 ret_ref |= 1;
18696         }
18697         return ret_ref;
18698 }
18699
18700 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
18701         LDKCommitmentUpdate this_ptr_conv;
18702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18703         this_ptr_conv.is_owned = false;
18704         LDKUpdateFee val_conv;
18705         val_conv.inner = (void*)(val & (~1));
18706         val_conv.is_owned = (val & 1) || (val == 0);
18707         val_conv = UpdateFee_clone(&val_conv);
18708         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
18709 }
18710
18711 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
18712         LDKCommitmentUpdate this_ptr_conv;
18713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18714         this_ptr_conv.is_owned = false;
18715         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
18716         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18717         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18718         uint64_t ret_ref = (uint64_t)ret_var.inner;
18719         if (ret_var.is_owned) {
18720                 ret_ref |= 1;
18721         }
18722         return ret_ref;
18723 }
18724
18725 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
18726         LDKCommitmentUpdate this_ptr_conv;
18727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18728         this_ptr_conv.is_owned = false;
18729         LDKCommitmentSigned val_conv;
18730         val_conv.inner = (void*)(val & (~1));
18731         val_conv.is_owned = (val & 1) || (val == 0);
18732         val_conv = CommitmentSigned_clone(&val_conv);
18733         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
18734 }
18735
18736 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) {
18737         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
18738         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
18739         if (update_add_htlcs_arg_constr.datalen > 0)
18740                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
18741         else
18742                 update_add_htlcs_arg_constr.data = NULL;
18743         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
18744         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
18745                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
18746                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
18747                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
18748                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
18749                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
18750                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
18751         }
18752         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
18753         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
18754         if (update_fulfill_htlcs_arg_constr.datalen > 0)
18755                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
18756         else
18757                 update_fulfill_htlcs_arg_constr.data = NULL;
18758         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
18759         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
18760                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
18761                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
18762                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
18763                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
18764                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
18765                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
18766         }
18767         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
18768         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
18769         if (update_fail_htlcs_arg_constr.datalen > 0)
18770                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
18771         else
18772                 update_fail_htlcs_arg_constr.data = NULL;
18773         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
18774         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
18775                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
18776                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
18777                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
18778                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
18779                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
18780                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
18781         }
18782         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
18783         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
18784         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
18785                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
18786         else
18787                 update_fail_malformed_htlcs_arg_constr.data = NULL;
18788         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
18789         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
18790                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
18791                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
18792                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
18793                 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);
18794                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
18795                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
18796         }
18797         LDKUpdateFee update_fee_arg_conv;
18798         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
18799         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
18800         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
18801         LDKCommitmentSigned commitment_signed_arg_conv;
18802         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
18803         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
18804         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
18805         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);
18806         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18807         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18808         uint64_t ret_ref = (uint64_t)ret_var.inner;
18809         if (ret_var.is_owned) {
18810                 ret_ref |= 1;
18811         }
18812         return ret_ref;
18813 }
18814
18815 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
18816         LDKCommitmentUpdate orig_conv;
18817         orig_conv.inner = (void*)(orig & (~1));
18818         orig_conv.is_owned = false;
18819         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
18820         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18821         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18822         uint64_t ret_ref = (uint64_t)ret_var.inner;
18823         if (ret_var.is_owned) {
18824                 ret_ref |= 1;
18825         }
18826         return ret_ref;
18827 }
18828
18829 void  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) {
18830         if ((this_ptr & 1) != 0) return;
18831         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
18832         FREE((void*)this_ptr);
18833         HTLCFailChannelUpdate_free(this_ptr_conv);
18834 }
18835
18836 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) {
18837         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
18838         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
18839         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
18840         uint64_t ret_ref = (uint64_t)ret_copy;
18841         return ret_ref;
18842 }
18843
18844 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_channel_update_message(uint32_t msg) {
18845         LDKChannelUpdate msg_conv;
18846         msg_conv.inner = (void*)(msg & (~1));
18847         msg_conv.is_owned = (msg & 1) || (msg == 0);
18848         msg_conv = ChannelUpdate_clone(&msg_conv);
18849         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
18850         *ret_copy = HTLCFailChannelUpdate_channel_update_message(msg_conv);
18851         uint64_t ret_ref = (uint64_t)ret_copy;
18852         return ret_ref;
18853 }
18854
18855 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
18856         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
18857         *ret_copy = HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent);
18858         uint64_t ret_ref = (uint64_t)ret_copy;
18859         return ret_ref;
18860 }
18861
18862 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
18863         LDKPublicKey node_id_ref;
18864         CHECK(*((uint32_t*)node_id) == 33);
18865         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
18866         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
18867         *ret_copy = HTLCFailChannelUpdate_node_failure(node_id_ref, is_permanent);
18868         uint64_t ret_ref = (uint64_t)ret_copy;
18869         return ret_ref;
18870 }
18871
18872 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
18873         if ((this_ptr & 1) != 0) return;
18874         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
18875         FREE((void*)this_ptr);
18876         ChannelMessageHandler_free(this_ptr_conv);
18877 }
18878
18879 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
18880         if ((this_ptr & 1) != 0) return;
18881         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
18882         FREE((void*)this_ptr);
18883         RoutingMessageHandler_free(this_ptr_conv);
18884 }
18885
18886 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
18887         LDKAcceptChannel obj_conv;
18888         obj_conv.inner = (void*)(obj & (~1));
18889         obj_conv.is_owned = false;
18890         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
18891         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18892         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18893         CVec_u8Z_free(ret_var);
18894         return ret_arr;
18895 }
18896
18897 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
18898         LDKu8slice ser_ref;
18899         ser_ref.datalen = *((uint32_t*)ser);
18900         ser_ref.data = (int8_t*)(ser + 4);
18901         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18902         *ret_conv = AcceptChannel_read(ser_ref);
18903         return (uint64_t)ret_conv;
18904 }
18905
18906 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
18907         LDKAnnouncementSignatures obj_conv;
18908         obj_conv.inner = (void*)(obj & (~1));
18909         obj_conv.is_owned = false;
18910         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
18911         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18912         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18913         CVec_u8Z_free(ret_var);
18914         return ret_arr;
18915 }
18916
18917 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
18918         LDKu8slice ser_ref;
18919         ser_ref.datalen = *((uint32_t*)ser);
18920         ser_ref.data = (int8_t*)(ser + 4);
18921         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18922         *ret_conv = AnnouncementSignatures_read(ser_ref);
18923         return (uint64_t)ret_conv;
18924 }
18925
18926 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
18927         LDKChannelReestablish obj_conv;
18928         obj_conv.inner = (void*)(obj & (~1));
18929         obj_conv.is_owned = false;
18930         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
18931         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18932         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18933         CVec_u8Z_free(ret_var);
18934         return ret_arr;
18935 }
18936
18937 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
18938         LDKu8slice ser_ref;
18939         ser_ref.datalen = *((uint32_t*)ser);
18940         ser_ref.data = (int8_t*)(ser + 4);
18941         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18942         *ret_conv = ChannelReestablish_read(ser_ref);
18943         return (uint64_t)ret_conv;
18944 }
18945
18946 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
18947         LDKClosingSigned obj_conv;
18948         obj_conv.inner = (void*)(obj & (~1));
18949         obj_conv.is_owned = false;
18950         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
18951         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18952         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18953         CVec_u8Z_free(ret_var);
18954         return ret_arr;
18955 }
18956
18957 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
18958         LDKu8slice ser_ref;
18959         ser_ref.datalen = *((uint32_t*)ser);
18960         ser_ref.data = (int8_t*)(ser + 4);
18961         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18962         *ret_conv = ClosingSigned_read(ser_ref);
18963         return (uint64_t)ret_conv;
18964 }
18965
18966 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
18967         LDKClosingSignedFeeRange obj_conv;
18968         obj_conv.inner = (void*)(obj & (~1));
18969         obj_conv.is_owned = false;
18970         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
18971         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18972         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18973         CVec_u8Z_free(ret_var);
18974         return ret_arr;
18975 }
18976
18977 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
18978         LDKu8slice ser_ref;
18979         ser_ref.datalen = *((uint32_t*)ser);
18980         ser_ref.data = (int8_t*)(ser + 4);
18981         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18982         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
18983         return (uint64_t)ret_conv;
18984 }
18985
18986 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
18987         LDKCommitmentSigned obj_conv;
18988         obj_conv.inner = (void*)(obj & (~1));
18989         obj_conv.is_owned = false;
18990         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
18991         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18992         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18993         CVec_u8Z_free(ret_var);
18994         return ret_arr;
18995 }
18996
18997 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
18998         LDKu8slice ser_ref;
18999         ser_ref.datalen = *((uint32_t*)ser);
19000         ser_ref.data = (int8_t*)(ser + 4);
19001         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
19002         *ret_conv = CommitmentSigned_read(ser_ref);
19003         return (uint64_t)ret_conv;
19004 }
19005
19006 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
19007         LDKFundingCreated obj_conv;
19008         obj_conv.inner = (void*)(obj & (~1));
19009         obj_conv.is_owned = false;
19010         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
19011         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19012         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19013         CVec_u8Z_free(ret_var);
19014         return ret_arr;
19015 }
19016
19017 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
19018         LDKu8slice ser_ref;
19019         ser_ref.datalen = *((uint32_t*)ser);
19020         ser_ref.data = (int8_t*)(ser + 4);
19021         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19022         *ret_conv = FundingCreated_read(ser_ref);
19023         return (uint64_t)ret_conv;
19024 }
19025
19026 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
19027         LDKFundingSigned obj_conv;
19028         obj_conv.inner = (void*)(obj & (~1));
19029         obj_conv.is_owned = false;
19030         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
19031         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19032         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19033         CVec_u8Z_free(ret_var);
19034         return ret_arr;
19035 }
19036
19037 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
19038         LDKu8slice ser_ref;
19039         ser_ref.datalen = *((uint32_t*)ser);
19040         ser_ref.data = (int8_t*)(ser + 4);
19041         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19042         *ret_conv = FundingSigned_read(ser_ref);
19043         return (uint64_t)ret_conv;
19044 }
19045
19046 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
19047         LDKFundingLocked obj_conv;
19048         obj_conv.inner = (void*)(obj & (~1));
19049         obj_conv.is_owned = false;
19050         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
19051         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19052         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19053         CVec_u8Z_free(ret_var);
19054         return ret_arr;
19055 }
19056
19057 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
19058         LDKu8slice ser_ref;
19059         ser_ref.datalen = *((uint32_t*)ser);
19060         ser_ref.data = (int8_t*)(ser + 4);
19061         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
19062         *ret_conv = FundingLocked_read(ser_ref);
19063         return (uint64_t)ret_conv;
19064 }
19065
19066 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
19067         LDKInit obj_conv;
19068         obj_conv.inner = (void*)(obj & (~1));
19069         obj_conv.is_owned = false;
19070         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
19071         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19072         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19073         CVec_u8Z_free(ret_var);
19074         return ret_arr;
19075 }
19076
19077 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
19078         LDKu8slice ser_ref;
19079         ser_ref.datalen = *((uint32_t*)ser);
19080         ser_ref.data = (int8_t*)(ser + 4);
19081         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19082         *ret_conv = Init_read(ser_ref);
19083         return (uint64_t)ret_conv;
19084 }
19085
19086 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
19087         LDKOpenChannel obj_conv;
19088         obj_conv.inner = (void*)(obj & (~1));
19089         obj_conv.is_owned = false;
19090         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
19091         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19092         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19093         CVec_u8Z_free(ret_var);
19094         return ret_arr;
19095 }
19096
19097 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
19098         LDKu8slice ser_ref;
19099         ser_ref.datalen = *((uint32_t*)ser);
19100         ser_ref.data = (int8_t*)(ser + 4);
19101         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19102         *ret_conv = OpenChannel_read(ser_ref);
19103         return (uint64_t)ret_conv;
19104 }
19105
19106 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
19107         LDKRevokeAndACK obj_conv;
19108         obj_conv.inner = (void*)(obj & (~1));
19109         obj_conv.is_owned = false;
19110         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
19111         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19112         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19113         CVec_u8Z_free(ret_var);
19114         return ret_arr;
19115 }
19116
19117 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
19118         LDKu8slice ser_ref;
19119         ser_ref.datalen = *((uint32_t*)ser);
19120         ser_ref.data = (int8_t*)(ser + 4);
19121         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19122         *ret_conv = RevokeAndACK_read(ser_ref);
19123         return (uint64_t)ret_conv;
19124 }
19125
19126 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
19127         LDKShutdown obj_conv;
19128         obj_conv.inner = (void*)(obj & (~1));
19129         obj_conv.is_owned = false;
19130         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
19131         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19132         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19133         CVec_u8Z_free(ret_var);
19134         return ret_arr;
19135 }
19136
19137 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
19138         LDKu8slice ser_ref;
19139         ser_ref.datalen = *((uint32_t*)ser);
19140         ser_ref.data = (int8_t*)(ser + 4);
19141         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19142         *ret_conv = Shutdown_read(ser_ref);
19143         return (uint64_t)ret_conv;
19144 }
19145
19146 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
19147         LDKUpdateFailHTLC obj_conv;
19148         obj_conv.inner = (void*)(obj & (~1));
19149         obj_conv.is_owned = false;
19150         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
19151         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19152         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19153         CVec_u8Z_free(ret_var);
19154         return ret_arr;
19155 }
19156
19157 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
19158         LDKu8slice ser_ref;
19159         ser_ref.datalen = *((uint32_t*)ser);
19160         ser_ref.data = (int8_t*)(ser + 4);
19161         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19162         *ret_conv = UpdateFailHTLC_read(ser_ref);
19163         return (uint64_t)ret_conv;
19164 }
19165
19166 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
19167         LDKUpdateFailMalformedHTLC obj_conv;
19168         obj_conv.inner = (void*)(obj & (~1));
19169         obj_conv.is_owned = false;
19170         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
19171         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19172         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19173         CVec_u8Z_free(ret_var);
19174         return ret_arr;
19175 }
19176
19177 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
19178         LDKu8slice ser_ref;
19179         ser_ref.datalen = *((uint32_t*)ser);
19180         ser_ref.data = (int8_t*)(ser + 4);
19181         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19182         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
19183         return (uint64_t)ret_conv;
19184 }
19185
19186 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
19187         LDKUpdateFee obj_conv;
19188         obj_conv.inner = (void*)(obj & (~1));
19189         obj_conv.is_owned = false;
19190         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
19191         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19192         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19193         CVec_u8Z_free(ret_var);
19194         return ret_arr;
19195 }
19196
19197 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
19198         LDKu8slice ser_ref;
19199         ser_ref.datalen = *((uint32_t*)ser);
19200         ser_ref.data = (int8_t*)(ser + 4);
19201         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19202         *ret_conv = UpdateFee_read(ser_ref);
19203         return (uint64_t)ret_conv;
19204 }
19205
19206 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
19207         LDKUpdateFulfillHTLC obj_conv;
19208         obj_conv.inner = (void*)(obj & (~1));
19209         obj_conv.is_owned = false;
19210         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
19211         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19212         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19213         CVec_u8Z_free(ret_var);
19214         return ret_arr;
19215 }
19216
19217 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
19218         LDKu8slice ser_ref;
19219         ser_ref.datalen = *((uint32_t*)ser);
19220         ser_ref.data = (int8_t*)(ser + 4);
19221         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19222         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
19223         return (uint64_t)ret_conv;
19224 }
19225
19226 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
19227         LDKUpdateAddHTLC obj_conv;
19228         obj_conv.inner = (void*)(obj & (~1));
19229         obj_conv.is_owned = false;
19230         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
19231         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19232         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19233         CVec_u8Z_free(ret_var);
19234         return ret_arr;
19235 }
19236
19237 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
19238         LDKu8slice ser_ref;
19239         ser_ref.datalen = *((uint32_t*)ser);
19240         ser_ref.data = (int8_t*)(ser + 4);
19241         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19242         *ret_conv = UpdateAddHTLC_read(ser_ref);
19243         return (uint64_t)ret_conv;
19244 }
19245
19246 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
19247         LDKPing obj_conv;
19248         obj_conv.inner = (void*)(obj & (~1));
19249         obj_conv.is_owned = false;
19250         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
19251         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19252         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19253         CVec_u8Z_free(ret_var);
19254         return ret_arr;
19255 }
19256
19257 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
19258         LDKu8slice ser_ref;
19259         ser_ref.datalen = *((uint32_t*)ser);
19260         ser_ref.data = (int8_t*)(ser + 4);
19261         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19262         *ret_conv = Ping_read(ser_ref);
19263         return (uint64_t)ret_conv;
19264 }
19265
19266 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
19267         LDKPong obj_conv;
19268         obj_conv.inner = (void*)(obj & (~1));
19269         obj_conv.is_owned = false;
19270         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
19271         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19272         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19273         CVec_u8Z_free(ret_var);
19274         return ret_arr;
19275 }
19276
19277 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
19278         LDKu8slice ser_ref;
19279         ser_ref.datalen = *((uint32_t*)ser);
19280         ser_ref.data = (int8_t*)(ser + 4);
19281         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19282         *ret_conv = Pong_read(ser_ref);
19283         return (uint64_t)ret_conv;
19284 }
19285
19286 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
19287         LDKUnsignedChannelAnnouncement obj_conv;
19288         obj_conv.inner = (void*)(obj & (~1));
19289         obj_conv.is_owned = false;
19290         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
19291         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19292         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19293         CVec_u8Z_free(ret_var);
19294         return ret_arr;
19295 }
19296
19297 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
19298         LDKu8slice ser_ref;
19299         ser_ref.datalen = *((uint32_t*)ser);
19300         ser_ref.data = (int8_t*)(ser + 4);
19301         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19302         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
19303         return (uint64_t)ret_conv;
19304 }
19305
19306 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
19307         LDKChannelAnnouncement obj_conv;
19308         obj_conv.inner = (void*)(obj & (~1));
19309         obj_conv.is_owned = false;
19310         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
19311         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19312         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19313         CVec_u8Z_free(ret_var);
19314         return ret_arr;
19315 }
19316
19317 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
19318         LDKu8slice ser_ref;
19319         ser_ref.datalen = *((uint32_t*)ser);
19320         ser_ref.data = (int8_t*)(ser + 4);
19321         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19322         *ret_conv = ChannelAnnouncement_read(ser_ref);
19323         return (uint64_t)ret_conv;
19324 }
19325
19326 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
19327         LDKUnsignedChannelUpdate obj_conv;
19328         obj_conv.inner = (void*)(obj & (~1));
19329         obj_conv.is_owned = false;
19330         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
19331         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19332         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19333         CVec_u8Z_free(ret_var);
19334         return ret_arr;
19335 }
19336
19337 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
19338         LDKu8slice ser_ref;
19339         ser_ref.datalen = *((uint32_t*)ser);
19340         ser_ref.data = (int8_t*)(ser + 4);
19341         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19342         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
19343         return (uint64_t)ret_conv;
19344 }
19345
19346 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
19347         LDKChannelUpdate obj_conv;
19348         obj_conv.inner = (void*)(obj & (~1));
19349         obj_conv.is_owned = false;
19350         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
19351         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19352         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19353         CVec_u8Z_free(ret_var);
19354         return ret_arr;
19355 }
19356
19357 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
19358         LDKu8slice ser_ref;
19359         ser_ref.datalen = *((uint32_t*)ser);
19360         ser_ref.data = (int8_t*)(ser + 4);
19361         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19362         *ret_conv = ChannelUpdate_read(ser_ref);
19363         return (uint64_t)ret_conv;
19364 }
19365
19366 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
19367         LDKErrorMessage obj_conv;
19368         obj_conv.inner = (void*)(obj & (~1));
19369         obj_conv.is_owned = false;
19370         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
19371         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19372         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19373         CVec_u8Z_free(ret_var);
19374         return ret_arr;
19375 }
19376
19377 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
19378         LDKu8slice ser_ref;
19379         ser_ref.datalen = *((uint32_t*)ser);
19380         ser_ref.data = (int8_t*)(ser + 4);
19381         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19382         *ret_conv = ErrorMessage_read(ser_ref);
19383         return (uint64_t)ret_conv;
19384 }
19385
19386 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
19387         LDKUnsignedNodeAnnouncement obj_conv;
19388         obj_conv.inner = (void*)(obj & (~1));
19389         obj_conv.is_owned = false;
19390         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
19391         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19392         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19393         CVec_u8Z_free(ret_var);
19394         return ret_arr;
19395 }
19396
19397 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
19398         LDKu8slice ser_ref;
19399         ser_ref.datalen = *((uint32_t*)ser);
19400         ser_ref.data = (int8_t*)(ser + 4);
19401         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19402         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
19403         return (uint64_t)ret_conv;
19404 }
19405
19406 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
19407         LDKNodeAnnouncement obj_conv;
19408         obj_conv.inner = (void*)(obj & (~1));
19409         obj_conv.is_owned = false;
19410         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
19411         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19412         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19413         CVec_u8Z_free(ret_var);
19414         return ret_arr;
19415 }
19416
19417 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
19418         LDKu8slice ser_ref;
19419         ser_ref.datalen = *((uint32_t*)ser);
19420         ser_ref.data = (int8_t*)(ser + 4);
19421         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19422         *ret_conv = NodeAnnouncement_read(ser_ref);
19423         return (uint64_t)ret_conv;
19424 }
19425
19426 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
19427         LDKu8slice ser_ref;
19428         ser_ref.datalen = *((uint32_t*)ser);
19429         ser_ref.data = (int8_t*)(ser + 4);
19430         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19431         *ret_conv = QueryShortChannelIds_read(ser_ref);
19432         return (uint64_t)ret_conv;
19433 }
19434
19435 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
19436         LDKQueryShortChannelIds obj_conv;
19437         obj_conv.inner = (void*)(obj & (~1));
19438         obj_conv.is_owned = false;
19439         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
19440         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19441         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19442         CVec_u8Z_free(ret_var);
19443         return ret_arr;
19444 }
19445
19446 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
19447         LDKu8slice ser_ref;
19448         ser_ref.datalen = *((uint32_t*)ser);
19449         ser_ref.data = (int8_t*)(ser + 4);
19450         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19451         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
19452         return (uint64_t)ret_conv;
19453 }
19454
19455 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
19456         LDKReplyShortChannelIdsEnd obj_conv;
19457         obj_conv.inner = (void*)(obj & (~1));
19458         obj_conv.is_owned = false;
19459         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
19460         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19461         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19462         CVec_u8Z_free(ret_var);
19463         return ret_arr;
19464 }
19465
19466 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
19467         LDKQueryChannelRange this_arg_conv;
19468         this_arg_conv.inner = (void*)(this_arg & (~1));
19469         this_arg_conv.is_owned = false;
19470         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
19471         return ret_val;
19472 }
19473
19474 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
19475         LDKu8slice ser_ref;
19476         ser_ref.datalen = *((uint32_t*)ser);
19477         ser_ref.data = (int8_t*)(ser + 4);
19478         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19479         *ret_conv = QueryChannelRange_read(ser_ref);
19480         return (uint64_t)ret_conv;
19481 }
19482
19483 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
19484         LDKQueryChannelRange obj_conv;
19485         obj_conv.inner = (void*)(obj & (~1));
19486         obj_conv.is_owned = false;
19487         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
19488         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19489         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19490         CVec_u8Z_free(ret_var);
19491         return ret_arr;
19492 }
19493
19494 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
19495         LDKu8slice ser_ref;
19496         ser_ref.datalen = *((uint32_t*)ser);
19497         ser_ref.data = (int8_t*)(ser + 4);
19498         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19499         *ret_conv = ReplyChannelRange_read(ser_ref);
19500         return (uint64_t)ret_conv;
19501 }
19502
19503 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
19504         LDKReplyChannelRange obj_conv;
19505         obj_conv.inner = (void*)(obj & (~1));
19506         obj_conv.is_owned = false;
19507         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
19508         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19509         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19510         CVec_u8Z_free(ret_var);
19511         return ret_arr;
19512 }
19513
19514 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
19515         LDKu8slice ser_ref;
19516         ser_ref.datalen = *((uint32_t*)ser);
19517         ser_ref.data = (int8_t*)(ser + 4);
19518         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19519         *ret_conv = GossipTimestampFilter_read(ser_ref);
19520         return (uint64_t)ret_conv;
19521 }
19522
19523 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
19524         LDKGossipTimestampFilter obj_conv;
19525         obj_conv.inner = (void*)(obj & (~1));
19526         obj_conv.is_owned = false;
19527         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
19528         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19529         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19530         CVec_u8Z_free(ret_var);
19531         return ret_arr;
19532 }
19533
19534 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
19535         LDKIgnoringMessageHandler this_obj_conv;
19536         this_obj_conv.inner = (void*)(this_obj & (~1));
19537         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19538         IgnoringMessageHandler_free(this_obj_conv);
19539 }
19540
19541 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
19542         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
19543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19545         uint64_t ret_ref = (uint64_t)ret_var.inner;
19546         if (ret_var.is_owned) {
19547                 ret_ref |= 1;
19548         }
19549         return ret_ref;
19550 }
19551
19552 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
19553         LDKIgnoringMessageHandler this_arg_conv;
19554         this_arg_conv.inner = (void*)(this_arg & (~1));
19555         this_arg_conv.is_owned = false;
19556         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
19557         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
19558         return (uint64_t)ret;
19559 }
19560
19561 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
19562         LDKIgnoringMessageHandler this_arg_conv;
19563         this_arg_conv.inner = (void*)(this_arg & (~1));
19564         this_arg_conv.is_owned = false;
19565         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
19566         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
19567         return (uint64_t)ret;
19568 }
19569
19570 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
19571         LDKErroringMessageHandler this_obj_conv;
19572         this_obj_conv.inner = (void*)(this_obj & (~1));
19573         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19574         ErroringMessageHandler_free(this_obj_conv);
19575 }
19576
19577 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
19578         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
19579         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19580         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19581         uint64_t ret_ref = (uint64_t)ret_var.inner;
19582         if (ret_var.is_owned) {
19583                 ret_ref |= 1;
19584         }
19585         return ret_ref;
19586 }
19587
19588 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
19589         LDKErroringMessageHandler this_arg_conv;
19590         this_arg_conv.inner = (void*)(this_arg & (~1));
19591         this_arg_conv.is_owned = false;
19592         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
19593         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
19594         return (uint64_t)ret;
19595 }
19596
19597 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
19598         LDKErroringMessageHandler this_arg_conv;
19599         this_arg_conv.inner = (void*)(this_arg & (~1));
19600         this_arg_conv.is_owned = false;
19601         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
19602         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
19603         return (uint64_t)ret;
19604 }
19605
19606 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
19607         LDKMessageHandler this_obj_conv;
19608         this_obj_conv.inner = (void*)(this_obj & (~1));
19609         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19610         MessageHandler_free(this_obj_conv);
19611 }
19612
19613 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
19614         LDKMessageHandler this_ptr_conv;
19615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19616         this_ptr_conv.is_owned = false;
19617         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
19618         return ret_ret;
19619 }
19620
19621 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
19622         LDKMessageHandler this_ptr_conv;
19623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19624         this_ptr_conv.is_owned = false;
19625         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
19626         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
19627 }
19628
19629 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
19630         LDKMessageHandler this_ptr_conv;
19631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19632         this_ptr_conv.is_owned = false;
19633         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
19634         return ret_ret;
19635 }
19636
19637 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
19638         LDKMessageHandler this_ptr_conv;
19639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19640         this_ptr_conv.is_owned = false;
19641         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
19642         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
19643 }
19644
19645 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
19646         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
19647         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
19648         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
19649         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19650         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19651         uint64_t ret_ref = (uint64_t)ret_var.inner;
19652         if (ret_var.is_owned) {
19653                 ret_ref |= 1;
19654         }
19655         return ret_ref;
19656 }
19657
19658 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
19659         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
19660         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
19661         *ret = SocketDescriptor_clone(orig_conv);
19662         return (uint64_t)ret;
19663 }
19664
19665 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
19666         if ((this_ptr & 1) != 0) return;
19667         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
19668         FREE((void*)this_ptr);
19669         SocketDescriptor_free(this_ptr_conv);
19670 }
19671
19672 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
19673         LDKPeerHandleError this_obj_conv;
19674         this_obj_conv.inner = (void*)(this_obj & (~1));
19675         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19676         PeerHandleError_free(this_obj_conv);
19677 }
19678
19679 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
19680         LDKPeerHandleError this_ptr_conv;
19681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19682         this_ptr_conv.is_owned = false;
19683         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
19684         return ret_val;
19685 }
19686
19687 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
19688         LDKPeerHandleError this_ptr_conv;
19689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19690         this_ptr_conv.is_owned = false;
19691         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
19692 }
19693
19694 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
19695         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
19696         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19697         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19698         uint64_t ret_ref = (uint64_t)ret_var.inner;
19699         if (ret_var.is_owned) {
19700                 ret_ref |= 1;
19701         }
19702         return ret_ref;
19703 }
19704
19705 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
19706         LDKPeerHandleError orig_conv;
19707         orig_conv.inner = (void*)(orig & (~1));
19708         orig_conv.is_owned = false;
19709         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
19710         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19711         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19712         uint64_t ret_ref = (uint64_t)ret_var.inner;
19713         if (ret_var.is_owned) {
19714                 ret_ref |= 1;
19715         }
19716         return ret_ref;
19717 }
19718
19719 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
19720         LDKPeerManager this_obj_conv;
19721         this_obj_conv.inner = (void*)(this_obj & (~1));
19722         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19723         PeerManager_free(this_obj_conv);
19724 }
19725
19726 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) {
19727         LDKMessageHandler message_handler_conv;
19728         message_handler_conv.inner = (void*)(message_handler & (~1));
19729         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
19730         // Warning: we need a move here but no clone is available for LDKMessageHandler
19731         LDKSecretKey our_node_secret_ref;
19732         CHECK(*((uint32_t*)our_node_secret) == 32);
19733         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
19734         unsigned char ephemeral_random_data_arr[32];
19735         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
19736         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
19737         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
19738         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19739         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
19740         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19741         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19742         uint64_t ret_ref = (uint64_t)ret_var.inner;
19743         if (ret_var.is_owned) {
19744                 ret_ref |= 1;
19745         }
19746         return ret_ref;
19747 }
19748
19749 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
19750         LDKPeerManager this_arg_conv;
19751         this_arg_conv.inner = (void*)(this_arg & (~1));
19752         this_arg_conv.is_owned = false;
19753         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
19754         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
19755         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
19756         for (size_t m = 0; m < ret_var.datalen; m++) {
19757                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19758                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
19759                 ret_arr_ptr[m] = ret_conv_12_arr;
19760         }
19761         FREE(ret_var.data);
19762         return ret_arr;
19763 }
19764
19765 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
19766         LDKPeerManager this_arg_conv;
19767         this_arg_conv.inner = (void*)(this_arg & (~1));
19768         this_arg_conv.is_owned = false;
19769         LDKPublicKey their_node_id_ref;
19770         CHECK(*((uint32_t*)their_node_id) == 33);
19771         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
19772         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
19773         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
19774         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
19775         return (uint64_t)ret_conv;
19776 }
19777
19778 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
19779         LDKPeerManager this_arg_conv;
19780         this_arg_conv.inner = (void*)(this_arg & (~1));
19781         this_arg_conv.is_owned = false;
19782         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
19783         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
19784         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
19785         return (uint64_t)ret_conv;
19786 }
19787
19788 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
19789         LDKPeerManager this_arg_conv;
19790         this_arg_conv.inner = (void*)(this_arg & (~1));
19791         this_arg_conv.is_owned = false;
19792         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
19793         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
19794         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
19795         return (uint64_t)ret_conv;
19796 }
19797
19798 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
19799         LDKPeerManager this_arg_conv;
19800         this_arg_conv.inner = (void*)(this_arg & (~1));
19801         this_arg_conv.is_owned = false;
19802         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
19803         LDKu8slice data_ref;
19804         data_ref.datalen = *((uint32_t*)data);
19805         data_ref.data = (int8_t*)(data + 4);
19806         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
19807         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
19808         return (uint64_t)ret_conv;
19809 }
19810
19811 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
19812         LDKPeerManager this_arg_conv;
19813         this_arg_conv.inner = (void*)(this_arg & (~1));
19814         this_arg_conv.is_owned = false;
19815         PeerManager_process_events(&this_arg_conv);
19816 }
19817
19818 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
19819         LDKPeerManager this_arg_conv;
19820         this_arg_conv.inner = (void*)(this_arg & (~1));
19821         this_arg_conv.is_owned = false;
19822         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
19823         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
19824 }
19825
19826 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
19827         LDKPeerManager this_arg_conv;
19828         this_arg_conv.inner = (void*)(this_arg & (~1));
19829         this_arg_conv.is_owned = false;
19830         LDKPublicKey node_id_ref;
19831         CHECK(*((uint32_t*)node_id) == 33);
19832         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
19833         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
19834 }
19835
19836 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
19837         LDKPeerManager this_arg_conv;
19838         this_arg_conv.inner = (void*)(this_arg & (~1));
19839         this_arg_conv.is_owned = false;
19840         PeerManager_timer_tick_occurred(&this_arg_conv);
19841 }
19842
19843 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
19844         unsigned char commitment_seed_arr[32];
19845         CHECK(*((uint32_t*)commitment_seed) == 32);
19846         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
19847         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
19848         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19849         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
19850         return ret_arr;
19851 }
19852
19853 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
19854         LDKPublicKey per_commitment_point_ref;
19855         CHECK(*((uint32_t*)per_commitment_point) == 33);
19856         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
19857         unsigned char base_secret_arr[32];
19858         CHECK(*((uint32_t*)base_secret) == 32);
19859         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
19860         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
19861         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
19862         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
19863         return (uint64_t)ret_conv;
19864 }
19865
19866 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
19867         LDKPublicKey per_commitment_point_ref;
19868         CHECK(*((uint32_t*)per_commitment_point) == 33);
19869         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
19870         LDKPublicKey base_point_ref;
19871         CHECK(*((uint32_t*)base_point) == 33);
19872         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
19873         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19874         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
19875         return (uint64_t)ret_conv;
19876 }
19877
19878 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
19879         unsigned char per_commitment_secret_arr[32];
19880         CHECK(*((uint32_t*)per_commitment_secret) == 32);
19881         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
19882         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
19883         unsigned char countersignatory_revocation_base_secret_arr[32];
19884         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
19885         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
19886         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
19887         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
19888         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
19889         return (uint64_t)ret_conv;
19890 }
19891
19892 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
19893         LDKPublicKey per_commitment_point_ref;
19894         CHECK(*((uint32_t*)per_commitment_point) == 33);
19895         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
19896         LDKPublicKey countersignatory_revocation_base_point_ref;
19897         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
19898         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
19899         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19900         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
19901         return (uint64_t)ret_conv;
19902 }
19903
19904 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
19905         LDKTxCreationKeys this_obj_conv;
19906         this_obj_conv.inner = (void*)(this_obj & (~1));
19907         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19908         TxCreationKeys_free(this_obj_conv);
19909 }
19910
19911 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
19912         LDKTxCreationKeys this_ptr_conv;
19913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19914         this_ptr_conv.is_owned = false;
19915         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19916         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
19917         return ret_arr;
19918 }
19919
19920 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
19921         LDKTxCreationKeys this_ptr_conv;
19922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19923         this_ptr_conv.is_owned = false;
19924         LDKPublicKey val_ref;
19925         CHECK(*((uint32_t*)val) == 33);
19926         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19927         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
19928 }
19929
19930 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
19931         LDKTxCreationKeys this_ptr_conv;
19932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19933         this_ptr_conv.is_owned = false;
19934         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19935         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
19936         return ret_arr;
19937 }
19938
19939 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
19940         LDKTxCreationKeys this_ptr_conv;
19941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19942         this_ptr_conv.is_owned = false;
19943         LDKPublicKey val_ref;
19944         CHECK(*((uint32_t*)val) == 33);
19945         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19946         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
19947 }
19948
19949 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
19950         LDKTxCreationKeys this_ptr_conv;
19951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19952         this_ptr_conv.is_owned = false;
19953         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19954         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
19955         return ret_arr;
19956 }
19957
19958 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
19959         LDKTxCreationKeys this_ptr_conv;
19960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19961         this_ptr_conv.is_owned = false;
19962         LDKPublicKey val_ref;
19963         CHECK(*((uint32_t*)val) == 33);
19964         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19965         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
19966 }
19967
19968 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
19969         LDKTxCreationKeys this_ptr_conv;
19970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19971         this_ptr_conv.is_owned = false;
19972         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19973         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
19974         return ret_arr;
19975 }
19976
19977 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
19978         LDKTxCreationKeys this_ptr_conv;
19979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19980         this_ptr_conv.is_owned = false;
19981         LDKPublicKey val_ref;
19982         CHECK(*((uint32_t*)val) == 33);
19983         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19984         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
19985 }
19986
19987 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
19988         LDKTxCreationKeys this_ptr_conv;
19989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19990         this_ptr_conv.is_owned = false;
19991         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19992         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
19993         return ret_arr;
19994 }
19995
19996 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
19997         LDKTxCreationKeys this_ptr_conv;
19998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19999         this_ptr_conv.is_owned = false;
20000         LDKPublicKey val_ref;
20001         CHECK(*((uint32_t*)val) == 33);
20002         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20003         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
20004 }
20005
20006 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) {
20007         LDKPublicKey per_commitment_point_arg_ref;
20008         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
20009         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
20010         LDKPublicKey revocation_key_arg_ref;
20011         CHECK(*((uint32_t*)revocation_key_arg) == 33);
20012         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
20013         LDKPublicKey broadcaster_htlc_key_arg_ref;
20014         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
20015         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
20016         LDKPublicKey countersignatory_htlc_key_arg_ref;
20017         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
20018         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
20019         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
20020         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
20021         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
20022         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);
20023         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20024         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20025         uint64_t ret_ref = (uint64_t)ret_var.inner;
20026         if (ret_var.is_owned) {
20027                 ret_ref |= 1;
20028         }
20029         return ret_ref;
20030 }
20031
20032 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
20033         LDKTxCreationKeys orig_conv;
20034         orig_conv.inner = (void*)(orig & (~1));
20035         orig_conv.is_owned = false;
20036         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
20037         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20038         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20039         uint64_t ret_ref = (uint64_t)ret_var.inner;
20040         if (ret_var.is_owned) {
20041                 ret_ref |= 1;
20042         }
20043         return ret_ref;
20044 }
20045
20046 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
20047         LDKTxCreationKeys obj_conv;
20048         obj_conv.inner = (void*)(obj & (~1));
20049         obj_conv.is_owned = false;
20050         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
20051         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20052         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20053         CVec_u8Z_free(ret_var);
20054         return ret_arr;
20055 }
20056
20057 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
20058         LDKu8slice ser_ref;
20059         ser_ref.datalen = *((uint32_t*)ser);
20060         ser_ref.data = (int8_t*)(ser + 4);
20061         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
20062         *ret_conv = TxCreationKeys_read(ser_ref);
20063         return (uint64_t)ret_conv;
20064 }
20065
20066 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
20067         LDKChannelPublicKeys this_obj_conv;
20068         this_obj_conv.inner = (void*)(this_obj & (~1));
20069         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20070         ChannelPublicKeys_free(this_obj_conv);
20071 }
20072
20073 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
20074         LDKChannelPublicKeys this_ptr_conv;
20075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20076         this_ptr_conv.is_owned = false;
20077         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20078         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
20079         return ret_arr;
20080 }
20081
20082 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
20083         LDKChannelPublicKeys this_ptr_conv;
20084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20085         this_ptr_conv.is_owned = false;
20086         LDKPublicKey val_ref;
20087         CHECK(*((uint32_t*)val) == 33);
20088         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20089         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
20090 }
20091
20092 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
20093         LDKChannelPublicKeys this_ptr_conv;
20094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20095         this_ptr_conv.is_owned = false;
20096         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20097         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
20098         return ret_arr;
20099 }
20100
20101 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
20102         LDKChannelPublicKeys this_ptr_conv;
20103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20104         this_ptr_conv.is_owned = false;
20105         LDKPublicKey val_ref;
20106         CHECK(*((uint32_t*)val) == 33);
20107         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20108         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
20109 }
20110
20111 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
20112         LDKChannelPublicKeys this_ptr_conv;
20113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20114         this_ptr_conv.is_owned = false;
20115         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20116         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
20117         return ret_arr;
20118 }
20119
20120 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
20121         LDKChannelPublicKeys this_ptr_conv;
20122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20123         this_ptr_conv.is_owned = false;
20124         LDKPublicKey val_ref;
20125         CHECK(*((uint32_t*)val) == 33);
20126         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20127         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
20128 }
20129
20130 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
20131         LDKChannelPublicKeys this_ptr_conv;
20132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20133         this_ptr_conv.is_owned = false;
20134         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20135         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
20136         return ret_arr;
20137 }
20138
20139 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
20140         LDKChannelPublicKeys this_ptr_conv;
20141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20142         this_ptr_conv.is_owned = false;
20143         LDKPublicKey val_ref;
20144         CHECK(*((uint32_t*)val) == 33);
20145         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20146         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
20147 }
20148
20149 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
20150         LDKChannelPublicKeys this_ptr_conv;
20151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20152         this_ptr_conv.is_owned = false;
20153         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20154         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
20155         return ret_arr;
20156 }
20157
20158 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
20159         LDKChannelPublicKeys this_ptr_conv;
20160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20161         this_ptr_conv.is_owned = false;
20162         LDKPublicKey val_ref;
20163         CHECK(*((uint32_t*)val) == 33);
20164         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20165         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
20166 }
20167
20168 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) {
20169         LDKPublicKey funding_pubkey_arg_ref;
20170         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
20171         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
20172         LDKPublicKey revocation_basepoint_arg_ref;
20173         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
20174         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
20175         LDKPublicKey payment_point_arg_ref;
20176         CHECK(*((uint32_t*)payment_point_arg) == 33);
20177         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
20178         LDKPublicKey delayed_payment_basepoint_arg_ref;
20179         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
20180         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
20181         LDKPublicKey htlc_basepoint_arg_ref;
20182         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
20183         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
20184         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);
20185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20187         uint64_t ret_ref = (uint64_t)ret_var.inner;
20188         if (ret_var.is_owned) {
20189                 ret_ref |= 1;
20190         }
20191         return ret_ref;
20192 }
20193
20194 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
20195         LDKChannelPublicKeys orig_conv;
20196         orig_conv.inner = (void*)(orig & (~1));
20197         orig_conv.is_owned = false;
20198         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
20199         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20200         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20201         uint64_t ret_ref = (uint64_t)ret_var.inner;
20202         if (ret_var.is_owned) {
20203                 ret_ref |= 1;
20204         }
20205         return ret_ref;
20206 }
20207
20208 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
20209         LDKChannelPublicKeys obj_conv;
20210         obj_conv.inner = (void*)(obj & (~1));
20211         obj_conv.is_owned = false;
20212         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
20213         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20214         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20215         CVec_u8Z_free(ret_var);
20216         return ret_arr;
20217 }
20218
20219 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
20220         LDKu8slice ser_ref;
20221         ser_ref.datalen = *((uint32_t*)ser);
20222         ser_ref.data = (int8_t*)(ser + 4);
20223         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
20224         *ret_conv = ChannelPublicKeys_read(ser_ref);
20225         return (uint64_t)ret_conv;
20226 }
20227
20228 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) {
20229         LDKPublicKey per_commitment_point_ref;
20230         CHECK(*((uint32_t*)per_commitment_point) == 33);
20231         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
20232         LDKPublicKey broadcaster_delayed_payment_base_ref;
20233         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
20234         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
20235         LDKPublicKey broadcaster_htlc_base_ref;
20236         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
20237         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
20238         LDKPublicKey countersignatory_revocation_base_ref;
20239         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
20240         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
20241         LDKPublicKey countersignatory_htlc_base_ref;
20242         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
20243         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
20244         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
20245         *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);
20246         return (uint64_t)ret_conv;
20247 }
20248
20249 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
20250         LDKPublicKey per_commitment_point_ref;
20251         CHECK(*((uint32_t*)per_commitment_point) == 33);
20252         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
20253         LDKChannelPublicKeys broadcaster_keys_conv;
20254         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
20255         broadcaster_keys_conv.is_owned = false;
20256         LDKChannelPublicKeys countersignatory_keys_conv;
20257         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
20258         countersignatory_keys_conv.is_owned = false;
20259         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
20260         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
20261         return (uint64_t)ret_conv;
20262 }
20263
20264 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
20265         LDKPublicKey revocation_key_ref;
20266         CHECK(*((uint32_t*)revocation_key) == 33);
20267         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
20268         LDKPublicKey broadcaster_delayed_payment_key_ref;
20269         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
20270         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
20271         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
20272         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20273         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20274         CVec_u8Z_free(ret_var);
20275         return ret_arr;
20276 }
20277
20278 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
20279         LDKHTLCOutputInCommitment this_obj_conv;
20280         this_obj_conv.inner = (void*)(this_obj & (~1));
20281         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20282         HTLCOutputInCommitment_free(this_obj_conv);
20283 }
20284
20285 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
20286         LDKHTLCOutputInCommitment this_ptr_conv;
20287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20288         this_ptr_conv.is_owned = false;
20289         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
20290         return ret_val;
20291 }
20292
20293 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
20294         LDKHTLCOutputInCommitment this_ptr_conv;
20295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20296         this_ptr_conv.is_owned = false;
20297         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
20298 }
20299
20300 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
20301         LDKHTLCOutputInCommitment this_ptr_conv;
20302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20303         this_ptr_conv.is_owned = false;
20304         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
20305         return ret_val;
20306 }
20307
20308 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
20309         LDKHTLCOutputInCommitment this_ptr_conv;
20310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20311         this_ptr_conv.is_owned = false;
20312         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
20313 }
20314
20315 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
20316         LDKHTLCOutputInCommitment this_ptr_conv;
20317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20318         this_ptr_conv.is_owned = false;
20319         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
20320         return ret_val;
20321 }
20322
20323 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
20324         LDKHTLCOutputInCommitment this_ptr_conv;
20325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20326         this_ptr_conv.is_owned = false;
20327         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
20328 }
20329
20330 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
20331         LDKHTLCOutputInCommitment this_ptr_conv;
20332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20333         this_ptr_conv.is_owned = false;
20334         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20335         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
20336         return ret_arr;
20337 }
20338
20339 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
20340         LDKHTLCOutputInCommitment this_ptr_conv;
20341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20342         this_ptr_conv.is_owned = false;
20343         LDKThirtyTwoBytes val_ref;
20344         CHECK(*((uint32_t*)val) == 32);
20345         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20346         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
20347 }
20348
20349 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
20350         LDKHTLCOutputInCommitment this_ptr_conv;
20351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20352         this_ptr_conv.is_owned = false;
20353         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
20354         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
20355         uint64_t ret_ref = (uint64_t)ret_copy;
20356         return ret_ref;
20357 }
20358
20359 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
20360         LDKHTLCOutputInCommitment this_ptr_conv;
20361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20362         this_ptr_conv.is_owned = false;
20363         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
20364         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
20365 }
20366
20367 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) {
20368         LDKThirtyTwoBytes payment_hash_arg_ref;
20369         CHECK(*((uint32_t*)payment_hash_arg) == 32);
20370         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
20371         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
20372         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
20373         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20374         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20375         uint64_t ret_ref = (uint64_t)ret_var.inner;
20376         if (ret_var.is_owned) {
20377                 ret_ref |= 1;
20378         }
20379         return ret_ref;
20380 }
20381
20382 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
20383         LDKHTLCOutputInCommitment orig_conv;
20384         orig_conv.inner = (void*)(orig & (~1));
20385         orig_conv.is_owned = false;
20386         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
20387         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20388         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20389         uint64_t ret_ref = (uint64_t)ret_var.inner;
20390         if (ret_var.is_owned) {
20391                 ret_ref |= 1;
20392         }
20393         return ret_ref;
20394 }
20395
20396 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
20397         LDKHTLCOutputInCommitment obj_conv;
20398         obj_conv.inner = (void*)(obj & (~1));
20399         obj_conv.is_owned = false;
20400         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
20401         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20402         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20403         CVec_u8Z_free(ret_var);
20404         return ret_arr;
20405 }
20406
20407 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
20408         LDKu8slice ser_ref;
20409         ser_ref.datalen = *((uint32_t*)ser);
20410         ser_ref.data = (int8_t*)(ser + 4);
20411         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
20412         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
20413         return (uint64_t)ret_conv;
20414 }
20415
20416 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
20417         LDKHTLCOutputInCommitment htlc_conv;
20418         htlc_conv.inner = (void*)(htlc & (~1));
20419         htlc_conv.is_owned = false;
20420         LDKTxCreationKeys keys_conv;
20421         keys_conv.inner = (void*)(keys & (~1));
20422         keys_conv.is_owned = false;
20423         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
20424         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20425         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20426         CVec_u8Z_free(ret_var);
20427         return ret_arr;
20428 }
20429
20430 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
20431         LDKPublicKey broadcaster_ref;
20432         CHECK(*((uint32_t*)broadcaster) == 33);
20433         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
20434         LDKPublicKey countersignatory_ref;
20435         CHECK(*((uint32_t*)countersignatory) == 33);
20436         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
20437         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
20438         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20439         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20440         CVec_u8Z_free(ret_var);
20441         return ret_arr;
20442 }
20443
20444 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) {
20445         unsigned char commitment_txid_arr[32];
20446         CHECK(*((uint32_t*)commitment_txid) == 32);
20447         memcpy(commitment_txid_arr, (uint8_t*)(commitment_txid + 4), 32);
20448         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
20449         LDKHTLCOutputInCommitment htlc_conv;
20450         htlc_conv.inner = (void*)(htlc & (~1));
20451         htlc_conv.is_owned = false;
20452         LDKPublicKey broadcaster_delayed_payment_key_ref;
20453         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
20454         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
20455         LDKPublicKey revocation_key_ref;
20456         CHECK(*((uint32_t*)revocation_key) == 33);
20457         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
20458         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
20459         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20460         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20461         Transaction_free(ret_var);
20462         return ret_arr;
20463 }
20464
20465 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
20466         LDKChannelTransactionParameters this_obj_conv;
20467         this_obj_conv.inner = (void*)(this_obj & (~1));
20468         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20469         ChannelTransactionParameters_free(this_obj_conv);
20470 }
20471
20472 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
20473         LDKChannelTransactionParameters this_ptr_conv;
20474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20475         this_ptr_conv.is_owned = false;
20476         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
20477         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20478         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20479         uint64_t ret_ref = (uint64_t)ret_var.inner;
20480         if (ret_var.is_owned) {
20481                 ret_ref |= 1;
20482         }
20483         return ret_ref;
20484 }
20485
20486 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
20487         LDKChannelTransactionParameters this_ptr_conv;
20488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20489         this_ptr_conv.is_owned = false;
20490         LDKChannelPublicKeys val_conv;
20491         val_conv.inner = (void*)(val & (~1));
20492         val_conv.is_owned = (val & 1) || (val == 0);
20493         val_conv = ChannelPublicKeys_clone(&val_conv);
20494         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
20495 }
20496
20497 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
20498         LDKChannelTransactionParameters this_ptr_conv;
20499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20500         this_ptr_conv.is_owned = false;
20501         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
20502         return ret_val;
20503 }
20504
20505 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
20506         LDKChannelTransactionParameters this_ptr_conv;
20507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20508         this_ptr_conv.is_owned = false;
20509         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
20510 }
20511
20512 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
20513         LDKChannelTransactionParameters this_ptr_conv;
20514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20515         this_ptr_conv.is_owned = false;
20516         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
20517         return ret_val;
20518 }
20519
20520 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
20521         LDKChannelTransactionParameters this_ptr_conv;
20522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20523         this_ptr_conv.is_owned = false;
20524         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
20525 }
20526
20527 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
20528         LDKChannelTransactionParameters this_ptr_conv;
20529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20530         this_ptr_conv.is_owned = false;
20531         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
20532         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20533         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20534         uint64_t ret_ref = (uint64_t)ret_var.inner;
20535         if (ret_var.is_owned) {
20536                 ret_ref |= 1;
20537         }
20538         return ret_ref;
20539 }
20540
20541 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
20542         LDKChannelTransactionParameters this_ptr_conv;
20543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20544         this_ptr_conv.is_owned = false;
20545         LDKCounterpartyChannelTransactionParameters val_conv;
20546         val_conv.inner = (void*)(val & (~1));
20547         val_conv.is_owned = (val & 1) || (val == 0);
20548         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
20549         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
20550 }
20551
20552 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
20553         LDKChannelTransactionParameters this_ptr_conv;
20554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20555         this_ptr_conv.is_owned = false;
20556         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
20557         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20558         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20559         uint64_t ret_ref = (uint64_t)ret_var.inner;
20560         if (ret_var.is_owned) {
20561                 ret_ref |= 1;
20562         }
20563         return ret_ref;
20564 }
20565
20566 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
20567         LDKChannelTransactionParameters this_ptr_conv;
20568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20569         this_ptr_conv.is_owned = false;
20570         LDKOutPoint val_conv;
20571         val_conv.inner = (void*)(val & (~1));
20572         val_conv.is_owned = (val & 1) || (val == 0);
20573         val_conv = OutPoint_clone(&val_conv);
20574         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
20575 }
20576
20577 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) {
20578         LDKChannelPublicKeys holder_pubkeys_arg_conv;
20579         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
20580         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
20581         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
20582         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
20583         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
20584         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
20585         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
20586         LDKOutPoint funding_outpoint_arg_conv;
20587         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
20588         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
20589         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
20590         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);
20591         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20592         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20593         uint64_t ret_ref = (uint64_t)ret_var.inner;
20594         if (ret_var.is_owned) {
20595                 ret_ref |= 1;
20596         }
20597         return ret_ref;
20598 }
20599
20600 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
20601         LDKChannelTransactionParameters orig_conv;
20602         orig_conv.inner = (void*)(orig & (~1));
20603         orig_conv.is_owned = false;
20604         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
20605         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20606         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20607         uint64_t ret_ref = (uint64_t)ret_var.inner;
20608         if (ret_var.is_owned) {
20609                 ret_ref |= 1;
20610         }
20611         return ret_ref;
20612 }
20613
20614 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
20615         LDKCounterpartyChannelTransactionParameters this_obj_conv;
20616         this_obj_conv.inner = (void*)(this_obj & (~1));
20617         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20618         CounterpartyChannelTransactionParameters_free(this_obj_conv);
20619 }
20620
20621 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
20622         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
20623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20624         this_ptr_conv.is_owned = false;
20625         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
20626         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20627         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20628         uint64_t ret_ref = (uint64_t)ret_var.inner;
20629         if (ret_var.is_owned) {
20630                 ret_ref |= 1;
20631         }
20632         return ret_ref;
20633 }
20634
20635 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
20636         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
20637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20638         this_ptr_conv.is_owned = false;
20639         LDKChannelPublicKeys val_conv;
20640         val_conv.inner = (void*)(val & (~1));
20641         val_conv.is_owned = (val & 1) || (val == 0);
20642         val_conv = ChannelPublicKeys_clone(&val_conv);
20643         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
20644 }
20645
20646 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
20647         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
20648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20649         this_ptr_conv.is_owned = false;
20650         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
20651         return ret_val;
20652 }
20653
20654 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
20655         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
20656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20657         this_ptr_conv.is_owned = false;
20658         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
20659 }
20660
20661 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
20662         LDKChannelPublicKeys pubkeys_arg_conv;
20663         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
20664         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
20665         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
20666         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
20667         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20668         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20669         uint64_t ret_ref = (uint64_t)ret_var.inner;
20670         if (ret_var.is_owned) {
20671                 ret_ref |= 1;
20672         }
20673         return ret_ref;
20674 }
20675
20676 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
20677         LDKCounterpartyChannelTransactionParameters orig_conv;
20678         orig_conv.inner = (void*)(orig & (~1));
20679         orig_conv.is_owned = false;
20680         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
20681         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20682         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20683         uint64_t ret_ref = (uint64_t)ret_var.inner;
20684         if (ret_var.is_owned) {
20685                 ret_ref |= 1;
20686         }
20687         return ret_ref;
20688 }
20689
20690 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
20691         LDKChannelTransactionParameters this_arg_conv;
20692         this_arg_conv.inner = (void*)(this_arg & (~1));
20693         this_arg_conv.is_owned = false;
20694         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
20695         return ret_val;
20696 }
20697
20698 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
20699         LDKChannelTransactionParameters this_arg_conv;
20700         this_arg_conv.inner = (void*)(this_arg & (~1));
20701         this_arg_conv.is_owned = false;
20702         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
20703         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20704         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20705         uint64_t ret_ref = (uint64_t)ret_var.inner;
20706         if (ret_var.is_owned) {
20707                 ret_ref |= 1;
20708         }
20709         return ret_ref;
20710 }
20711
20712 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
20713         LDKChannelTransactionParameters this_arg_conv;
20714         this_arg_conv.inner = (void*)(this_arg & (~1));
20715         this_arg_conv.is_owned = false;
20716         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
20717         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20718         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20719         uint64_t ret_ref = (uint64_t)ret_var.inner;
20720         if (ret_var.is_owned) {
20721                 ret_ref |= 1;
20722         }
20723         return ret_ref;
20724 }
20725
20726 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
20727         LDKCounterpartyChannelTransactionParameters obj_conv;
20728         obj_conv.inner = (void*)(obj & (~1));
20729         obj_conv.is_owned = false;
20730         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
20731         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20732         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20733         CVec_u8Z_free(ret_var);
20734         return ret_arr;
20735 }
20736
20737 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
20738         LDKu8slice ser_ref;
20739         ser_ref.datalen = *((uint32_t*)ser);
20740         ser_ref.data = (int8_t*)(ser + 4);
20741         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
20742         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
20743         return (uint64_t)ret_conv;
20744 }
20745
20746 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
20747         LDKChannelTransactionParameters obj_conv;
20748         obj_conv.inner = (void*)(obj & (~1));
20749         obj_conv.is_owned = false;
20750         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
20751         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20752         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20753         CVec_u8Z_free(ret_var);
20754         return ret_arr;
20755 }
20756
20757 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
20758         LDKu8slice ser_ref;
20759         ser_ref.datalen = *((uint32_t*)ser);
20760         ser_ref.data = (int8_t*)(ser + 4);
20761         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
20762         *ret_conv = ChannelTransactionParameters_read(ser_ref);
20763         return (uint64_t)ret_conv;
20764 }
20765
20766 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
20767         LDKDirectedChannelTransactionParameters this_obj_conv;
20768         this_obj_conv.inner = (void*)(this_obj & (~1));
20769         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20770         DirectedChannelTransactionParameters_free(this_obj_conv);
20771 }
20772
20773 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
20774         LDKDirectedChannelTransactionParameters this_arg_conv;
20775         this_arg_conv.inner = (void*)(this_arg & (~1));
20776         this_arg_conv.is_owned = false;
20777         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
20778         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20779         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20780         uint64_t ret_ref = (uint64_t)ret_var.inner;
20781         if (ret_var.is_owned) {
20782                 ret_ref |= 1;
20783         }
20784         return ret_ref;
20785 }
20786
20787 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
20788         LDKDirectedChannelTransactionParameters this_arg_conv;
20789         this_arg_conv.inner = (void*)(this_arg & (~1));
20790         this_arg_conv.is_owned = false;
20791         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
20792         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20793         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20794         uint64_t ret_ref = (uint64_t)ret_var.inner;
20795         if (ret_var.is_owned) {
20796                 ret_ref |= 1;
20797         }
20798         return ret_ref;
20799 }
20800
20801 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
20802         LDKDirectedChannelTransactionParameters this_arg_conv;
20803         this_arg_conv.inner = (void*)(this_arg & (~1));
20804         this_arg_conv.is_owned = false;
20805         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
20806         return ret_val;
20807 }
20808
20809 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
20810         LDKDirectedChannelTransactionParameters this_arg_conv;
20811         this_arg_conv.inner = (void*)(this_arg & (~1));
20812         this_arg_conv.is_owned = false;
20813         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
20814         return ret_val;
20815 }
20816
20817 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
20818         LDKDirectedChannelTransactionParameters this_arg_conv;
20819         this_arg_conv.inner = (void*)(this_arg & (~1));
20820         this_arg_conv.is_owned = false;
20821         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
20822         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20823         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20824         uint64_t ret_ref = (uint64_t)ret_var.inner;
20825         if (ret_var.is_owned) {
20826                 ret_ref |= 1;
20827         }
20828         return ret_ref;
20829 }
20830
20831 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
20832         LDKHolderCommitmentTransaction this_obj_conv;
20833         this_obj_conv.inner = (void*)(this_obj & (~1));
20834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20835         HolderCommitmentTransaction_free(this_obj_conv);
20836 }
20837
20838 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
20839         LDKHolderCommitmentTransaction this_ptr_conv;
20840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20841         this_ptr_conv.is_owned = false;
20842         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
20843         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
20844         return ret_arr;
20845 }
20846
20847 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
20848         LDKHolderCommitmentTransaction this_ptr_conv;
20849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20850         this_ptr_conv.is_owned = false;
20851         LDKSignature val_ref;
20852         CHECK(*((uint32_t*)val) == 64);
20853         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
20854         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
20855 }
20856
20857 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
20858         LDKHolderCommitmentTransaction this_ptr_conv;
20859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20860         this_ptr_conv.is_owned = false;
20861         LDKCVec_SignatureZ val_constr;
20862         val_constr.datalen = *((uint32_t*)val);
20863         if (val_constr.datalen > 0)
20864                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
20865         else
20866                 val_constr.data = NULL;
20867         int8_tArray* val_vals = (int8_tArray*)(val + 4);
20868         for (size_t m = 0; m < val_constr.datalen; m++) {
20869                 int8_tArray val_conv_12 = val_vals[m];
20870                 LDKSignature val_conv_12_ref;
20871                 CHECK(*((uint32_t*)val_conv_12) == 64);
20872                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
20873                 val_constr.data[m] = val_conv_12_ref;
20874         }
20875         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
20876 }
20877
20878 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
20879         LDKHolderCommitmentTransaction orig_conv;
20880         orig_conv.inner = (void*)(orig & (~1));
20881         orig_conv.is_owned = false;
20882         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
20883         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20884         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20885         uint64_t ret_ref = (uint64_t)ret_var.inner;
20886         if (ret_var.is_owned) {
20887                 ret_ref |= 1;
20888         }
20889         return ret_ref;
20890 }
20891
20892 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
20893         LDKHolderCommitmentTransaction obj_conv;
20894         obj_conv.inner = (void*)(obj & (~1));
20895         obj_conv.is_owned = false;
20896         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
20897         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20898         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20899         CVec_u8Z_free(ret_var);
20900         return ret_arr;
20901 }
20902
20903 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
20904         LDKu8slice ser_ref;
20905         ser_ref.datalen = *((uint32_t*)ser);
20906         ser_ref.data = (int8_t*)(ser + 4);
20907         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
20908         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
20909         return (uint64_t)ret_conv;
20910 }
20911
20912 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) {
20913         LDKCommitmentTransaction commitment_tx_conv;
20914         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
20915         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
20916         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
20917         LDKSignature counterparty_sig_ref;
20918         CHECK(*((uint32_t*)counterparty_sig) == 64);
20919         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
20920         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
20921         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
20922         if (counterparty_htlc_sigs_constr.datalen > 0)
20923                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
20924         else
20925                 counterparty_htlc_sigs_constr.data = NULL;
20926         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
20927         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
20928                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
20929                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
20930                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
20931                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
20932                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
20933         }
20934         LDKPublicKey holder_funding_key_ref;
20935         CHECK(*((uint32_t*)holder_funding_key) == 33);
20936         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
20937         LDKPublicKey counterparty_funding_key_ref;
20938         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
20939         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
20940         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
20941         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20942         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20943         uint64_t ret_ref = (uint64_t)ret_var.inner;
20944         if (ret_var.is_owned) {
20945                 ret_ref |= 1;
20946         }
20947         return ret_ref;
20948 }
20949
20950 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
20951         LDKBuiltCommitmentTransaction this_obj_conv;
20952         this_obj_conv.inner = (void*)(this_obj & (~1));
20953         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20954         BuiltCommitmentTransaction_free(this_obj_conv);
20955 }
20956
20957 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
20958         LDKBuiltCommitmentTransaction this_ptr_conv;
20959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20960         this_ptr_conv.is_owned = false;
20961         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
20962         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20963         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20964         Transaction_free(ret_var);
20965         return ret_arr;
20966 }
20967
20968 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
20969         LDKBuiltCommitmentTransaction this_ptr_conv;
20970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20971         this_ptr_conv.is_owned = false;
20972         LDKTransaction val_ref;
20973         val_ref.datalen = *((uint32_t*)val);
20974         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
20975         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
20976         val_ref.data_is_owned = true;
20977         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
20978 }
20979
20980 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
20981         LDKBuiltCommitmentTransaction this_ptr_conv;
20982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20983         this_ptr_conv.is_owned = false;
20984         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20985         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
20986         return ret_arr;
20987 }
20988
20989 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
20990         LDKBuiltCommitmentTransaction this_ptr_conv;
20991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20992         this_ptr_conv.is_owned = false;
20993         LDKThirtyTwoBytes val_ref;
20994         CHECK(*((uint32_t*)val) == 32);
20995         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20996         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
20997 }
20998
20999 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
21000         LDKTransaction transaction_arg_ref;
21001         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
21002         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
21003         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
21004         transaction_arg_ref.data_is_owned = true;
21005         LDKThirtyTwoBytes txid_arg_ref;
21006         CHECK(*((uint32_t*)txid_arg) == 32);
21007         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
21008         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
21009         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21010         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21011         uint64_t ret_ref = (uint64_t)ret_var.inner;
21012         if (ret_var.is_owned) {
21013                 ret_ref |= 1;
21014         }
21015         return ret_ref;
21016 }
21017
21018 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
21019         LDKBuiltCommitmentTransaction orig_conv;
21020         orig_conv.inner = (void*)(orig & (~1));
21021         orig_conv.is_owned = false;
21022         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
21023         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21024         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21025         uint64_t ret_ref = (uint64_t)ret_var.inner;
21026         if (ret_var.is_owned) {
21027                 ret_ref |= 1;
21028         }
21029         return ret_ref;
21030 }
21031
21032 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
21033         LDKBuiltCommitmentTransaction obj_conv;
21034         obj_conv.inner = (void*)(obj & (~1));
21035         obj_conv.is_owned = false;
21036         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
21037         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21038         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21039         CVec_u8Z_free(ret_var);
21040         return ret_arr;
21041 }
21042
21043 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
21044         LDKu8slice ser_ref;
21045         ser_ref.datalen = *((uint32_t*)ser);
21046         ser_ref.data = (int8_t*)(ser + 4);
21047         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
21048         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
21049         return (uint64_t)ret_conv;
21050 }
21051
21052 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
21053         LDKBuiltCommitmentTransaction this_arg_conv;
21054         this_arg_conv.inner = (void*)(this_arg & (~1));
21055         this_arg_conv.is_owned = false;
21056         LDKu8slice funding_redeemscript_ref;
21057         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
21058         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
21059         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21060         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
21061         return ret_arr;
21062 }
21063
21064 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) {
21065         LDKBuiltCommitmentTransaction this_arg_conv;
21066         this_arg_conv.inner = (void*)(this_arg & (~1));
21067         this_arg_conv.is_owned = false;
21068         unsigned char funding_key_arr[32];
21069         CHECK(*((uint32_t*)funding_key) == 32);
21070         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
21071         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
21072         LDKu8slice funding_redeemscript_ref;
21073         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
21074         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
21075         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
21076         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
21077         return ret_arr;
21078 }
21079
21080 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
21081         LDKCommitmentTransaction this_obj_conv;
21082         this_obj_conv.inner = (void*)(this_obj & (~1));
21083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21084         CommitmentTransaction_free(this_obj_conv);
21085 }
21086
21087 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
21088         LDKCommitmentTransaction orig_conv;
21089         orig_conv.inner = (void*)(orig & (~1));
21090         orig_conv.is_owned = false;
21091         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
21092         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21093         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21094         uint64_t ret_ref = (uint64_t)ret_var.inner;
21095         if (ret_var.is_owned) {
21096                 ret_ref |= 1;
21097         }
21098         return ret_ref;
21099 }
21100
21101 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
21102         LDKCommitmentTransaction obj_conv;
21103         obj_conv.inner = (void*)(obj & (~1));
21104         obj_conv.is_owned = false;
21105         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
21106         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21107         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21108         CVec_u8Z_free(ret_var);
21109         return ret_arr;
21110 }
21111
21112 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
21113         LDKu8slice ser_ref;
21114         ser_ref.datalen = *((uint32_t*)ser);
21115         ser_ref.data = (int8_t*)(ser + 4);
21116         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
21117         *ret_conv = CommitmentTransaction_read(ser_ref);
21118         return (uint64_t)ret_conv;
21119 }
21120
21121 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
21122         LDKCommitmentTransaction this_arg_conv;
21123         this_arg_conv.inner = (void*)(this_arg & (~1));
21124         this_arg_conv.is_owned = false;
21125         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
21126         return ret_val;
21127 }
21128
21129 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
21130         LDKCommitmentTransaction this_arg_conv;
21131         this_arg_conv.inner = (void*)(this_arg & (~1));
21132         this_arg_conv.is_owned = false;
21133         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
21134         return ret_val;
21135 }
21136
21137 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
21138         LDKCommitmentTransaction this_arg_conv;
21139         this_arg_conv.inner = (void*)(this_arg & (~1));
21140         this_arg_conv.is_owned = false;
21141         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
21142         return ret_val;
21143 }
21144
21145 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
21146         LDKCommitmentTransaction this_arg_conv;
21147         this_arg_conv.inner = (void*)(this_arg & (~1));
21148         this_arg_conv.is_owned = false;
21149         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
21150         return ret_val;
21151 }
21152
21153 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
21154         LDKCommitmentTransaction this_arg_conv;
21155         this_arg_conv.inner = (void*)(this_arg & (~1));
21156         this_arg_conv.is_owned = false;
21157         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
21158         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21159         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21160         uint64_t ret_ref = (uint64_t)ret_var.inner;
21161         if (ret_var.is_owned) {
21162                 ret_ref |= 1;
21163         }
21164         return ret_ref;
21165 }
21166
21167 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
21168         LDKCommitmentTransaction this_arg_conv;
21169         this_arg_conv.inner = (void*)(this_arg & (~1));
21170         this_arg_conv.is_owned = false;
21171         LDKDirectedChannelTransactionParameters channel_parameters_conv;
21172         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
21173         channel_parameters_conv.is_owned = false;
21174         LDKChannelPublicKeys broadcaster_keys_conv;
21175         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
21176         broadcaster_keys_conv.is_owned = false;
21177         LDKChannelPublicKeys countersignatory_keys_conv;
21178         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
21179         countersignatory_keys_conv.is_owned = false;
21180         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
21181         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
21182         return (uint64_t)ret_conv;
21183 }
21184
21185 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
21186         LDKTrustedCommitmentTransaction this_obj_conv;
21187         this_obj_conv.inner = (void*)(this_obj & (~1));
21188         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21189         TrustedCommitmentTransaction_free(this_obj_conv);
21190 }
21191
21192 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
21193         LDKTrustedCommitmentTransaction this_arg_conv;
21194         this_arg_conv.inner = (void*)(this_arg & (~1));
21195         this_arg_conv.is_owned = false;
21196         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21197         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
21198         return ret_arr;
21199 }
21200
21201 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
21202         LDKTrustedCommitmentTransaction this_arg_conv;
21203         this_arg_conv.inner = (void*)(this_arg & (~1));
21204         this_arg_conv.is_owned = false;
21205         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
21206         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21207         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21208         uint64_t ret_ref = (uint64_t)ret_var.inner;
21209         if (ret_var.is_owned) {
21210                 ret_ref |= 1;
21211         }
21212         return ret_ref;
21213 }
21214
21215 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
21216         LDKTrustedCommitmentTransaction this_arg_conv;
21217         this_arg_conv.inner = (void*)(this_arg & (~1));
21218         this_arg_conv.is_owned = false;
21219         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
21220         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21221         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21222         uint64_t ret_ref = (uint64_t)ret_var.inner;
21223         if (ret_var.is_owned) {
21224                 ret_ref |= 1;
21225         }
21226         return ret_ref;
21227 }
21228
21229 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
21230         LDKTrustedCommitmentTransaction this_arg_conv;
21231         this_arg_conv.inner = (void*)(this_arg & (~1));
21232         this_arg_conv.is_owned = false;
21233         unsigned char htlc_base_key_arr[32];
21234         CHECK(*((uint32_t*)htlc_base_key) == 32);
21235         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
21236         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
21237         LDKDirectedChannelTransactionParameters channel_parameters_conv;
21238         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
21239         channel_parameters_conv.is_owned = false;
21240         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
21241         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
21242         return (uint64_t)ret_conv;
21243 }
21244
21245 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) {
21246         LDKPublicKey broadcaster_payment_basepoint_ref;
21247         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
21248         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
21249         LDKPublicKey countersignatory_payment_basepoint_ref;
21250         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
21251         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
21252         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
21253         return ret_val;
21254 }
21255
21256 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
21257         LDKInitFeatures a_conv;
21258         a_conv.inner = (void*)(a & (~1));
21259         a_conv.is_owned = false;
21260         LDKInitFeatures b_conv;
21261         b_conv.inner = (void*)(b & (~1));
21262         b_conv.is_owned = false;
21263         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
21264         return ret_val;
21265 }
21266
21267 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
21268         LDKNodeFeatures a_conv;
21269         a_conv.inner = (void*)(a & (~1));
21270         a_conv.is_owned = false;
21271         LDKNodeFeatures b_conv;
21272         b_conv.inner = (void*)(b & (~1));
21273         b_conv.is_owned = false;
21274         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
21275         return ret_val;
21276 }
21277
21278 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
21279         LDKChannelFeatures a_conv;
21280         a_conv.inner = (void*)(a & (~1));
21281         a_conv.is_owned = false;
21282         LDKChannelFeatures b_conv;
21283         b_conv.inner = (void*)(b & (~1));
21284         b_conv.is_owned = false;
21285         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
21286         return ret_val;
21287 }
21288
21289 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
21290         LDKInvoiceFeatures a_conv;
21291         a_conv.inner = (void*)(a & (~1));
21292         a_conv.is_owned = false;
21293         LDKInvoiceFeatures b_conv;
21294         b_conv.inner = (void*)(b & (~1));
21295         b_conv.is_owned = false;
21296         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
21297         return ret_val;
21298 }
21299
21300 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
21301         LDKInitFeatures orig_conv;
21302         orig_conv.inner = (void*)(orig & (~1));
21303         orig_conv.is_owned = false;
21304         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
21305         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21306         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21307         uint64_t ret_ref = (uint64_t)ret_var.inner;
21308         if (ret_var.is_owned) {
21309                 ret_ref |= 1;
21310         }
21311         return ret_ref;
21312 }
21313
21314 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
21315         LDKNodeFeatures orig_conv;
21316         orig_conv.inner = (void*)(orig & (~1));
21317         orig_conv.is_owned = false;
21318         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
21319         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21320         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21321         uint64_t ret_ref = (uint64_t)ret_var.inner;
21322         if (ret_var.is_owned) {
21323                 ret_ref |= 1;
21324         }
21325         return ret_ref;
21326 }
21327
21328 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
21329         LDKChannelFeatures orig_conv;
21330         orig_conv.inner = (void*)(orig & (~1));
21331         orig_conv.is_owned = false;
21332         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
21333         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21334         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21335         uint64_t ret_ref = (uint64_t)ret_var.inner;
21336         if (ret_var.is_owned) {
21337                 ret_ref |= 1;
21338         }
21339         return ret_ref;
21340 }
21341
21342 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
21343         LDKInvoiceFeatures orig_conv;
21344         orig_conv.inner = (void*)(orig & (~1));
21345         orig_conv.is_owned = false;
21346         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
21347         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21348         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21349         uint64_t ret_ref = (uint64_t)ret_var.inner;
21350         if (ret_var.is_owned) {
21351                 ret_ref |= 1;
21352         }
21353         return ret_ref;
21354 }
21355
21356 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
21357         LDKInitFeatures this_obj_conv;
21358         this_obj_conv.inner = (void*)(this_obj & (~1));
21359         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21360         InitFeatures_free(this_obj_conv);
21361 }
21362
21363 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
21364         LDKNodeFeatures this_obj_conv;
21365         this_obj_conv.inner = (void*)(this_obj & (~1));
21366         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21367         NodeFeatures_free(this_obj_conv);
21368 }
21369
21370 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
21371         LDKChannelFeatures this_obj_conv;
21372         this_obj_conv.inner = (void*)(this_obj & (~1));
21373         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21374         ChannelFeatures_free(this_obj_conv);
21375 }
21376
21377 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
21378         LDKInvoiceFeatures this_obj_conv;
21379         this_obj_conv.inner = (void*)(this_obj & (~1));
21380         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21381         InvoiceFeatures_free(this_obj_conv);
21382 }
21383
21384 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
21385         LDKInitFeatures ret_var = InitFeatures_empty();
21386         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21387         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21388         uint64_t ret_ref = (uint64_t)ret_var.inner;
21389         if (ret_var.is_owned) {
21390                 ret_ref |= 1;
21391         }
21392         return ret_ref;
21393 }
21394
21395 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
21396         LDKInitFeatures ret_var = InitFeatures_known();
21397         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21398         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21399         uint64_t ret_ref = (uint64_t)ret_var.inner;
21400         if (ret_var.is_owned) {
21401                 ret_ref |= 1;
21402         }
21403         return ret_ref;
21404 }
21405
21406 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
21407         LDKNodeFeatures ret_var = NodeFeatures_empty();
21408         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21409         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21410         uint64_t ret_ref = (uint64_t)ret_var.inner;
21411         if (ret_var.is_owned) {
21412                 ret_ref |= 1;
21413         }
21414         return ret_ref;
21415 }
21416
21417 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
21418         LDKNodeFeatures ret_var = NodeFeatures_known();
21419         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21420         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21421         uint64_t ret_ref = (uint64_t)ret_var.inner;
21422         if (ret_var.is_owned) {
21423                 ret_ref |= 1;
21424         }
21425         return ret_ref;
21426 }
21427
21428 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
21429         LDKChannelFeatures ret_var = ChannelFeatures_empty();
21430         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21431         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21432         uint64_t ret_ref = (uint64_t)ret_var.inner;
21433         if (ret_var.is_owned) {
21434                 ret_ref |= 1;
21435         }
21436         return ret_ref;
21437 }
21438
21439 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
21440         LDKChannelFeatures ret_var = ChannelFeatures_known();
21441         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21442         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21443         uint64_t ret_ref = (uint64_t)ret_var.inner;
21444         if (ret_var.is_owned) {
21445                 ret_ref |= 1;
21446         }
21447         return ret_ref;
21448 }
21449
21450 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
21451         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
21452         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21453         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21454         uint64_t ret_ref = (uint64_t)ret_var.inner;
21455         if (ret_var.is_owned) {
21456                 ret_ref |= 1;
21457         }
21458         return ret_ref;
21459 }
21460
21461 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
21462         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
21463         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21464         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21465         uint64_t ret_ref = (uint64_t)ret_var.inner;
21466         if (ret_var.is_owned) {
21467                 ret_ref |= 1;
21468         }
21469         return ret_ref;
21470 }
21471
21472 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
21473         LDKInitFeatures this_arg_conv;
21474         this_arg_conv.inner = (void*)(this_arg & (~1));
21475         this_arg_conv.is_owned = false;
21476         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
21477         return ret_val;
21478 }
21479
21480 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
21481         LDKNodeFeatures this_arg_conv;
21482         this_arg_conv.inner = (void*)(this_arg & (~1));
21483         this_arg_conv.is_owned = false;
21484         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
21485         return ret_val;
21486 }
21487
21488 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
21489         LDKInvoiceFeatures this_arg_conv;
21490         this_arg_conv.inner = (void*)(this_arg & (~1));
21491         this_arg_conv.is_owned = false;
21492         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
21493         return ret_val;
21494 }
21495
21496 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
21497         LDKInitFeatures obj_conv;
21498         obj_conv.inner = (void*)(obj & (~1));
21499         obj_conv.is_owned = false;
21500         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
21501         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21502         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21503         CVec_u8Z_free(ret_var);
21504         return ret_arr;
21505 }
21506
21507 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
21508         LDKNodeFeatures obj_conv;
21509         obj_conv.inner = (void*)(obj & (~1));
21510         obj_conv.is_owned = false;
21511         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
21512         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21513         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21514         CVec_u8Z_free(ret_var);
21515         return ret_arr;
21516 }
21517
21518 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
21519         LDKChannelFeatures obj_conv;
21520         obj_conv.inner = (void*)(obj & (~1));
21521         obj_conv.is_owned = false;
21522         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
21523         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21524         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21525         CVec_u8Z_free(ret_var);
21526         return ret_arr;
21527 }
21528
21529 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
21530         LDKInvoiceFeatures obj_conv;
21531         obj_conv.inner = (void*)(obj & (~1));
21532         obj_conv.is_owned = false;
21533         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
21534         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21535         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21536         CVec_u8Z_free(ret_var);
21537         return ret_arr;
21538 }
21539
21540 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
21541         LDKu8slice ser_ref;
21542         ser_ref.datalen = *((uint32_t*)ser);
21543         ser_ref.data = (int8_t*)(ser + 4);
21544         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
21545         *ret_conv = InitFeatures_read(ser_ref);
21546         return (uint64_t)ret_conv;
21547 }
21548
21549 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
21550         LDKu8slice ser_ref;
21551         ser_ref.datalen = *((uint32_t*)ser);
21552         ser_ref.data = (int8_t*)(ser + 4);
21553         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
21554         *ret_conv = NodeFeatures_read(ser_ref);
21555         return (uint64_t)ret_conv;
21556 }
21557
21558 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
21559         LDKu8slice ser_ref;
21560         ser_ref.datalen = *((uint32_t*)ser);
21561         ser_ref.data = (int8_t*)(ser + 4);
21562         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
21563         *ret_conv = ChannelFeatures_read(ser_ref);
21564         return (uint64_t)ret_conv;
21565 }
21566
21567 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
21568         LDKu8slice ser_ref;
21569         ser_ref.datalen = *((uint32_t*)ser);
21570         ser_ref.data = (int8_t*)(ser + 4);
21571         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
21572         *ret_conv = InvoiceFeatures_read(ser_ref);
21573         return (uint64_t)ret_conv;
21574 }
21575
21576 void  __attribute__((visibility("default"))) TS_ShutdownScript_free(uint32_t this_obj) {
21577         LDKShutdownScript this_obj_conv;
21578         this_obj_conv.inner = (void*)(this_obj & (~1));
21579         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21580         ShutdownScript_free(this_obj_conv);
21581 }
21582
21583 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_clone(uint32_t orig) {
21584         LDKShutdownScript orig_conv;
21585         orig_conv.inner = (void*)(orig & (~1));
21586         orig_conv.is_owned = false;
21587         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
21588         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21589         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21590         uint64_t ret_ref = (uint64_t)ret_var.inner;
21591         if (ret_var.is_owned) {
21592                 ret_ref |= 1;
21593         }
21594         return ret_ref;
21595 }
21596
21597 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
21598         LDKInvalidShutdownScript this_obj_conv;
21599         this_obj_conv.inner = (void*)(this_obj & (~1));
21600         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21601         InvalidShutdownScript_free(this_obj_conv);
21602 }
21603
21604 int8_tArray  __attribute__((visibility("default"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
21605         LDKInvalidShutdownScript this_ptr_conv;
21606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21607         this_ptr_conv.is_owned = false;
21608         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
21609         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21610         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21611         return ret_arr;
21612 }
21613
21614 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
21615         LDKInvalidShutdownScript this_ptr_conv;
21616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21617         this_ptr_conv.is_owned = false;
21618         LDKCVec_u8Z val_ref;
21619         val_ref.datalen = *((uint32_t*)val);
21620         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21621         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
21622         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
21623 }
21624
21625 uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
21626         LDKCVec_u8Z script_arg_ref;
21627         script_arg_ref.datalen = *((uint32_t*)script_arg);
21628         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21629         memcpy(script_arg_ref.data, (uint8_t*)(script_arg + 4), script_arg_ref.datalen);
21630         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
21631         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21632         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21633         uint64_t ret_ref = (uint64_t)ret_var.inner;
21634         if (ret_var.is_owned) {
21635                 ret_ref |= 1;
21636         }
21637         return ret_ref;
21638 }
21639
21640 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_write(uint32_t obj) {
21641         LDKShutdownScript obj_conv;
21642         obj_conv.inner = (void*)(obj & (~1));
21643         obj_conv.is_owned = false;
21644         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
21645         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21646         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21647         CVec_u8Z_free(ret_var);
21648         return ret_arr;
21649 }
21650
21651 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_read(int8_tArray ser) {
21652         LDKu8slice ser_ref;
21653         ser_ref.datalen = *((uint32_t*)ser);
21654         ser_ref.data = (int8_t*)(ser + 4);
21655         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
21656         *ret_conv = ShutdownScript_read(ser_ref);
21657         return (uint64_t)ret_conv;
21658 }
21659
21660 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2pkh(int8_tArray pubkey_hash) {
21661         unsigned char pubkey_hash_arr[20];
21662         CHECK(*((uint32_t*)pubkey_hash) == 20);
21663         memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20);
21664         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
21665         LDKShutdownScript ret_var = ShutdownScript_new_p2pkh(pubkey_hash_ref);
21666         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21667         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21668         uint64_t ret_ref = (uint64_t)ret_var.inner;
21669         if (ret_var.is_owned) {
21670                 ret_ref |= 1;
21671         }
21672         return ret_ref;
21673 }
21674
21675 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2sh(int8_tArray script_hash) {
21676         unsigned char script_hash_arr[20];
21677         CHECK(*((uint32_t*)script_hash) == 20);
21678         memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 20);
21679         unsigned char (*script_hash_ref)[20] = &script_hash_arr;
21680         LDKShutdownScript ret_var = ShutdownScript_new_p2sh(script_hash_ref);
21681         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21682         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21683         uint64_t ret_ref = (uint64_t)ret_var.inner;
21684         if (ret_var.is_owned) {
21685                 ret_ref |= 1;
21686         }
21687         return ret_ref;
21688 }
21689
21690 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
21691         unsigned char pubkey_hash_arr[20];
21692         CHECK(*((uint32_t*)pubkey_hash) == 20);
21693         memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20);
21694         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
21695         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
21696         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21697         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21698         uint64_t ret_ref = (uint64_t)ret_var.inner;
21699         if (ret_var.is_owned) {
21700                 ret_ref |= 1;
21701         }
21702         return ret_ref;
21703 }
21704
21705 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
21706         unsigned char script_hash_arr[32];
21707         CHECK(*((uint32_t*)script_hash) == 32);
21708         memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 32);
21709         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
21710         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
21711         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21712         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21713         uint64_t ret_ref = (uint64_t)ret_var.inner;
21714         if (ret_var.is_owned) {
21715                 ret_ref |= 1;
21716         }
21717         return ret_ref;
21718 }
21719
21720 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
21721         LDKu8slice program_ref;
21722         program_ref.datalen = *((uint32_t*)program);
21723         program_ref.data = (int8_t*)(program + 4);
21724         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
21725         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
21726         return (uint64_t)ret_conv;
21727 }
21728
21729 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
21730         LDKShutdownScript this_arg_conv;
21731         this_arg_conv.inner = (void*)(this_arg & (~1));
21732         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
21733         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
21734         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
21735         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21736         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21737         CVec_u8Z_free(ret_var);
21738         return ret_arr;
21739 }
21740
21741 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
21742         LDKShutdownScript this_arg_conv;
21743         this_arg_conv.inner = (void*)(this_arg & (~1));
21744         this_arg_conv.is_owned = false;
21745         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21746         memcpy((uint8_t*)(ret_arr + 4), ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
21747         return ret_arr;
21748 }
21749
21750 jboolean  __attribute__((visibility("default"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
21751         LDKShutdownScript this_arg_conv;
21752         this_arg_conv.inner = (void*)(this_arg & (~1));
21753         this_arg_conv.is_owned = false;
21754         LDKInitFeatures features_conv;
21755         features_conv.inner = (void*)(features & (~1));
21756         features_conv.is_owned = false;
21757         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
21758         return ret_val;
21759 }
21760
21761 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
21762         LDKRouteHop this_obj_conv;
21763         this_obj_conv.inner = (void*)(this_obj & (~1));
21764         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21765         RouteHop_free(this_obj_conv);
21766 }
21767
21768 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
21769         LDKRouteHop this_ptr_conv;
21770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21771         this_ptr_conv.is_owned = false;
21772         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21773         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
21774         return ret_arr;
21775 }
21776
21777 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
21778         LDKRouteHop this_ptr_conv;
21779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21780         this_ptr_conv.is_owned = false;
21781         LDKPublicKey val_ref;
21782         CHECK(*((uint32_t*)val) == 33);
21783         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21784         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
21785 }
21786
21787 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
21788         LDKRouteHop this_ptr_conv;
21789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21790         this_ptr_conv.is_owned = false;
21791         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
21792         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21793         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21794         uint64_t ret_ref = (uint64_t)ret_var.inner;
21795         if (ret_var.is_owned) {
21796                 ret_ref |= 1;
21797         }
21798         return ret_ref;
21799 }
21800
21801 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
21802         LDKRouteHop this_ptr_conv;
21803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21804         this_ptr_conv.is_owned = false;
21805         LDKNodeFeatures val_conv;
21806         val_conv.inner = (void*)(val & (~1));
21807         val_conv.is_owned = (val & 1) || (val == 0);
21808         val_conv = NodeFeatures_clone(&val_conv);
21809         RouteHop_set_node_features(&this_ptr_conv, val_conv);
21810 }
21811
21812 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
21813         LDKRouteHop this_ptr_conv;
21814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21815         this_ptr_conv.is_owned = false;
21816         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
21817         return ret_val;
21818 }
21819
21820 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
21821         LDKRouteHop this_ptr_conv;
21822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21823         this_ptr_conv.is_owned = false;
21824         RouteHop_set_short_channel_id(&this_ptr_conv, val);
21825 }
21826
21827 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
21828         LDKRouteHop this_ptr_conv;
21829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21830         this_ptr_conv.is_owned = false;
21831         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
21832         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21833         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21834         uint64_t ret_ref = (uint64_t)ret_var.inner;
21835         if (ret_var.is_owned) {
21836                 ret_ref |= 1;
21837         }
21838         return ret_ref;
21839 }
21840
21841 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
21842         LDKRouteHop this_ptr_conv;
21843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21844         this_ptr_conv.is_owned = false;
21845         LDKChannelFeatures val_conv;
21846         val_conv.inner = (void*)(val & (~1));
21847         val_conv.is_owned = (val & 1) || (val == 0);
21848         val_conv = ChannelFeatures_clone(&val_conv);
21849         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
21850 }
21851
21852 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
21853         LDKRouteHop this_ptr_conv;
21854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21855         this_ptr_conv.is_owned = false;
21856         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
21857         return ret_val;
21858 }
21859
21860 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
21861         LDKRouteHop this_ptr_conv;
21862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21863         this_ptr_conv.is_owned = false;
21864         RouteHop_set_fee_msat(&this_ptr_conv, val);
21865 }
21866
21867 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
21868         LDKRouteHop this_ptr_conv;
21869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21870         this_ptr_conv.is_owned = false;
21871         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
21872         return ret_val;
21873 }
21874
21875 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
21876         LDKRouteHop this_ptr_conv;
21877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21878         this_ptr_conv.is_owned = false;
21879         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
21880 }
21881
21882 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) {
21883         LDKPublicKey pubkey_arg_ref;
21884         CHECK(*((uint32_t*)pubkey_arg) == 33);
21885         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
21886         LDKNodeFeatures node_features_arg_conv;
21887         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
21888         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
21889         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
21890         LDKChannelFeatures channel_features_arg_conv;
21891         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
21892         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
21893         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
21894         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);
21895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21897         uint64_t ret_ref = (uint64_t)ret_var.inner;
21898         if (ret_var.is_owned) {
21899                 ret_ref |= 1;
21900         }
21901         return ret_ref;
21902 }
21903
21904 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
21905         LDKRouteHop orig_conv;
21906         orig_conv.inner = (void*)(orig & (~1));
21907         orig_conv.is_owned = false;
21908         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
21909         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21910         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21911         uint64_t ret_ref = (uint64_t)ret_var.inner;
21912         if (ret_var.is_owned) {
21913                 ret_ref |= 1;
21914         }
21915         return ret_ref;
21916 }
21917
21918 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) {
21919         LDKRouteHop obj_conv;
21920         obj_conv.inner = (void*)(obj & (~1));
21921         obj_conv.is_owned = false;
21922         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
21923         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21924         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21925         CVec_u8Z_free(ret_var);
21926         return ret_arr;
21927 }
21928
21929 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_read(int8_tArray ser) {
21930         LDKu8slice ser_ref;
21931         ser_ref.datalen = *((uint32_t*)ser);
21932         ser_ref.data = (int8_t*)(ser + 4);
21933         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
21934         *ret_conv = RouteHop_read(ser_ref);
21935         return (uint64_t)ret_conv;
21936 }
21937
21938 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
21939         LDKRoute this_obj_conv;
21940         this_obj_conv.inner = (void*)(this_obj & (~1));
21941         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21942         Route_free(this_obj_conv);
21943 }
21944
21945 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
21946         LDKRoute this_ptr_conv;
21947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21948         this_ptr_conv.is_owned = false;
21949         LDKCVec_CVec_RouteHopZZ val_constr;
21950         val_constr.datalen = *((uint32_t*)val);
21951         if (val_constr.datalen > 0)
21952                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
21953         else
21954                 val_constr.data = NULL;
21955         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
21956         for (size_t m = 0; m < val_constr.datalen; m++) {
21957                 uint32_tArray val_conv_12 = val_vals[m];
21958                 LDKCVec_RouteHopZ val_conv_12_constr;
21959                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
21960                 if (val_conv_12_constr.datalen > 0)
21961                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21962                 else
21963                         val_conv_12_constr.data = NULL;
21964                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
21965                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
21966                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
21967                         LDKRouteHop val_conv_12_conv_10_conv;
21968                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
21969                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
21970                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
21971                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
21972                 }
21973                 val_constr.data[m] = val_conv_12_constr;
21974         }
21975         Route_set_paths(&this_ptr_conv, val_constr);
21976 }
21977
21978 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
21979         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
21980         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
21981         if (paths_arg_constr.datalen > 0)
21982                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
21983         else
21984                 paths_arg_constr.data = NULL;
21985         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
21986         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
21987                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
21988                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
21989                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
21990                 if (paths_arg_conv_12_constr.datalen > 0)
21991                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21992                 else
21993                         paths_arg_conv_12_constr.data = NULL;
21994                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
21995                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
21996                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
21997                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
21998                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
21999                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
22000                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
22001                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
22002                 }
22003                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
22004         }
22005         LDKRoute ret_var = Route_new(paths_arg_constr);
22006         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22007         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22008         uint64_t ret_ref = (uint64_t)ret_var.inner;
22009         if (ret_var.is_owned) {
22010                 ret_ref |= 1;
22011         }
22012         return ret_ref;
22013 }
22014
22015 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
22016         LDKRoute orig_conv;
22017         orig_conv.inner = (void*)(orig & (~1));
22018         orig_conv.is_owned = false;
22019         LDKRoute ret_var = Route_clone(&orig_conv);
22020         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22021         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22022         uint64_t ret_ref = (uint64_t)ret_var.inner;
22023         if (ret_var.is_owned) {
22024                 ret_ref |= 1;
22025         }
22026         return ret_ref;
22027 }
22028
22029 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
22030         LDKRoute obj_conv;
22031         obj_conv.inner = (void*)(obj & (~1));
22032         obj_conv.is_owned = false;
22033         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
22034         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22035         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22036         CVec_u8Z_free(ret_var);
22037         return ret_arr;
22038 }
22039
22040 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
22041         LDKu8slice ser_ref;
22042         ser_ref.datalen = *((uint32_t*)ser);
22043         ser_ref.data = (int8_t*)(ser + 4);
22044         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
22045         *ret_conv = Route_read(ser_ref);
22046         return (uint64_t)ret_conv;
22047 }
22048
22049 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
22050         LDKRouteHint this_obj_conv;
22051         this_obj_conv.inner = (void*)(this_obj & (~1));
22052         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22053         RouteHint_free(this_obj_conv);
22054 }
22055
22056 jboolean  __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
22057         LDKRouteHint a_conv;
22058         a_conv.inner = (void*)(a & (~1));
22059         a_conv.is_owned = false;
22060         LDKRouteHint b_conv;
22061         b_conv.inner = (void*)(b & (~1));
22062         b_conv.is_owned = false;
22063         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
22064         return ret_val;
22065 }
22066
22067 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
22068         LDKRouteHint orig_conv;
22069         orig_conv.inner = (void*)(orig & (~1));
22070         orig_conv.is_owned = false;
22071         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
22072         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22073         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22074         uint64_t ret_ref = (uint64_t)ret_var.inner;
22075         if (ret_var.is_owned) {
22076                 ret_ref |= 1;
22077         }
22078         return ret_ref;
22079 }
22080
22081 void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
22082         LDKRouteHintHop this_obj_conv;
22083         this_obj_conv.inner = (void*)(this_obj & (~1));
22084         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22085         RouteHintHop_free(this_obj_conv);
22086 }
22087
22088 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
22089         LDKRouteHintHop this_ptr_conv;
22090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22091         this_ptr_conv.is_owned = false;
22092         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22093         memcpy((uint8_t*)(ret_arr + 4), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
22094         return ret_arr;
22095 }
22096
22097 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
22098         LDKRouteHintHop this_ptr_conv;
22099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22100         this_ptr_conv.is_owned = false;
22101         LDKPublicKey val_ref;
22102         CHECK(*((uint32_t*)val) == 33);
22103         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22104         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
22105 }
22106
22107 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
22108         LDKRouteHintHop this_ptr_conv;
22109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22110         this_ptr_conv.is_owned = false;
22111         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
22112         return ret_val;
22113 }
22114
22115 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
22116         LDKRouteHintHop this_ptr_conv;
22117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22118         this_ptr_conv.is_owned = false;
22119         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
22120 }
22121
22122 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
22123         LDKRouteHintHop this_ptr_conv;
22124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22125         this_ptr_conv.is_owned = false;
22126         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
22127         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22128         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22129         uint64_t ret_ref = (uint64_t)ret_var.inner;
22130         if (ret_var.is_owned) {
22131                 ret_ref |= 1;
22132         }
22133         return ret_ref;
22134 }
22135
22136 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
22137         LDKRouteHintHop this_ptr_conv;
22138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22139         this_ptr_conv.is_owned = false;
22140         LDKRoutingFees val_conv;
22141         val_conv.inner = (void*)(val & (~1));
22142         val_conv.is_owned = (val & 1) || (val == 0);
22143         val_conv = RoutingFees_clone(&val_conv);
22144         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
22145 }
22146
22147 int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
22148         LDKRouteHintHop this_ptr_conv;
22149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22150         this_ptr_conv.is_owned = false;
22151         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
22152         return ret_val;
22153 }
22154
22155 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
22156         LDKRouteHintHop this_ptr_conv;
22157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22158         this_ptr_conv.is_owned = false;
22159         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
22160 }
22161
22162 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
22163         LDKRouteHintHop this_ptr_conv;
22164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22165         this_ptr_conv.is_owned = false;
22166         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
22167         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
22168         uint64_t ret_ref = (uint64_t)ret_copy;
22169         return ret_ref;
22170 }
22171
22172 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
22173         LDKRouteHintHop this_ptr_conv;
22174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22175         this_ptr_conv.is_owned = false;
22176         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
22177         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
22178 }
22179
22180 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
22181         LDKRouteHintHop this_ptr_conv;
22182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22183         this_ptr_conv.is_owned = false;
22184         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
22185         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
22186         uint64_t ret_ref = (uint64_t)ret_copy;
22187         return ret_ref;
22188 }
22189
22190 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
22191         LDKRouteHintHop this_ptr_conv;
22192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22193         this_ptr_conv.is_owned = false;
22194         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
22195         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
22196 }
22197
22198 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) {
22199         LDKPublicKey src_node_id_arg_ref;
22200         CHECK(*((uint32_t*)src_node_id_arg) == 33);
22201         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
22202         LDKRoutingFees fees_arg_conv;
22203         fees_arg_conv.inner = (void*)(fees_arg & (~1));
22204         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
22205         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
22206         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
22207         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
22208         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);
22209         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22210         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22211         uint64_t ret_ref = (uint64_t)ret_var.inner;
22212         if (ret_var.is_owned) {
22213                 ret_ref |= 1;
22214         }
22215         return ret_ref;
22216 }
22217
22218 jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
22219         LDKRouteHintHop a_conv;
22220         a_conv.inner = (void*)(a & (~1));
22221         a_conv.is_owned = false;
22222         LDKRouteHintHop b_conv;
22223         b_conv.inner = (void*)(b & (~1));
22224         b_conv.is_owned = false;
22225         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
22226         return ret_val;
22227 }
22228
22229 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) {
22230         LDKRouteHintHop orig_conv;
22231         orig_conv.inner = (void*)(orig & (~1));
22232         orig_conv.is_owned = false;
22233         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
22234         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22235         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22236         uint64_t ret_ref = (uint64_t)ret_var.inner;
22237         if (ret_var.is_owned) {
22238                 ret_ref |= 1;
22239         }
22240         return ret_ref;
22241 }
22242
22243 uint32_t  __attribute__((visibility("default"))) TS_get_keysend_route(int8_tArray our_node_id, uint32_t network, int8_tArray payee, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) {
22244         LDKPublicKey our_node_id_ref;
22245         CHECK(*((uint32_t*)our_node_id) == 33);
22246         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
22247         LDKNetworkGraph network_conv;
22248         network_conv.inner = (void*)(network & (~1));
22249         network_conv.is_owned = false;
22250         LDKPublicKey payee_ref;
22251         CHECK(*((uint32_t*)payee) == 33);
22252         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
22253         LDKCVec_ChannelDetailsZ first_hops_constr;
22254         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
22255         if (first_hops != 0) {
22256                 first_hops_constr.datalen = *((uint32_t*)first_hops);
22257                 if (first_hops_constr.datalen > 0)
22258                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
22259                 else
22260                         first_hops_constr.data = NULL;
22261                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
22262                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
22263                         uint32_t first_hops_conv_16 = first_hops_vals[q];
22264                         LDKChannelDetails first_hops_conv_16_conv;
22265                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
22266                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
22267                         first_hops_constr.data[q] = first_hops_conv_16_conv;
22268                 }
22269                 first_hops_ptr = &first_hops_constr;
22270         }
22271         LDKCVec_RouteHintZ last_hops_constr;
22272         last_hops_constr.datalen = *((uint32_t*)last_hops);
22273         if (last_hops_constr.datalen > 0)
22274                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
22275         else
22276                 last_hops_constr.data = NULL;
22277         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
22278         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
22279                 uint32_t last_hops_conv_11 = last_hops_vals[l];
22280                 LDKRouteHint last_hops_conv_11_conv;
22281                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
22282                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
22283                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
22284                 last_hops_constr.data[l] = last_hops_conv_11_conv;
22285         }
22286         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
22287         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
22288         *ret_conv = get_keysend_route(our_node_id_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
22289         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
22290         return (uint64_t)ret_conv;
22291 }
22292
22293 uint32_t  __attribute__((visibility("default"))) TS_get_route(int8_tArray our_node_id, uint32_t network, int8_tArray payee, uint32_t payee_features, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) {
22294         LDKPublicKey our_node_id_ref;
22295         CHECK(*((uint32_t*)our_node_id) == 33);
22296         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
22297         LDKNetworkGraph network_conv;
22298         network_conv.inner = (void*)(network & (~1));
22299         network_conv.is_owned = false;
22300         LDKPublicKey payee_ref;
22301         CHECK(*((uint32_t*)payee) == 33);
22302         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
22303         LDKInvoiceFeatures payee_features_conv;
22304         payee_features_conv.inner = (void*)(payee_features & (~1));
22305         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
22306         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
22307         LDKCVec_ChannelDetailsZ first_hops_constr;
22308         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
22309         if (first_hops != 0) {
22310                 first_hops_constr.datalen = *((uint32_t*)first_hops);
22311                 if (first_hops_constr.datalen > 0)
22312                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
22313                 else
22314                         first_hops_constr.data = NULL;
22315                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
22316                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
22317                         uint32_t first_hops_conv_16 = first_hops_vals[q];
22318                         LDKChannelDetails first_hops_conv_16_conv;
22319                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
22320                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
22321                         first_hops_constr.data[q] = first_hops_conv_16_conv;
22322                 }
22323                 first_hops_ptr = &first_hops_constr;
22324         }
22325         LDKCVec_RouteHintZ last_hops_constr;
22326         last_hops_constr.datalen = *((uint32_t*)last_hops);
22327         if (last_hops_constr.datalen > 0)
22328                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
22329         else
22330                 last_hops_constr.data = NULL;
22331         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
22332         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
22333                 uint32_t last_hops_conv_11 = last_hops_vals[l];
22334                 LDKRouteHint last_hops_conv_11_conv;
22335                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
22336                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
22337                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
22338                 last_hops_constr.data[l] = last_hops_conv_11_conv;
22339         }
22340         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
22341         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
22342         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
22343         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
22344         return (uint64_t)ret_conv;
22345 }
22346
22347 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
22348         LDKNetworkGraph this_obj_conv;
22349         this_obj_conv.inner = (void*)(this_obj & (~1));
22350         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22351         NetworkGraph_free(this_obj_conv);
22352 }
22353
22354 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
22355         LDKNetworkGraph orig_conv;
22356         orig_conv.inner = (void*)(orig & (~1));
22357         orig_conv.is_owned = false;
22358         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
22359         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22360         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22361         uint64_t ret_ref = (uint64_t)ret_var.inner;
22362         if (ret_var.is_owned) {
22363                 ret_ref |= 1;
22364         }
22365         return ret_ref;
22366 }
22367
22368 void  __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_obj) {
22369         LDKLockedNetworkGraph this_obj_conv;
22370         this_obj_conv.inner = (void*)(this_obj & (~1));
22371         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22372         LockedNetworkGraph_free(this_obj_conv);
22373 }
22374
22375 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
22376         LDKNetGraphMsgHandler this_obj_conv;
22377         this_obj_conv.inner = (void*)(this_obj & (~1));
22378         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22379         NetGraphMsgHandler_free(this_obj_conv);
22380 }
22381
22382 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
22383         LDKThirtyTwoBytes genesis_hash_ref;
22384         CHECK(*((uint32_t*)genesis_hash) == 32);
22385         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
22386         LDKAccess *chain_access_conv_ptr = NULL;
22387         if (chain_access != 0) {
22388                 LDKAccess chain_access_conv;
22389                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
22390                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
22391                 *chain_access_conv_ptr = chain_access_conv;
22392         }
22393         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
22394         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
22395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22397         uint64_t ret_ref = (uint64_t)ret_var.inner;
22398         if (ret_var.is_owned) {
22399                 ret_ref |= 1;
22400         }
22401         return ret_ref;
22402 }
22403
22404 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
22405         LDKAccess *chain_access_conv_ptr = NULL;
22406         if (chain_access != 0) {
22407                 LDKAccess chain_access_conv;
22408                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
22409                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
22410                 *chain_access_conv_ptr = chain_access_conv;
22411         }
22412         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
22413         LDKNetworkGraph network_graph_conv;
22414         network_graph_conv.inner = (void*)(network_graph & (~1));
22415         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
22416         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
22417         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
22418         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22419         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22420         uint64_t ret_ref = (uint64_t)ret_var.inner;
22421         if (ret_var.is_owned) {
22422                 ret_ref |= 1;
22423         }
22424         return ret_ref;
22425 }
22426
22427 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
22428         LDKNetGraphMsgHandler this_arg_conv;
22429         this_arg_conv.inner = (void*)(this_arg & (~1));
22430         this_arg_conv.is_owned = false;
22431         LDKAccess *chain_access_conv_ptr = NULL;
22432         if (chain_access != 0) {
22433                 LDKAccess chain_access_conv;
22434                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
22435                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
22436                 *chain_access_conv_ptr = chain_access_conv;
22437         }
22438         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
22439 }
22440
22441 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) {
22442         LDKNetGraphMsgHandler this_arg_conv;
22443         this_arg_conv.inner = (void*)(this_arg & (~1));
22444         this_arg_conv.is_owned = false;
22445         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
22446         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22447         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22448         uint64_t ret_ref = (uint64_t)ret_var.inner;
22449         if (ret_var.is_owned) {
22450                 ret_ref |= 1;
22451         }
22452         return ret_ref;
22453 }
22454
22455 uint32_t  __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) {
22456         LDKLockedNetworkGraph this_arg_conv;
22457         this_arg_conv.inner = (void*)(this_arg & (~1));
22458         this_arg_conv.is_owned = false;
22459         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
22460         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22461         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22462         uint64_t ret_ref = (uint64_t)ret_var.inner;
22463         if (ret_var.is_owned) {
22464                 ret_ref |= 1;
22465         }
22466         return ret_ref;
22467 }
22468
22469 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
22470         LDKNetGraphMsgHandler this_arg_conv;
22471         this_arg_conv.inner = (void*)(this_arg & (~1));
22472         this_arg_conv.is_owned = false;
22473         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
22474         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
22475         return (uint64_t)ret;
22476 }
22477
22478 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
22479         LDKNetGraphMsgHandler this_arg_conv;
22480         this_arg_conv.inner = (void*)(this_arg & (~1));
22481         this_arg_conv.is_owned = false;
22482         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
22483         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
22484         return (uint64_t)ret;
22485 }
22486
22487 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
22488         LDKDirectionalChannelInfo this_obj_conv;
22489         this_obj_conv.inner = (void*)(this_obj & (~1));
22490         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22491         DirectionalChannelInfo_free(this_obj_conv);
22492 }
22493
22494 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
22495         LDKDirectionalChannelInfo this_ptr_conv;
22496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22497         this_ptr_conv.is_owned = false;
22498         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
22499         return ret_val;
22500 }
22501
22502 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
22503         LDKDirectionalChannelInfo this_ptr_conv;
22504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22505         this_ptr_conv.is_owned = false;
22506         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
22507 }
22508
22509 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
22510         LDKDirectionalChannelInfo this_ptr_conv;
22511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22512         this_ptr_conv.is_owned = false;
22513         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
22514         return ret_val;
22515 }
22516
22517 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
22518         LDKDirectionalChannelInfo this_ptr_conv;
22519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22520         this_ptr_conv.is_owned = false;
22521         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
22522 }
22523
22524 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
22525         LDKDirectionalChannelInfo this_ptr_conv;
22526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22527         this_ptr_conv.is_owned = false;
22528         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
22529         return ret_val;
22530 }
22531
22532 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
22533         LDKDirectionalChannelInfo this_ptr_conv;
22534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22535         this_ptr_conv.is_owned = false;
22536         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
22537 }
22538
22539 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
22540         LDKDirectionalChannelInfo this_ptr_conv;
22541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22542         this_ptr_conv.is_owned = false;
22543         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
22544         return ret_val;
22545 }
22546
22547 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
22548         LDKDirectionalChannelInfo this_ptr_conv;
22549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22550         this_ptr_conv.is_owned = false;
22551         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
22552 }
22553
22554 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
22555         LDKDirectionalChannelInfo this_ptr_conv;
22556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22557         this_ptr_conv.is_owned = false;
22558         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
22559         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
22560         uint64_t ret_ref = (uint64_t)ret_copy;
22561         return ret_ref;
22562 }
22563
22564 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
22565         LDKDirectionalChannelInfo this_ptr_conv;
22566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22567         this_ptr_conv.is_owned = false;
22568         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
22569         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
22570 }
22571
22572 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
22573         LDKDirectionalChannelInfo this_ptr_conv;
22574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22575         this_ptr_conv.is_owned = false;
22576         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
22577         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22578         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22579         uint64_t ret_ref = (uint64_t)ret_var.inner;
22580         if (ret_var.is_owned) {
22581                 ret_ref |= 1;
22582         }
22583         return ret_ref;
22584 }
22585
22586 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
22587         LDKDirectionalChannelInfo this_ptr_conv;
22588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22589         this_ptr_conv.is_owned = false;
22590         LDKRoutingFees val_conv;
22591         val_conv.inner = (void*)(val & (~1));
22592         val_conv.is_owned = (val & 1) || (val == 0);
22593         val_conv = RoutingFees_clone(&val_conv);
22594         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
22595 }
22596
22597 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
22598         LDKDirectionalChannelInfo this_ptr_conv;
22599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22600         this_ptr_conv.is_owned = false;
22601         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
22602         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22603         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22604         uint64_t ret_ref = (uint64_t)ret_var.inner;
22605         if (ret_var.is_owned) {
22606                 ret_ref |= 1;
22607         }
22608         return ret_ref;
22609 }
22610
22611 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
22612         LDKDirectionalChannelInfo this_ptr_conv;
22613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22614         this_ptr_conv.is_owned = false;
22615         LDKChannelUpdate val_conv;
22616         val_conv.inner = (void*)(val & (~1));
22617         val_conv.is_owned = (val & 1) || (val == 0);
22618         val_conv = ChannelUpdate_clone(&val_conv);
22619         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
22620 }
22621
22622 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) {
22623         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
22624         LDKRoutingFees fees_arg_conv;
22625         fees_arg_conv.inner = (void*)(fees_arg & (~1));
22626         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
22627         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
22628         LDKChannelUpdate last_update_message_arg_conv;
22629         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
22630         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
22631         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
22632         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);
22633         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22634         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22635         uint64_t ret_ref = (uint64_t)ret_var.inner;
22636         if (ret_var.is_owned) {
22637                 ret_ref |= 1;
22638         }
22639         return ret_ref;
22640 }
22641
22642 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
22643         LDKDirectionalChannelInfo orig_conv;
22644         orig_conv.inner = (void*)(orig & (~1));
22645         orig_conv.is_owned = false;
22646         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
22647         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22648         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22649         uint64_t ret_ref = (uint64_t)ret_var.inner;
22650         if (ret_var.is_owned) {
22651                 ret_ref |= 1;
22652         }
22653         return ret_ref;
22654 }
22655
22656 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
22657         LDKDirectionalChannelInfo obj_conv;
22658         obj_conv.inner = (void*)(obj & (~1));
22659         obj_conv.is_owned = false;
22660         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
22661         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22662         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22663         CVec_u8Z_free(ret_var);
22664         return ret_arr;
22665 }
22666
22667 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
22668         LDKu8slice ser_ref;
22669         ser_ref.datalen = *((uint32_t*)ser);
22670         ser_ref.data = (int8_t*)(ser + 4);
22671         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
22672         *ret_conv = DirectionalChannelInfo_read(ser_ref);
22673         return (uint64_t)ret_conv;
22674 }
22675
22676 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
22677         LDKChannelInfo this_obj_conv;
22678         this_obj_conv.inner = (void*)(this_obj & (~1));
22679         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22680         ChannelInfo_free(this_obj_conv);
22681 }
22682
22683 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
22684         LDKChannelInfo this_ptr_conv;
22685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22686         this_ptr_conv.is_owned = false;
22687         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
22688         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22689         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22690         uint64_t ret_ref = (uint64_t)ret_var.inner;
22691         if (ret_var.is_owned) {
22692                 ret_ref |= 1;
22693         }
22694         return ret_ref;
22695 }
22696
22697 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
22698         LDKChannelInfo this_ptr_conv;
22699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22700         this_ptr_conv.is_owned = false;
22701         LDKChannelFeatures val_conv;
22702         val_conv.inner = (void*)(val & (~1));
22703         val_conv.is_owned = (val & 1) || (val == 0);
22704         val_conv = ChannelFeatures_clone(&val_conv);
22705         ChannelInfo_set_features(&this_ptr_conv, val_conv);
22706 }
22707
22708 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
22709         LDKChannelInfo this_ptr_conv;
22710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22711         this_ptr_conv.is_owned = false;
22712         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22713         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
22714         return ret_arr;
22715 }
22716
22717 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
22718         LDKChannelInfo this_ptr_conv;
22719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22720         this_ptr_conv.is_owned = false;
22721         LDKPublicKey val_ref;
22722         CHECK(*((uint32_t*)val) == 33);
22723         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22724         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
22725 }
22726
22727 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
22728         LDKChannelInfo this_ptr_conv;
22729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22730         this_ptr_conv.is_owned = false;
22731         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
22732         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22733         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22734         uint64_t ret_ref = (uint64_t)ret_var.inner;
22735         if (ret_var.is_owned) {
22736                 ret_ref |= 1;
22737         }
22738         return ret_ref;
22739 }
22740
22741 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
22742         LDKChannelInfo this_ptr_conv;
22743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22744         this_ptr_conv.is_owned = false;
22745         LDKDirectionalChannelInfo val_conv;
22746         val_conv.inner = (void*)(val & (~1));
22747         val_conv.is_owned = (val & 1) || (val == 0);
22748         val_conv = DirectionalChannelInfo_clone(&val_conv);
22749         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
22750 }
22751
22752 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
22753         LDKChannelInfo this_ptr_conv;
22754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22755         this_ptr_conv.is_owned = false;
22756         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22757         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
22758         return ret_arr;
22759 }
22760
22761 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
22762         LDKChannelInfo this_ptr_conv;
22763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22764         this_ptr_conv.is_owned = false;
22765         LDKPublicKey val_ref;
22766         CHECK(*((uint32_t*)val) == 33);
22767         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22768         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
22769 }
22770
22771 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
22772         LDKChannelInfo this_ptr_conv;
22773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22774         this_ptr_conv.is_owned = false;
22775         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
22776         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22777         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22778         uint64_t ret_ref = (uint64_t)ret_var.inner;
22779         if (ret_var.is_owned) {
22780                 ret_ref |= 1;
22781         }
22782         return ret_ref;
22783 }
22784
22785 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
22786         LDKChannelInfo this_ptr_conv;
22787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22788         this_ptr_conv.is_owned = false;
22789         LDKDirectionalChannelInfo val_conv;
22790         val_conv.inner = (void*)(val & (~1));
22791         val_conv.is_owned = (val & 1) || (val == 0);
22792         val_conv = DirectionalChannelInfo_clone(&val_conv);
22793         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
22794 }
22795
22796 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
22797         LDKChannelInfo this_ptr_conv;
22798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22799         this_ptr_conv.is_owned = false;
22800         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
22801         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
22802         uint64_t ret_ref = (uint64_t)ret_copy;
22803         return ret_ref;
22804 }
22805
22806 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
22807         LDKChannelInfo this_ptr_conv;
22808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22809         this_ptr_conv.is_owned = false;
22810         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
22811         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
22812 }
22813
22814 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
22815         LDKChannelInfo this_ptr_conv;
22816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22817         this_ptr_conv.is_owned = false;
22818         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
22819         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22820         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22821         uint64_t ret_ref = (uint64_t)ret_var.inner;
22822         if (ret_var.is_owned) {
22823                 ret_ref |= 1;
22824         }
22825         return ret_ref;
22826 }
22827
22828 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
22829         LDKChannelInfo this_ptr_conv;
22830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22831         this_ptr_conv.is_owned = false;
22832         LDKChannelAnnouncement val_conv;
22833         val_conv.inner = (void*)(val & (~1));
22834         val_conv.is_owned = (val & 1) || (val == 0);
22835         val_conv = ChannelAnnouncement_clone(&val_conv);
22836         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
22837 }
22838
22839 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_new(uint32_t features_arg, int8_tArray node_one_arg, uint32_t one_to_two_arg, int8_tArray node_two_arg, uint32_t two_to_one_arg, uint32_t capacity_sats_arg, uint32_t announcement_message_arg) {
22840         LDKChannelFeatures features_arg_conv;
22841         features_arg_conv.inner = (void*)(features_arg & (~1));
22842         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
22843         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
22844         LDKPublicKey node_one_arg_ref;
22845         CHECK(*((uint32_t*)node_one_arg) == 33);
22846         memcpy(node_one_arg_ref.compressed_form, (uint8_t*)(node_one_arg + 4), 33);
22847         LDKDirectionalChannelInfo one_to_two_arg_conv;
22848         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
22849         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
22850         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
22851         LDKPublicKey node_two_arg_ref;
22852         CHECK(*((uint32_t*)node_two_arg) == 33);
22853         memcpy(node_two_arg_ref.compressed_form, (uint8_t*)(node_two_arg + 4), 33);
22854         LDKDirectionalChannelInfo two_to_one_arg_conv;
22855         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
22856         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
22857         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
22858         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
22859         LDKChannelAnnouncement announcement_message_arg_conv;
22860         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
22861         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
22862         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
22863         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_ref, one_to_two_arg_conv, node_two_arg_ref, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
22864         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22865         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22866         uint64_t ret_ref = (uint64_t)ret_var.inner;
22867         if (ret_var.is_owned) {
22868                 ret_ref |= 1;
22869         }
22870         return ret_ref;
22871 }
22872
22873 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
22874         LDKChannelInfo orig_conv;
22875         orig_conv.inner = (void*)(orig & (~1));
22876         orig_conv.is_owned = false;
22877         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
22878         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22879         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22880         uint64_t ret_ref = (uint64_t)ret_var.inner;
22881         if (ret_var.is_owned) {
22882                 ret_ref |= 1;
22883         }
22884         return ret_ref;
22885 }
22886
22887 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
22888         LDKChannelInfo obj_conv;
22889         obj_conv.inner = (void*)(obj & (~1));
22890         obj_conv.is_owned = false;
22891         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
22892         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22893         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22894         CVec_u8Z_free(ret_var);
22895         return ret_arr;
22896 }
22897
22898 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
22899         LDKu8slice ser_ref;
22900         ser_ref.datalen = *((uint32_t*)ser);
22901         ser_ref.data = (int8_t*)(ser + 4);
22902         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
22903         *ret_conv = ChannelInfo_read(ser_ref);
22904         return (uint64_t)ret_conv;
22905 }
22906
22907 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
22908         LDKRoutingFees this_obj_conv;
22909         this_obj_conv.inner = (void*)(this_obj & (~1));
22910         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22911         RoutingFees_free(this_obj_conv);
22912 }
22913
22914 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
22915         LDKRoutingFees this_ptr_conv;
22916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22917         this_ptr_conv.is_owned = false;
22918         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
22919         return ret_val;
22920 }
22921
22922 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
22923         LDKRoutingFees this_ptr_conv;
22924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22925         this_ptr_conv.is_owned = false;
22926         RoutingFees_set_base_msat(&this_ptr_conv, val);
22927 }
22928
22929 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
22930         LDKRoutingFees this_ptr_conv;
22931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22932         this_ptr_conv.is_owned = false;
22933         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
22934         return ret_val;
22935 }
22936
22937 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
22938         LDKRoutingFees this_ptr_conv;
22939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22940         this_ptr_conv.is_owned = false;
22941         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
22942 }
22943
22944 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
22945         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
22946         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22947         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22948         uint64_t ret_ref = (uint64_t)ret_var.inner;
22949         if (ret_var.is_owned) {
22950                 ret_ref |= 1;
22951         }
22952         return ret_ref;
22953 }
22954
22955 jboolean  __attribute__((visibility("default"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
22956         LDKRoutingFees a_conv;
22957         a_conv.inner = (void*)(a & (~1));
22958         a_conv.is_owned = false;
22959         LDKRoutingFees b_conv;
22960         b_conv.inner = (void*)(b & (~1));
22961         b_conv.is_owned = false;
22962         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
22963         return ret_val;
22964 }
22965
22966 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
22967         LDKRoutingFees orig_conv;
22968         orig_conv.inner = (void*)(orig & (~1));
22969         orig_conv.is_owned = false;
22970         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
22971         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22972         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22973         uint64_t ret_ref = (uint64_t)ret_var.inner;
22974         if (ret_var.is_owned) {
22975                 ret_ref |= 1;
22976         }
22977         return ret_ref;
22978 }
22979
22980 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
22981         LDKRoutingFees obj_conv;
22982         obj_conv.inner = (void*)(obj & (~1));
22983         obj_conv.is_owned = false;
22984         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
22985         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22986         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22987         CVec_u8Z_free(ret_var);
22988         return ret_arr;
22989 }
22990
22991 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
22992         LDKu8slice ser_ref;
22993         ser_ref.datalen = *((uint32_t*)ser);
22994         ser_ref.data = (int8_t*)(ser + 4);
22995         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
22996         *ret_conv = RoutingFees_read(ser_ref);
22997         return (uint64_t)ret_conv;
22998 }
22999
23000 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
23001         LDKNodeAnnouncementInfo this_obj_conv;
23002         this_obj_conv.inner = (void*)(this_obj & (~1));
23003         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23004         NodeAnnouncementInfo_free(this_obj_conv);
23005 }
23006
23007 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
23008         LDKNodeAnnouncementInfo this_ptr_conv;
23009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23010         this_ptr_conv.is_owned = false;
23011         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
23012         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23013         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23014         uint64_t ret_ref = (uint64_t)ret_var.inner;
23015         if (ret_var.is_owned) {
23016                 ret_ref |= 1;
23017         }
23018         return ret_ref;
23019 }
23020
23021 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
23022         LDKNodeAnnouncementInfo this_ptr_conv;
23023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23024         this_ptr_conv.is_owned = false;
23025         LDKNodeFeatures val_conv;
23026         val_conv.inner = (void*)(val & (~1));
23027         val_conv.is_owned = (val & 1) || (val == 0);
23028         val_conv = NodeFeatures_clone(&val_conv);
23029         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
23030 }
23031
23032 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
23033         LDKNodeAnnouncementInfo this_ptr_conv;
23034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23035         this_ptr_conv.is_owned = false;
23036         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
23037         return ret_val;
23038 }
23039
23040 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
23041         LDKNodeAnnouncementInfo this_ptr_conv;
23042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23043         this_ptr_conv.is_owned = false;
23044         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
23045 }
23046
23047 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
23048         LDKNodeAnnouncementInfo this_ptr_conv;
23049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23050         this_ptr_conv.is_owned = false;
23051         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
23052         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
23053         return ret_arr;
23054 }
23055
23056 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
23057         LDKNodeAnnouncementInfo this_ptr_conv;
23058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23059         this_ptr_conv.is_owned = false;
23060         LDKThreeBytes val_ref;
23061         CHECK(*((uint32_t*)val) == 3);
23062         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
23063         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
23064 }
23065
23066 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
23067         LDKNodeAnnouncementInfo this_ptr_conv;
23068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23069         this_ptr_conv.is_owned = false;
23070         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23071         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
23072         return ret_arr;
23073 }
23074
23075 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
23076         LDKNodeAnnouncementInfo this_ptr_conv;
23077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23078         this_ptr_conv.is_owned = false;
23079         LDKThirtyTwoBytes val_ref;
23080         CHECK(*((uint32_t*)val) == 32);
23081         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23082         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
23083 }
23084
23085 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
23086         LDKNodeAnnouncementInfo this_ptr_conv;
23087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23088         this_ptr_conv.is_owned = false;
23089         LDKCVec_NetAddressZ val_constr;
23090         val_constr.datalen = *((uint32_t*)val);
23091         if (val_constr.datalen > 0)
23092                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
23093         else
23094                 val_constr.data = NULL;
23095         uint32_t* val_vals = (uint32_t*)(val + 4);
23096         for (size_t m = 0; m < val_constr.datalen; m++) {
23097                 uint32_t val_conv_12 = val_vals[m];
23098                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
23099                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
23100                 val_constr.data[m] = val_conv_12_conv;
23101         }
23102         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
23103 }
23104
23105 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
23106         LDKNodeAnnouncementInfo this_ptr_conv;
23107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23108         this_ptr_conv.is_owned = false;
23109         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
23110         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23111         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23112         uint64_t ret_ref = (uint64_t)ret_var.inner;
23113         if (ret_var.is_owned) {
23114                 ret_ref |= 1;
23115         }
23116         return ret_ref;
23117 }
23118
23119 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
23120         LDKNodeAnnouncementInfo this_ptr_conv;
23121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23122         this_ptr_conv.is_owned = false;
23123         LDKNodeAnnouncement val_conv;
23124         val_conv.inner = (void*)(val & (~1));
23125         val_conv.is_owned = (val & 1) || (val == 0);
23126         val_conv = NodeAnnouncement_clone(&val_conv);
23127         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
23128 }
23129
23130 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) {
23131         LDKNodeFeatures features_arg_conv;
23132         features_arg_conv.inner = (void*)(features_arg & (~1));
23133         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
23134         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
23135         LDKThreeBytes rgb_arg_ref;
23136         CHECK(*((uint32_t*)rgb_arg) == 3);
23137         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
23138         LDKThirtyTwoBytes alias_arg_ref;
23139         CHECK(*((uint32_t*)alias_arg) == 32);
23140         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
23141         LDKCVec_NetAddressZ addresses_arg_constr;
23142         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
23143         if (addresses_arg_constr.datalen > 0)
23144                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
23145         else
23146                 addresses_arg_constr.data = NULL;
23147         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
23148         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
23149                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
23150                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
23151                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
23152         }
23153         LDKNodeAnnouncement announcement_message_arg_conv;
23154         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
23155         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
23156         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
23157         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
23158         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23159         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23160         uint64_t ret_ref = (uint64_t)ret_var.inner;
23161         if (ret_var.is_owned) {
23162                 ret_ref |= 1;
23163         }
23164         return ret_ref;
23165 }
23166
23167 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
23168         LDKNodeAnnouncementInfo orig_conv;
23169         orig_conv.inner = (void*)(orig & (~1));
23170         orig_conv.is_owned = false;
23171         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
23172         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23173         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23174         uint64_t ret_ref = (uint64_t)ret_var.inner;
23175         if (ret_var.is_owned) {
23176                 ret_ref |= 1;
23177         }
23178         return ret_ref;
23179 }
23180
23181 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
23182         LDKNodeAnnouncementInfo obj_conv;
23183         obj_conv.inner = (void*)(obj & (~1));
23184         obj_conv.is_owned = false;
23185         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
23186         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23187         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23188         CVec_u8Z_free(ret_var);
23189         return ret_arr;
23190 }
23191
23192 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
23193         LDKu8slice ser_ref;
23194         ser_ref.datalen = *((uint32_t*)ser);
23195         ser_ref.data = (int8_t*)(ser + 4);
23196         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
23197         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
23198         return (uint64_t)ret_conv;
23199 }
23200
23201 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
23202         LDKNodeInfo this_obj_conv;
23203         this_obj_conv.inner = (void*)(this_obj & (~1));
23204         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23205         NodeInfo_free(this_obj_conv);
23206 }
23207
23208 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
23209         LDKNodeInfo this_ptr_conv;
23210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23211         this_ptr_conv.is_owned = false;
23212         LDKCVec_u64Z val_constr;
23213         val_constr.datalen = *((uint32_t*)val);
23214         if (val_constr.datalen > 0)
23215                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
23216         else
23217                 val_constr.data = NULL;
23218         int64_t* val_vals = (int64_t*)(val + 4);
23219         for (size_t i = 0; i < val_constr.datalen; i++) {
23220                 int64_t val_conv_8 = val_vals[i];
23221                 val_constr.data[i] = val_conv_8;
23222         }
23223         NodeInfo_set_channels(&this_ptr_conv, val_constr);
23224 }
23225
23226 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
23227         LDKNodeInfo this_ptr_conv;
23228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23229         this_ptr_conv.is_owned = false;
23230         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
23231         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23232         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23233         uint64_t ret_ref = (uint64_t)ret_var.inner;
23234         if (ret_var.is_owned) {
23235                 ret_ref |= 1;
23236         }
23237         return ret_ref;
23238 }
23239
23240 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
23241         LDKNodeInfo this_ptr_conv;
23242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23243         this_ptr_conv.is_owned = false;
23244         LDKRoutingFees val_conv;
23245         val_conv.inner = (void*)(val & (~1));
23246         val_conv.is_owned = (val & 1) || (val == 0);
23247         val_conv = RoutingFees_clone(&val_conv);
23248         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
23249 }
23250
23251 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
23252         LDKNodeInfo this_ptr_conv;
23253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23254         this_ptr_conv.is_owned = false;
23255         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
23256         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23257         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23258         uint64_t ret_ref = (uint64_t)ret_var.inner;
23259         if (ret_var.is_owned) {
23260                 ret_ref |= 1;
23261         }
23262         return ret_ref;
23263 }
23264
23265 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
23266         LDKNodeInfo this_ptr_conv;
23267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23268         this_ptr_conv.is_owned = false;
23269         LDKNodeAnnouncementInfo val_conv;
23270         val_conv.inner = (void*)(val & (~1));
23271         val_conv.is_owned = (val & 1) || (val == 0);
23272         val_conv = NodeAnnouncementInfo_clone(&val_conv);
23273         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
23274 }
23275
23276 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
23277         LDKCVec_u64Z channels_arg_constr;
23278         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
23279         if (channels_arg_constr.datalen > 0)
23280                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
23281         else
23282                 channels_arg_constr.data = NULL;
23283         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
23284         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
23285                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
23286                 channels_arg_constr.data[i] = channels_arg_conv_8;
23287         }
23288         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
23289         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
23290         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
23291         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
23292         LDKNodeAnnouncementInfo announcement_info_arg_conv;
23293         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
23294         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
23295         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
23296         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
23297         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23298         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23299         uint64_t ret_ref = (uint64_t)ret_var.inner;
23300         if (ret_var.is_owned) {
23301                 ret_ref |= 1;
23302         }
23303         return ret_ref;
23304 }
23305
23306 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
23307         LDKNodeInfo orig_conv;
23308         orig_conv.inner = (void*)(orig & (~1));
23309         orig_conv.is_owned = false;
23310         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
23311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23313         uint64_t ret_ref = (uint64_t)ret_var.inner;
23314         if (ret_var.is_owned) {
23315                 ret_ref |= 1;
23316         }
23317         return ret_ref;
23318 }
23319
23320 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
23321         LDKNodeInfo obj_conv;
23322         obj_conv.inner = (void*)(obj & (~1));
23323         obj_conv.is_owned = false;
23324         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
23325         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23326         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23327         CVec_u8Z_free(ret_var);
23328         return ret_arr;
23329 }
23330
23331 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
23332         LDKu8slice ser_ref;
23333         ser_ref.datalen = *((uint32_t*)ser);
23334         ser_ref.data = (int8_t*)(ser + 4);
23335         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
23336         *ret_conv = NodeInfo_read(ser_ref);
23337         return (uint64_t)ret_conv;
23338 }
23339
23340 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
23341         LDKNetworkGraph obj_conv;
23342         obj_conv.inner = (void*)(obj & (~1));
23343         obj_conv.is_owned = false;
23344         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
23345         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23346         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23347         CVec_u8Z_free(ret_var);
23348         return ret_arr;
23349 }
23350
23351 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
23352         LDKu8slice ser_ref;
23353         ser_ref.datalen = *((uint32_t*)ser);
23354         ser_ref.data = (int8_t*)(ser + 4);
23355         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
23356         *ret_conv = NetworkGraph_read(ser_ref);
23357         return (uint64_t)ret_conv;
23358 }
23359
23360 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
23361         LDKThirtyTwoBytes genesis_hash_ref;
23362         CHECK(*((uint32_t*)genesis_hash) == 32);
23363         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
23364         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
23365         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23366         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23367         uint64_t ret_ref = (uint64_t)ret_var.inner;
23368         if (ret_var.is_owned) {
23369                 ret_ref |= 1;
23370         }
23371         return ret_ref;
23372 }
23373
23374 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
23375         LDKNetworkGraph this_arg_conv;
23376         this_arg_conv.inner = (void*)(this_arg & (~1));
23377         this_arg_conv.is_owned = false;
23378         LDKNodeAnnouncement msg_conv;
23379         msg_conv.inner = (void*)(msg & (~1));
23380         msg_conv.is_owned = false;
23381         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
23382         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
23383         return (uint64_t)ret_conv;
23384 }
23385
23386 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
23387         LDKNetworkGraph this_arg_conv;
23388         this_arg_conv.inner = (void*)(this_arg & (~1));
23389         this_arg_conv.is_owned = false;
23390         LDKUnsignedNodeAnnouncement msg_conv;
23391         msg_conv.inner = (void*)(msg & (~1));
23392         msg_conv.is_owned = false;
23393         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
23394         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
23395         return (uint64_t)ret_conv;
23396 }
23397
23398 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
23399         LDKNetworkGraph this_arg_conv;
23400         this_arg_conv.inner = (void*)(this_arg & (~1));
23401         this_arg_conv.is_owned = false;
23402         LDKChannelAnnouncement msg_conv;
23403         msg_conv.inner = (void*)(msg & (~1));
23404         msg_conv.is_owned = false;
23405         LDKAccess *chain_access_conv_ptr = NULL;
23406         if (chain_access != 0) {
23407                 LDKAccess chain_access_conv;
23408                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23409                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23410                 *chain_access_conv_ptr = chain_access_conv;
23411         }
23412         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
23413         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
23414         return (uint64_t)ret_conv;
23415 }
23416
23417 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
23418         LDKNetworkGraph this_arg_conv;
23419         this_arg_conv.inner = (void*)(this_arg & (~1));
23420         this_arg_conv.is_owned = false;
23421         LDKUnsignedChannelAnnouncement msg_conv;
23422         msg_conv.inner = (void*)(msg & (~1));
23423         msg_conv.is_owned = false;
23424         LDKAccess *chain_access_conv_ptr = NULL;
23425         if (chain_access != 0) {
23426                 LDKAccess chain_access_conv;
23427                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
23428                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
23429                 *chain_access_conv_ptr = chain_access_conv;
23430         }
23431         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
23432         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
23433         return (uint64_t)ret_conv;
23434 }
23435
23436 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
23437         LDKNetworkGraph this_arg_conv;
23438         this_arg_conv.inner = (void*)(this_arg & (~1));
23439         this_arg_conv.is_owned = false;
23440         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
23441 }
23442
23443 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
23444         LDKNetworkGraph this_arg_conv;
23445         this_arg_conv.inner = (void*)(this_arg & (~1));
23446         this_arg_conv.is_owned = false;
23447         LDKChannelUpdate msg_conv;
23448         msg_conv.inner = (void*)(msg & (~1));
23449         msg_conv.is_owned = false;
23450         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
23451         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
23452         return (uint64_t)ret_conv;
23453 }
23454
23455 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
23456         LDKNetworkGraph this_arg_conv;
23457         this_arg_conv.inner = (void*)(this_arg & (~1));
23458         this_arg_conv.is_owned = false;
23459         LDKUnsignedChannelUpdate msg_conv;
23460         msg_conv.inner = (void*)(msg & (~1));
23461         msg_conv.is_owned = false;
23462         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
23463         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
23464         return (uint64_t)ret_conv;
23465 }
23466
23467 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
23468         LDKFilesystemPersister this_obj_conv;
23469         this_obj_conv.inner = (void*)(this_obj & (~1));
23470         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23471         FilesystemPersister_free(this_obj_conv);
23472 }
23473
23474 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
23475         LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
23476         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
23477         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23478         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23479         uint64_t ret_ref = (uint64_t)ret_var.inner;
23480         if (ret_var.is_owned) {
23481                 ret_ref |= 1;
23482         }
23483         return ret_ref;
23484 }
23485
23486 jstring  __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_dir(uint32_t this_arg) {
23487         LDKFilesystemPersister this_arg_conv;
23488         this_arg_conv.inner = (void*)(this_arg & (~1));
23489         this_arg_conv.is_owned = false;
23490         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
23491         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23492         Str_free(ret_str);
23493         return ret_conv;
23494 }
23495
23496 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_persist_manager(jstring data_dir, uint32_t manager) {
23497         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
23498         LDKChannelManager manager_conv;
23499         manager_conv.inner = (void*)(manager & (~1));
23500         manager_conv.is_owned = false;
23501         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
23502         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
23503         return (uint64_t)ret_conv;
23504 }
23505
23506 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_channelmonitors(uint32_t this_arg, uint32_t keys_manager) {
23507         LDKFilesystemPersister this_arg_conv;
23508         this_arg_conv.inner = (void*)(this_arg & (~1));
23509         this_arg_conv.is_owned = false;
23510         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
23511         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
23512         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
23513         return (uint64_t)ret_conv;
23514 }
23515
23516 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persist(uint32_t this_arg) {
23517         LDKFilesystemPersister this_arg_conv;
23518         this_arg_conv.inner = (void*)(this_arg & (~1));
23519         this_arg_conv.is_owned = false;
23520         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
23521         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
23522         return (uint64_t)ret;
23523 }
23524
23525 void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) {
23526         LDKBackgroundProcessor this_obj_conv;
23527         this_obj_conv.inner = (void*)(this_obj & (~1));
23528         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23529         BackgroundProcessor_free(this_obj_conv);
23530 }
23531
23532 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
23533         if ((this_ptr & 1) != 0) return;
23534         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
23535         FREE((void*)this_ptr);
23536         ChannelManagerPersister_free(this_ptr_conv);
23537 }
23538
23539 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_start(uint32_t persister, uint32_t event_handler, uint32_t chain_monitor, uint32_t channel_manager, uint32_t peer_manager, uint32_t logger) {
23540         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
23541         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
23542         LDKChainMonitor chain_monitor_conv;
23543         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
23544         chain_monitor_conv.is_owned = false;
23545         LDKChannelManager channel_manager_conv;
23546         channel_manager_conv.inner = (void*)(channel_manager & (~1));
23547         channel_manager_conv.is_owned = false;
23548         LDKPeerManager peer_manager_conv;
23549         peer_manager_conv.inner = (void*)(peer_manager & (~1));
23550         peer_manager_conv.is_owned = false;
23551         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23552         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
23553         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23554         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23555         uint64_t ret_ref = (uint64_t)ret_var.inner;
23556         if (ret_var.is_owned) {
23557                 ret_ref |= 1;
23558         }
23559         return ret_ref;
23560 }
23561
23562 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_join(uint32_t this_arg) {
23563         LDKBackgroundProcessor this_arg_conv;
23564         this_arg_conv.inner = (void*)(this_arg & (~1));
23565         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
23566         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
23567         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
23568         *ret_conv = BackgroundProcessor_join(this_arg_conv);
23569         return (uint64_t)ret_conv;
23570 }
23571
23572 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_stop(uint32_t this_arg) {
23573         LDKBackgroundProcessor this_arg_conv;
23574         this_arg_conv.inner = (void*)(this_arg & (~1));
23575         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
23576         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
23577         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
23578         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
23579         return (uint64_t)ret_conv;
23580 }
23581
23582 void  __attribute__((visibility("default"))) TS_check_platform() {
23583         check_platform();
23584 }
23585
23586 void  __attribute__((visibility("default"))) TS_Invoice_free(uint32_t this_obj) {
23587         LDKInvoice this_obj_conv;
23588         this_obj_conv.inner = (void*)(this_obj & (~1));
23589         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23590         Invoice_free(this_obj_conv);
23591 }
23592
23593 jboolean  __attribute__((visibility("default"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
23594         LDKInvoice a_conv;
23595         a_conv.inner = (void*)(a & (~1));
23596         a_conv.is_owned = false;
23597         LDKInvoice b_conv;
23598         b_conv.inner = (void*)(b & (~1));
23599         b_conv.is_owned = false;
23600         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
23601         return ret_val;
23602 }
23603
23604 uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig) {
23605         LDKInvoice orig_conv;
23606         orig_conv.inner = (void*)(orig & (~1));
23607         orig_conv.is_owned = false;
23608         LDKInvoice ret_var = Invoice_clone(&orig_conv);
23609         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23610         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23611         uint64_t ret_ref = (uint64_t)ret_var.inner;
23612         if (ret_var.is_owned) {
23613                 ret_ref |= 1;
23614         }
23615         return ret_ref;
23616 }
23617
23618 void  __attribute__((visibility("default"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
23619         LDKSignedRawInvoice this_obj_conv;
23620         this_obj_conv.inner = (void*)(this_obj & (~1));
23621         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23622         SignedRawInvoice_free(this_obj_conv);
23623 }
23624
23625 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
23626         LDKSignedRawInvoice a_conv;
23627         a_conv.inner = (void*)(a & (~1));
23628         a_conv.is_owned = false;
23629         LDKSignedRawInvoice b_conv;
23630         b_conv.inner = (void*)(b & (~1));
23631         b_conv.is_owned = false;
23632         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
23633         return ret_val;
23634 }
23635
23636 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint32_t orig) {
23637         LDKSignedRawInvoice orig_conv;
23638         orig_conv.inner = (void*)(orig & (~1));
23639         orig_conv.is_owned = false;
23640         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
23641         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23642         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23643         uint64_t ret_ref = (uint64_t)ret_var.inner;
23644         if (ret_var.is_owned) {
23645                 ret_ref |= 1;
23646         }
23647         return ret_ref;
23648 }
23649
23650 void  __attribute__((visibility("default"))) TS_RawInvoice_free(uint32_t this_obj) {
23651         LDKRawInvoice this_obj_conv;
23652         this_obj_conv.inner = (void*)(this_obj & (~1));
23653         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23654         RawInvoice_free(this_obj_conv);
23655 }
23656
23657 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
23658         LDKRawInvoice this_ptr_conv;
23659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23660         this_ptr_conv.is_owned = false;
23661         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
23662         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23663         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23664         uint64_t ret_ref = (uint64_t)ret_var.inner;
23665         if (ret_var.is_owned) {
23666                 ret_ref |= 1;
23667         }
23668         return ret_ref;
23669 }
23670
23671 void  __attribute__((visibility("default"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
23672         LDKRawInvoice this_ptr_conv;
23673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23674         this_ptr_conv.is_owned = false;
23675         LDKRawDataPart val_conv;
23676         val_conv.inner = (void*)(val & (~1));
23677         val_conv.is_owned = (val & 1) || (val == 0);
23678         val_conv = RawDataPart_clone(&val_conv);
23679         RawInvoice_set_data(&this_ptr_conv, val_conv);
23680 }
23681
23682 jboolean  __attribute__((visibility("default"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
23683         LDKRawInvoice a_conv;
23684         a_conv.inner = (void*)(a & (~1));
23685         a_conv.is_owned = false;
23686         LDKRawInvoice b_conv;
23687         b_conv.inner = (void*)(b & (~1));
23688         b_conv.is_owned = false;
23689         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
23690         return ret_val;
23691 }
23692
23693 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t orig) {
23694         LDKRawInvoice orig_conv;
23695         orig_conv.inner = (void*)(orig & (~1));
23696         orig_conv.is_owned = false;
23697         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
23698         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23699         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23700         uint64_t ret_ref = (uint64_t)ret_var.inner;
23701         if (ret_var.is_owned) {
23702                 ret_ref |= 1;
23703         }
23704         return ret_ref;
23705 }
23706
23707 void  __attribute__((visibility("default"))) TS_RawDataPart_free(uint32_t this_obj) {
23708         LDKRawDataPart this_obj_conv;
23709         this_obj_conv.inner = (void*)(this_obj & (~1));
23710         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23711         RawDataPart_free(this_obj_conv);
23712 }
23713
23714 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
23715         LDKRawDataPart this_ptr_conv;
23716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23717         this_ptr_conv.is_owned = false;
23718         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
23719         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23720         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23721         uint64_t ret_ref = (uint64_t)ret_var.inner;
23722         if (ret_var.is_owned) {
23723                 ret_ref |= 1;
23724         }
23725         return ret_ref;
23726 }
23727
23728 void  __attribute__((visibility("default"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
23729         LDKRawDataPart this_ptr_conv;
23730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23731         this_ptr_conv.is_owned = false;
23732         LDKPositiveTimestamp val_conv;
23733         val_conv.inner = (void*)(val & (~1));
23734         val_conv.is_owned = (val & 1) || (val == 0);
23735         val_conv = PositiveTimestamp_clone(&val_conv);
23736         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
23737 }
23738
23739 jboolean  __attribute__((visibility("default"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
23740         LDKRawDataPart a_conv;
23741         a_conv.inner = (void*)(a & (~1));
23742         a_conv.is_owned = false;
23743         LDKRawDataPart b_conv;
23744         b_conv.inner = (void*)(b & (~1));
23745         b_conv.is_owned = false;
23746         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
23747         return ret_val;
23748 }
23749
23750 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t orig) {
23751         LDKRawDataPart orig_conv;
23752         orig_conv.inner = (void*)(orig & (~1));
23753         orig_conv.is_owned = false;
23754         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
23755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23757         uint64_t ret_ref = (uint64_t)ret_var.inner;
23758         if (ret_var.is_owned) {
23759                 ret_ref |= 1;
23760         }
23761         return ret_ref;
23762 }
23763
23764 void  __attribute__((visibility("default"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
23765         LDKPositiveTimestamp this_obj_conv;
23766         this_obj_conv.inner = (void*)(this_obj & (~1));
23767         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23768         PositiveTimestamp_free(this_obj_conv);
23769 }
23770
23771 jboolean  __attribute__((visibility("default"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
23772         LDKPositiveTimestamp a_conv;
23773         a_conv.inner = (void*)(a & (~1));
23774         a_conv.is_owned = false;
23775         LDKPositiveTimestamp b_conv;
23776         b_conv.inner = (void*)(b & (~1));
23777         b_conv.is_owned = false;
23778         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
23779         return ret_val;
23780 }
23781
23782 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint32_t orig) {
23783         LDKPositiveTimestamp orig_conv;
23784         orig_conv.inner = (void*)(orig & (~1));
23785         orig_conv.is_owned = false;
23786         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
23787         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23788         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23789         uint64_t ret_ref = (uint64_t)ret_var.inner;
23790         if (ret_var.is_owned) {
23791                 ret_ref |= 1;
23792         }
23793         return ret_ref;
23794 }
23795
23796 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_clone(uint32_t orig) {
23797         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
23798         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
23799         return ret_conv;
23800 }
23801
23802 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_milli() {
23803         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
23804         return ret_conv;
23805 }
23806
23807 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_micro() {
23808         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
23809         return ret_conv;
23810 }
23811
23812 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_nano() {
23813         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
23814         return ret_conv;
23815 }
23816
23817 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_pico() {
23818         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
23819         return ret_conv;
23820 }
23821
23822 jboolean  __attribute__((visibility("default"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
23823         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
23824         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
23825         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
23826         return ret_val;
23827 }
23828
23829 int64_t  __attribute__((visibility("default"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
23830         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
23831         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
23832         return ret_val;
23833 }
23834
23835 uint32_t  __attribute__((visibility("default"))) TS_Currency_clone(uint32_t orig) {
23836         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
23837         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
23838         return ret_conv;
23839 }
23840
23841 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin() {
23842         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
23843         return ret_conv;
23844 }
23845
23846 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin_testnet() {
23847         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
23848         return ret_conv;
23849 }
23850
23851 uint32_t  __attribute__((visibility("default"))) TS_Currency_regtest() {
23852         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
23853         return ret_conv;
23854 }
23855
23856 uint32_t  __attribute__((visibility("default"))) TS_Currency_simnet() {
23857         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
23858         return ret_conv;
23859 }
23860
23861 uint32_t  __attribute__((visibility("default"))) TS_Currency_signet() {
23862         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
23863         return ret_conv;
23864 }
23865
23866 jboolean  __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) {
23867         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
23868         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
23869         jboolean ret_val = Currency_eq(a_conv, b_conv);
23870         return ret_val;
23871 }
23872
23873 void  __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) {
23874         LDKSha256 this_obj_conv;
23875         this_obj_conv.inner = (void*)(this_obj & (~1));
23876         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23877         Sha256_free(this_obj_conv);
23878 }
23879
23880 jboolean  __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
23881         LDKSha256 a_conv;
23882         a_conv.inner = (void*)(a & (~1));
23883         a_conv.is_owned = false;
23884         LDKSha256 b_conv;
23885         b_conv.inner = (void*)(b & (~1));
23886         b_conv.is_owned = false;
23887         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
23888         return ret_val;
23889 }
23890
23891 uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) {
23892         LDKSha256 orig_conv;
23893         orig_conv.inner = (void*)(orig & (~1));
23894         orig_conv.is_owned = false;
23895         LDKSha256 ret_var = Sha256_clone(&orig_conv);
23896         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23897         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23898         uint64_t ret_ref = (uint64_t)ret_var.inner;
23899         if (ret_var.is_owned) {
23900                 ret_ref |= 1;
23901         }
23902         return ret_ref;
23903 }
23904
23905 void  __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) {
23906         LDKDescription this_obj_conv;
23907         this_obj_conv.inner = (void*)(this_obj & (~1));
23908         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23909         Description_free(this_obj_conv);
23910 }
23911
23912 jboolean  __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) {
23913         LDKDescription a_conv;
23914         a_conv.inner = (void*)(a & (~1));
23915         a_conv.is_owned = false;
23916         LDKDescription b_conv;
23917         b_conv.inner = (void*)(b & (~1));
23918         b_conv.is_owned = false;
23919         jboolean ret_val = Description_eq(&a_conv, &b_conv);
23920         return ret_val;
23921 }
23922
23923 uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) {
23924         LDKDescription orig_conv;
23925         orig_conv.inner = (void*)(orig & (~1));
23926         orig_conv.is_owned = false;
23927         LDKDescription ret_var = Description_clone(&orig_conv);
23928         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23929         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23930         uint64_t ret_ref = (uint64_t)ret_var.inner;
23931         if (ret_var.is_owned) {
23932                 ret_ref |= 1;
23933         }
23934         return ret_ref;
23935 }
23936
23937 void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) {
23938         LDKPayeePubKey this_obj_conv;
23939         this_obj_conv.inner = (void*)(this_obj & (~1));
23940         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23941         PayeePubKey_free(this_obj_conv);
23942 }
23943
23944 jboolean  __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
23945         LDKPayeePubKey a_conv;
23946         a_conv.inner = (void*)(a & (~1));
23947         a_conv.is_owned = false;
23948         LDKPayeePubKey b_conv;
23949         b_conv.inner = (void*)(b & (~1));
23950         b_conv.is_owned = false;
23951         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
23952         return ret_val;
23953 }
23954
23955 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) {
23956         LDKPayeePubKey orig_conv;
23957         orig_conv.inner = (void*)(orig & (~1));
23958         orig_conv.is_owned = false;
23959         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
23960         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23961         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23962         uint64_t ret_ref = (uint64_t)ret_var.inner;
23963         if (ret_var.is_owned) {
23964                 ret_ref |= 1;
23965         }
23966         return ret_ref;
23967 }
23968
23969 void  __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) {
23970         LDKExpiryTime this_obj_conv;
23971         this_obj_conv.inner = (void*)(this_obj & (~1));
23972         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23973         ExpiryTime_free(this_obj_conv);
23974 }
23975
23976 jboolean  __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
23977         LDKExpiryTime a_conv;
23978         a_conv.inner = (void*)(a & (~1));
23979         a_conv.is_owned = false;
23980         LDKExpiryTime b_conv;
23981         b_conv.inner = (void*)(b & (~1));
23982         b_conv.is_owned = false;
23983         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
23984         return ret_val;
23985 }
23986
23987 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) {
23988         LDKExpiryTime orig_conv;
23989         orig_conv.inner = (void*)(orig & (~1));
23990         orig_conv.is_owned = false;
23991         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
23992         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23993         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23994         uint64_t ret_ref = (uint64_t)ret_var.inner;
23995         if (ret_var.is_owned) {
23996                 ret_ref |= 1;
23997         }
23998         return ret_ref;
23999 }
24000
24001 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
24002         LDKMinFinalCltvExpiry this_obj_conv;
24003         this_obj_conv.inner = (void*)(this_obj & (~1));
24004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24005         MinFinalCltvExpiry_free(this_obj_conv);
24006 }
24007
24008 jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
24009         LDKMinFinalCltvExpiry a_conv;
24010         a_conv.inner = (void*)(a & (~1));
24011         a_conv.is_owned = false;
24012         LDKMinFinalCltvExpiry b_conv;
24013         b_conv.inner = (void*)(b & (~1));
24014         b_conv.is_owned = false;
24015         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
24016         return ret_val;
24017 }
24018
24019 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
24020         LDKMinFinalCltvExpiry orig_conv;
24021         orig_conv.inner = (void*)(orig & (~1));
24022         orig_conv.is_owned = false;
24023         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
24024         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24025         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24026         uint64_t ret_ref = (uint64_t)ret_var.inner;
24027         if (ret_var.is_owned) {
24028                 ret_ref |= 1;
24029         }
24030         return ret_ref;
24031 }
24032
24033 void  __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) {
24034         if ((this_ptr & 1) != 0) return;
24035         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
24036         FREE((void*)this_ptr);
24037         Fallback_free(this_ptr_conv);
24038 }
24039
24040 uint32_t  __attribute__((visibility("default"))) TS_Fallback_clone(uint32_t orig) {
24041         LDKFallback* orig_conv = (LDKFallback*)orig;
24042         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
24043         *ret_copy = Fallback_clone(orig_conv);
24044         uint64_t ret_ref = (uint64_t)ret_copy;
24045         return ret_ref;
24046 }
24047
24048 uint32_t  __attribute__((visibility("default"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
24049         
24050         LDKCVec_u8Z program_ref;
24051         program_ref.datalen = *((uint32_t*)program);
24052         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
24053         memcpy(program_ref.data, (uint8_t*)(program + 4), program_ref.datalen);
24054         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
24055         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
24056         uint64_t ret_ref = (uint64_t)ret_copy;
24057         return ret_ref;
24058 }
24059
24060 uint32_t  __attribute__((visibility("default"))) TS_Fallback_pub_key_hash(int8_tArray a) {
24061         LDKTwentyBytes a_ref;
24062         CHECK(*((uint32_t*)a) == 20);
24063         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
24064         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
24065         *ret_copy = Fallback_pub_key_hash(a_ref);
24066         uint64_t ret_ref = (uint64_t)ret_copy;
24067         return ret_ref;
24068 }
24069
24070 uint32_t  __attribute__((visibility("default"))) TS_Fallback_script_hash(int8_tArray a) {
24071         LDKTwentyBytes a_ref;
24072         CHECK(*((uint32_t*)a) == 20);
24073         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
24074         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
24075         *ret_copy = Fallback_script_hash(a_ref);
24076         uint64_t ret_ref = (uint64_t)ret_copy;
24077         return ret_ref;
24078 }
24079
24080 jboolean  __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
24081         LDKFallback* a_conv = (LDKFallback*)a;
24082         LDKFallback* b_conv = (LDKFallback*)b;
24083         jboolean ret_val = Fallback_eq(a_conv, b_conv);
24084         return ret_val;
24085 }
24086
24087 void  __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t this_obj) {
24088         LDKInvoiceSignature this_obj_conv;
24089         this_obj_conv.inner = (void*)(this_obj & (~1));
24090         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24091         InvoiceSignature_free(this_obj_conv);
24092 }
24093
24094 jboolean  __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
24095         LDKInvoiceSignature a_conv;
24096         a_conv.inner = (void*)(a & (~1));
24097         a_conv.is_owned = false;
24098         LDKInvoiceSignature b_conv;
24099         b_conv.inner = (void*)(b & (~1));
24100         b_conv.is_owned = false;
24101         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
24102         return ret_val;
24103 }
24104
24105 uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) {
24106         LDKInvoiceSignature orig_conv;
24107         orig_conv.inner = (void*)(orig & (~1));
24108         orig_conv.is_owned = false;
24109         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
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         uint64_t 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 void  __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) {
24120         LDKPrivateRoute this_obj_conv;
24121         this_obj_conv.inner = (void*)(this_obj & (~1));
24122         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24123         PrivateRoute_free(this_obj_conv);
24124 }
24125
24126 jboolean  __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
24127         LDKPrivateRoute a_conv;
24128         a_conv.inner = (void*)(a & (~1));
24129         a_conv.is_owned = false;
24130         LDKPrivateRoute b_conv;
24131         b_conv.inner = (void*)(b & (~1));
24132         b_conv.is_owned = false;
24133         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
24134         return ret_val;
24135 }
24136
24137 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) {
24138         LDKPrivateRoute orig_conv;
24139         orig_conv.inner = (void*)(orig & (~1));
24140         orig_conv.is_owned = false;
24141         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
24142         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24143         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24144         uint64_t ret_ref = (uint64_t)ret_var.inner;
24145         if (ret_var.is_owned) {
24146                 ret_ref |= 1;
24147         }
24148         return ret_ref;
24149 }
24150
24151 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
24152         LDKSignedRawInvoice this_arg_conv;
24153         this_arg_conv.inner = (void*)(this_arg & (~1));
24154         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
24155         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
24156         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24157         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
24158         return (uint64_t)ret_ref;
24159 }
24160
24161 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
24162         LDKSignedRawInvoice this_arg_conv;
24163         this_arg_conv.inner = (void*)(this_arg & (~1));
24164         this_arg_conv.is_owned = false;
24165         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
24166         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24167         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24168         uint64_t ret_ref = (uint64_t)ret_var.inner;
24169         if (ret_var.is_owned) {
24170                 ret_ref |= 1;
24171         }
24172         return ret_ref;
24173 }
24174
24175 int8_tArray  __attribute__((visibility("default"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
24176         LDKSignedRawInvoice this_arg_conv;
24177         this_arg_conv.inner = (void*)(this_arg & (~1));
24178         this_arg_conv.is_owned = false;
24179         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24180         memcpy((uint8_t*)(ret_arr + 4), *SignedRawInvoice_hash(&this_arg_conv), 32);
24181         return ret_arr;
24182 }
24183
24184 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
24185         LDKSignedRawInvoice this_arg_conv;
24186         this_arg_conv.inner = (void*)(this_arg & (~1));
24187         this_arg_conv.is_owned = false;
24188         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
24189         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24190         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24191         uint64_t ret_ref = (uint64_t)ret_var.inner;
24192         if (ret_var.is_owned) {
24193                 ret_ref |= 1;
24194         }
24195         return ret_ref;
24196 }
24197
24198 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
24199         LDKSignedRawInvoice this_arg_conv;
24200         this_arg_conv.inner = (void*)(this_arg & (~1));
24201         this_arg_conv.is_owned = false;
24202         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24203         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
24204         return (uint64_t)ret_conv;
24205 }
24206
24207 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
24208         LDKSignedRawInvoice this_arg_conv;
24209         this_arg_conv.inner = (void*)(this_arg & (~1));
24210         this_arg_conv.is_owned = false;
24211         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
24212         return ret_val;
24213 }
24214
24215 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_hash(uint32_t this_arg) {
24216         LDKRawInvoice this_arg_conv;
24217         this_arg_conv.inner = (void*)(this_arg & (~1));
24218         this_arg_conv.is_owned = false;
24219         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24220         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_hash(&this_arg_conv).data, 32);
24221         return ret_arr;
24222 }
24223
24224 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
24225         LDKRawInvoice this_arg_conv;
24226         this_arg_conv.inner = (void*)(this_arg & (~1));
24227         this_arg_conv.is_owned = false;
24228         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
24229         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24230         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24231         uint64_t ret_ref = (uint64_t)ret_var.inner;
24232         if (ret_var.is_owned) {
24233                 ret_ref |= 1;
24234         }
24235         return ret_ref;
24236 }
24237
24238 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint32_t this_arg) {
24239         LDKRawInvoice this_arg_conv;
24240         this_arg_conv.inner = (void*)(this_arg & (~1));
24241         this_arg_conv.is_owned = false;
24242         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
24243         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24244         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24245         uint64_t ret_ref = (uint64_t)ret_var.inner;
24246         if (ret_var.is_owned) {
24247                 ret_ref |= 1;
24248         }
24249         return ret_ref;
24250 }
24251
24252 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
24253         LDKRawInvoice this_arg_conv;
24254         this_arg_conv.inner = (void*)(this_arg & (~1));
24255         this_arg_conv.is_owned = false;
24256         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
24257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24259         uint64_t ret_ref = (uint64_t)ret_var.inner;
24260         if (ret_var.is_owned) {
24261                 ret_ref |= 1;
24262         }
24263         return ret_ref;
24264 }
24265
24266 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
24267         LDKRawInvoice this_arg_conv;
24268         this_arg_conv.inner = (void*)(this_arg & (~1));
24269         this_arg_conv.is_owned = false;
24270         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
24271         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24272         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24273         uint64_t ret_ref = (uint64_t)ret_var.inner;
24274         if (ret_var.is_owned) {
24275                 ret_ref |= 1;
24276         }
24277         return ret_ref;
24278 }
24279
24280 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
24281         LDKRawInvoice this_arg_conv;
24282         this_arg_conv.inner = (void*)(this_arg & (~1));
24283         this_arg_conv.is_owned = false;
24284         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
24285         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24286         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24287         uint64_t ret_ref = (uint64_t)ret_var.inner;
24288         if (ret_var.is_owned) {
24289                 ret_ref |= 1;
24290         }
24291         return ret_ref;
24292 }
24293
24294 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
24295         LDKRawInvoice this_arg_conv;
24296         this_arg_conv.inner = (void*)(this_arg & (~1));
24297         this_arg_conv.is_owned = false;
24298         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
24299         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24300         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24301         uint64_t ret_ref = (uint64_t)ret_var.inner;
24302         if (ret_var.is_owned) {
24303                 ret_ref |= 1;
24304         }
24305         return ret_ref;
24306 }
24307
24308 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
24309         LDKRawInvoice this_arg_conv;
24310         this_arg_conv.inner = (void*)(this_arg & (~1));
24311         this_arg_conv.is_owned = false;
24312         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24313         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_payment_secret(&this_arg_conv).data, 32);
24314         return ret_arr;
24315 }
24316
24317 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t this_arg) {
24318         LDKRawInvoice this_arg_conv;
24319         this_arg_conv.inner = (void*)(this_arg & (~1));
24320         this_arg_conv.is_owned = false;
24321         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
24322         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24323         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24324         uint64_t ret_ref = (uint64_t)ret_var.inner;
24325         if (ret_var.is_owned) {
24326                 ret_ref |= 1;
24327         }
24328         return ret_ref;
24329 }
24330
24331 uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
24332         LDKRawInvoice this_arg_conv;
24333         this_arg_conv.inner = (void*)(this_arg & (~1));
24334         this_arg_conv.is_owned = false;
24335         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
24336         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
24337         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
24338         for (size_t o = 0; o < ret_var.datalen; o++) {
24339                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
24340                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24341                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24342                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
24343                 if (ret_conv_14_var.is_owned) {
24344                         ret_conv_14_ref |= 1;
24345                 }
24346                 ret_arr_ptr[o] = ret_conv_14_ref;
24347         }
24348         FREE(ret_var.data);
24349         return ret_arr;
24350 }
24351
24352 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
24353         LDKRawInvoice this_arg_conv;
24354         this_arg_conv.inner = (void*)(this_arg & (~1));
24355         this_arg_conv.is_owned = false;
24356         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24357         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
24358         uint64_t ret_ref = (uint64_t)ret_copy;
24359         return ret_ref;
24360 }
24361
24362 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_currency(uint32_t this_arg) {
24363         LDKRawInvoice this_arg_conv;
24364         this_arg_conv.inner = (void*)(this_arg & (~1));
24365         this_arg_conv.is_owned = false;
24366         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
24367         return ret_conv;
24368 }
24369
24370 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
24371         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24372         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
24373         return (uint64_t)ret_conv;
24374 }
24375
24376 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_system_time(int64_t time) {
24377         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24378         *ret_conv = PositiveTimestamp_from_system_time(time);
24379         return (uint64_t)ret_conv;
24380 }
24381
24382 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
24383         LDKPositiveTimestamp this_arg_conv;
24384         this_arg_conv.inner = (void*)(this_arg & (~1));
24385         this_arg_conv.is_owned = false;
24386         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
24387         return ret_val;
24388 }
24389
24390 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_time(uint32_t this_arg) {
24391         LDKPositiveTimestamp this_arg_conv;
24392         this_arg_conv.inner = (void*)(this_arg & (~1));
24393         this_arg_conv.is_owned = false;
24394         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
24395         return ret_val;
24396 }
24397
24398 uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
24399         LDKInvoice this_arg_conv;
24400         this_arg_conv.inner = (void*)(this_arg & (~1));
24401         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
24402         this_arg_conv = Invoice_clone(&this_arg_conv);
24403         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
24404         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24405         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24406         uint64_t ret_ref = (uint64_t)ret_var.inner;
24407         if (ret_var.is_owned) {
24408                 ret_ref |= 1;
24409         }
24410         return ret_ref;
24411 }
24412
24413 uint32_t  __attribute__((visibility("default"))) TS_Invoice_check_signature(uint32_t this_arg) {
24414         LDKInvoice this_arg_conv;
24415         this_arg_conv.inner = (void*)(this_arg & (~1));
24416         this_arg_conv.is_owned = false;
24417         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24418         *ret_conv = Invoice_check_signature(&this_arg_conv);
24419         return (uint64_t)ret_conv;
24420 }
24421
24422 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
24423         LDKSignedRawInvoice signed_invoice_conv;
24424         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
24425         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
24426         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
24427         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24428         *ret_conv = Invoice_from_signed(signed_invoice_conv);
24429         return (uint64_t)ret_conv;
24430 }
24431
24432 int64_t  __attribute__((visibility("default"))) TS_Invoice_timestamp(uint32_t this_arg) {
24433         LDKInvoice this_arg_conv;
24434         this_arg_conv.inner = (void*)(this_arg & (~1));
24435         this_arg_conv.is_owned = false;
24436         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
24437         return ret_val;
24438 }
24439
24440 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_hash(uint32_t this_arg) {
24441         LDKInvoice this_arg_conv;
24442         this_arg_conv.inner = (void*)(this_arg & (~1));
24443         this_arg_conv.is_owned = false;
24444         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24445         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_hash(&this_arg_conv), 32);
24446         return ret_arr;
24447 }
24448
24449 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
24450         LDKInvoice this_arg_conv;
24451         this_arg_conv.inner = (void*)(this_arg & (~1));
24452         this_arg_conv.is_owned = false;
24453         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24454         memcpy((uint8_t*)(ret_arr + 4), Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
24455         return ret_arr;
24456 }
24457
24458 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(uint32_t this_arg) {
24459         LDKInvoice this_arg_conv;
24460         this_arg_conv.inner = (void*)(this_arg & (~1));
24461         this_arg_conv.is_owned = false;
24462         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24463         memcpy((uint8_t*)(ret_arr + 4), Invoice_payment_secret(&this_arg_conv).data, 32);
24464         return ret_arr;
24465 }
24466
24467 uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t this_arg) {
24468         LDKInvoice this_arg_conv;
24469         this_arg_conv.inner = (void*)(this_arg & (~1));
24470         this_arg_conv.is_owned = false;
24471         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
24472         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24473         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24474         uint64_t ret_ref = (uint64_t)ret_var.inner;
24475         if (ret_var.is_owned) {
24476                 ret_ref |= 1;
24477         }
24478         return ret_ref;
24479 }
24480
24481 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
24482         LDKInvoice this_arg_conv;
24483         this_arg_conv.inner = (void*)(this_arg & (~1));
24484         this_arg_conv.is_owned = false;
24485         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24486         memcpy((uint8_t*)(ret_arr + 4), Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
24487         return ret_arr;
24488 }
24489
24490 int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t this_arg) {
24491         LDKInvoice this_arg_conv;
24492         this_arg_conv.inner = (void*)(this_arg & (~1));
24493         this_arg_conv.is_owned = false;
24494         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
24495         return ret_val;
24496 }
24497
24498 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
24499         LDKInvoice this_arg_conv;
24500         this_arg_conv.inner = (void*)(this_arg & (~1));
24501         this_arg_conv.is_owned = false;
24502         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
24503         return ret_val;
24504 }
24505
24506 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(uint32_t this_arg) {
24507         LDKInvoice this_arg_conv;
24508         this_arg_conv.inner = (void*)(this_arg & (~1));
24509         this_arg_conv.is_owned = false;
24510         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
24511         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
24512         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
24513         for (size_t o = 0; o < ret_var.datalen; o++) {
24514                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
24515                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24516                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24517                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
24518                 if (ret_conv_14_var.is_owned) {
24519                         ret_conv_14_ref |= 1;
24520                 }
24521                 ret_arr_ptr[o] = ret_conv_14_ref;
24522         }
24523         FREE(ret_var.data);
24524         return ret_arr;
24525 }
24526
24527 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uint32_t this_arg) {
24528         LDKInvoice this_arg_conv;
24529         this_arg_conv.inner = (void*)(this_arg & (~1));
24530         this_arg_conv.is_owned = false;
24531         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
24532         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
24533         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
24534         for (size_t l = 0; l < ret_var.datalen; l++) {
24535                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
24536                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24537                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24538                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
24539                 if (ret_conv_11_var.is_owned) {
24540                         ret_conv_11_ref |= 1;
24541                 }
24542                 ret_arr_ptr[l] = ret_conv_11_ref;
24543         }
24544         FREE(ret_var.data);
24545         return ret_arr;
24546 }
24547
24548 uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t this_arg) {
24549         LDKInvoice this_arg_conv;
24550         this_arg_conv.inner = (void*)(this_arg & (~1));
24551         this_arg_conv.is_owned = false;
24552         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
24553         return ret_conv;
24554 }
24555
24556 uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_pico_btc(uint32_t this_arg) {
24557         LDKInvoice this_arg_conv;
24558         this_arg_conv.inner = (void*)(this_arg & (~1));
24559         this_arg_conv.is_owned = false;
24560         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24561         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
24562         uint64_t ret_ref = (uint64_t)ret_copy;
24563         return ret_ref;
24564 }
24565
24566 uint32_t  __attribute__((visibility("default"))) TS_Description_new(jstring description) {
24567         LDKStr description_conv = str_ref_to_owned_c(description);
24568         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24569         *ret_conv = Description_new(description_conv);
24570         return (uint64_t)ret_conv;
24571 }
24572
24573 jstring  __attribute__((visibility("default"))) TS_Description_into_inner(uint32_t this_arg) {
24574         LDKDescription this_arg_conv;
24575         this_arg_conv.inner = (void*)(this_arg & (~1));
24576         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
24577         this_arg_conv = Description_clone(&this_arg_conv);
24578         LDKStr ret_str = Description_into_inner(this_arg_conv);
24579         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
24580         Str_free(ret_str);
24581         return ret_conv;
24582 }
24583
24584 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
24585         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
24586         *ret_conv = ExpiryTime_from_seconds(seconds);
24587         return (uint64_t)ret_conv;
24588 }
24589
24590 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_duration(int64_t duration) {
24591         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
24592         *ret_conv = ExpiryTime_from_duration(duration);
24593         return (uint64_t)ret_conv;
24594 }
24595
24596 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
24597         LDKExpiryTime this_arg_conv;
24598         this_arg_conv.inner = (void*)(this_arg & (~1));
24599         this_arg_conv.is_owned = false;
24600         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
24601         return ret_val;
24602 }
24603
24604 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
24605         LDKExpiryTime this_arg_conv;
24606         this_arg_conv.inner = (void*)(this_arg & (~1));
24607         this_arg_conv.is_owned = false;
24608         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
24609         return ret_val;
24610 }
24611
24612 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_new(uint32_t hops) {
24613         LDKRouteHint hops_conv;
24614         hops_conv.inner = (void*)(hops & (~1));
24615         hops_conv.is_owned = (hops & 1) || (hops == 0);
24616         hops_conv = RouteHint_clone(&hops_conv);
24617         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24618         *ret_conv = PrivateRoute_new(hops_conv);
24619         return (uint64_t)ret_conv;
24620 }
24621
24622 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
24623         LDKPrivateRoute this_arg_conv;
24624         this_arg_conv.inner = (void*)(this_arg & (~1));
24625         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
24626         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
24627         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
24628         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24629         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24630         uint64_t ret_ref = (uint64_t)ret_var.inner;
24631         if (ret_var.is_owned) {
24632                 ret_ref |= 1;
24633         }
24634         return ret_ref;
24635 }
24636
24637 uint32_t  __attribute__((visibility("default"))) TS_CreationError_clone(uint32_t orig) {
24638         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
24639         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
24640         return ret_conv;
24641 }
24642
24643 uint32_t  __attribute__((visibility("default"))) TS_CreationError_description_too_long() {
24644         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
24645         return ret_conv;
24646 }
24647
24648 uint32_t  __attribute__((visibility("default"))) TS_CreationError_route_too_long() {
24649         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
24650         return ret_conv;
24651 }
24652
24653 uint32_t  __attribute__((visibility("default"))) TS_CreationError_timestamp_out_of_bounds() {
24654         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
24655         return ret_conv;
24656 }
24657
24658 uint32_t  __attribute__((visibility("default"))) TS_CreationError_expiry_time_out_of_bounds() {
24659         uint32_t ret_conv = LDKCreationError_to_js(CreationError_expiry_time_out_of_bounds());
24660         return ret_conv;
24661 }
24662
24663 jboolean  __attribute__((visibility("default"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
24664         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
24665         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
24666         jboolean ret_val = CreationError_eq(a_conv, b_conv);
24667         return ret_val;
24668 }
24669
24670 jstring  __attribute__((visibility("default"))) TS_CreationError_to_str(uint32_t o) {
24671         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
24672         LDKStr ret_str = CreationError_to_str(o_conv);
24673         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
24674         Str_free(ret_str);
24675         return ret_conv;
24676 }
24677
24678 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_clone(uint32_t orig) {
24679         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
24680         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
24681         return ret_conv;
24682 }
24683
24684 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_hash() {
24685         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
24686         return ret_conv;
24687 }
24688
24689 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_hashes() {
24690         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
24691         return ret_conv;
24692 }
24693
24694 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_description() {
24695         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
24696         return ret_conv;
24697 }
24698
24699 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_descriptions() {
24700         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
24701         return ret_conv;
24702 }
24703
24704 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_secrets() {
24705         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
24706         return ret_conv;
24707 }
24708
24709 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_features() {
24710         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
24711         return ret_conv;
24712 }
24713
24714 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_recovery_id() {
24715         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
24716         return ret_conv;
24717 }
24718
24719 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_signature() {
24720         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
24721         return ret_conv;
24722 }
24723
24724 jboolean  __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
24725         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
24726         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
24727         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
24728         return ret_val;
24729 }
24730
24731 jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t o) {
24732         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
24733         LDKStr ret_str = SemanticError_to_str(o_conv);
24734         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
24735         Str_free(ret_str);
24736         return ret_conv;
24737 }
24738
24739 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
24740         if ((this_ptr & 1) != 0) return;
24741         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
24742         FREE((void*)this_ptr);
24743         SignOrCreationError_free(this_ptr_conv);
24744 }
24745
24746 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone(uint32_t orig) {
24747         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
24748         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
24749         *ret_copy = SignOrCreationError_clone(orig_conv);
24750         uint64_t ret_ref = (uint64_t)ret_copy;
24751         return ret_ref;
24752 }
24753
24754 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_sign_error() {
24755         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
24756         *ret_copy = SignOrCreationError_sign_error();
24757         uint64_t ret_ref = (uint64_t)ret_copy;
24758         return ret_ref;
24759 }
24760
24761 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_creation_error(uint32_t a) {
24762         LDKCreationError a_conv = LDKCreationError_from_js(a);
24763         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
24764         *ret_copy = SignOrCreationError_creation_error(a_conv);
24765         uint64_t ret_ref = (uint64_t)ret_copy;
24766         return ret_ref;
24767 }
24768
24769 jboolean  __attribute__((visibility("default"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
24770         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
24771         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
24772         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
24773         return ret_val;
24774 }
24775
24776 jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(uint32_t o) {
24777         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
24778         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
24779         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
24780         Str_free(ret_str);
24781         return ret_conv;
24782 }
24783
24784 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) {
24785         LDKChannelManager channelmanager_conv;
24786         channelmanager_conv.inner = (void*)(channelmanager & (~1));
24787         channelmanager_conv.is_owned = false;
24788         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
24789         LDKCurrency network_conv = LDKCurrency_from_js(network);
24790         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
24791         LDKStr description_conv = str_ref_to_owned_c(description);
24792         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24793         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
24794         return (uint64_t)ret_conv;
24795 }
24796
24797 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
24798         LDKStr s_conv = str_ref_to_owned_c(s);
24799         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
24800         *ret_conv = SiPrefix_from_str(s_conv);
24801         return (uint64_t)ret_conv;
24802 }
24803
24804 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_str(jstring s) {
24805         LDKStr s_conv = str_ref_to_owned_c(s);
24806         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
24807         *ret_conv = Invoice_from_str(s_conv);
24808         return (uint64_t)ret_conv;
24809 }
24810
24811 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_from_str(jstring s) {
24812         LDKStr s_conv = str_ref_to_owned_c(s);
24813         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
24814         *ret_conv = SignedRawInvoice_from_str(s_conv);
24815         return (uint64_t)ret_conv;
24816 }
24817
24818 jstring  __attribute__((visibility("default"))) TS_Invoice_to_str(uint32_t o) {
24819         LDKInvoice o_conv;
24820         o_conv.inner = (void*)(o & (~1));
24821         o_conv.is_owned = false;
24822         LDKStr ret_str = Invoice_to_str(&o_conv);
24823         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
24824         Str_free(ret_str);
24825         return ret_conv;
24826 }
24827
24828 jstring  __attribute__((visibility("default"))) TS_SignedRawInvoice_to_str(uint32_t o) {
24829         LDKSignedRawInvoice o_conv;
24830         o_conv.inner = (void*)(o & (~1));
24831         o_conv.is_owned = false;
24832         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
24833         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
24834         Str_free(ret_str);
24835         return ret_conv;
24836 }
24837
24838 jstring  __attribute__((visibility("default"))) TS_Currency_to_str(uint32_t o) {
24839         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
24840         LDKStr ret_str = Currency_to_str(o_conv);
24841         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
24842         Str_free(ret_str);
24843         return ret_conv;
24844 }
24845
24846 jstring  __attribute__((visibility("default"))) TS_SiPrefix_to_str(uint32_t o) {
24847         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
24848         LDKStr ret_str = SiPrefix_to_str(o_conv);
24849         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
24850         Str_free(ret_str);
24851         return ret_conv;
24852 }
24853