Update CI references to 0.0.122
[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 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_result_ok(uint32_t arg) {
330         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
331 }
332 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
333         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
334         CHECK(val->result_ok);
335         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
336         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
337         return res_arr;
338 }
339 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
340         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
341         CHECK(!val->result_ok);
342         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
343         return err_conv;
344 }
345 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_result_ok(uint32_t arg) {
346         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
347 }
348 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
349         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
350         CHECK(val->result_ok);
351         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
352         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
353         return res_arr;
354 }
355 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
356         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
357         CHECK(!val->result_ok);
358         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
359         return err_conv;
360 }
361 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_result_ok(uint32_t arg) {
362         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
363 }
364 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
365         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
366         CHECK(val->result_ok);
367         LDKTxCreationKeys res_var = (*val->contents.result);
368         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
369         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
370         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
371         return res_ref;
372 }
373 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
374         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
375         CHECK(!val->result_ok);
376         LDKDecodeError err_var = (*val->contents.err);
377         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
378         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
379         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
380         return err_ref;
381 }
382 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
383         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
384 }
385 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
386         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
387         CHECK(val->result_ok);
388         LDKChannelPublicKeys res_var = (*val->contents.result);
389         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
390         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
391         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
392         return res_ref;
393 }
394 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
395         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
396         CHECK(!val->result_ok);
397         LDKDecodeError err_var = (*val->contents.err);
398         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
399         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
400         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
401         return err_ref;
402 }
403 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
404         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
405 }
406 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
407         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
408         CHECK(val->result_ok);
409         LDKTxCreationKeys res_var = (*val->contents.result);
410         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
411         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
412         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
413         return res_ref;
414 }
415 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
416         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
417         CHECK(!val->result_ok);
418         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
419         return err_conv;
420 }
421 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u32Z_ref_from_ptr(uint32_t ptr) {
422         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
423         switch(obj->tag) {
424                 case LDKCOption_u32Z_Some: {
425                         return 0 /* LDKCOption_u32Z - Some */; (void) obj->some;
426                 }
427                 case LDKCOption_u32Z_None: {
428                         return 0 /* LDKCOption_u32Z - None */;
429                 }
430                 default: abort();
431         }
432 }
433 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_result_ok(uint32_t arg) {
434         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
435 }
436 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
437         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
438         CHECK(val->result_ok);
439         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
440         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
441         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
442         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
443         return res_ref;
444 }
445 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
446         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
447         CHECK(!val->result_ok);
448         LDKDecodeError err_var = (*val->contents.err);
449         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
450         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
451         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
452         return err_ref;
453 }
454 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
455         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
456 }
457 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
458         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
459         CHECK(val->result_ok);
460         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
461         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
462         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
463         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
464         return res_ref;
465 }
466 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
467         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
468         CHECK(!val->result_ok);
469         LDKDecodeError err_var = (*val->contents.err);
470         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
471         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
472         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
473         return err_ref;
474 }
475 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
476         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
477 }
478 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
479         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
480         CHECK(val->result_ok);
481         LDKChannelTransactionParameters res_var = (*val->contents.result);
482         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
483         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
484         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
485         return res_ref;
486 }
487 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
488         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
489         CHECK(!val->result_ok);
490         LDKDecodeError err_var = (*val->contents.err);
491         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
492         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
493         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
494         return err_ref;
495 }
496 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
497         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
498 }
499 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
500         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
501         CHECK(val->result_ok);
502         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
503         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
504         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
505         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
506         return res_ref;
507 }
508 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
509         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
510         CHECK(!val->result_ok);
511         LDKDecodeError err_var = (*val->contents.err);
512         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
513         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
514         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
515         return err_ref;
516 }
517 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
518         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
519 }
520 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
521         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
522         CHECK(val->result_ok);
523         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
524         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
525         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
526         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
527         return res_ref;
528 }
529 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
530         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
531         CHECK(!val->result_ok);
532         LDKDecodeError err_var = (*val->contents.err);
533         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
534         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
535         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
536         return err_ref;
537 }
538 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
539         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
540 }
541 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
542         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
543         CHECK(val->result_ok);
544         LDKCommitmentTransaction res_var = (*val->contents.result);
545         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
546         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
547         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
548         return res_ref;
549 }
550 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
551         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
552         CHECK(!val->result_ok);
553         LDKDecodeError err_var = (*val->contents.err);
554         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
555         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
556         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
557         return err_ref;
558 }
559 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
560         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
561 }
562 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
563         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
564         CHECK(val->result_ok);
565         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
566         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
567         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
568         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
569         return res_ref;
570 }
571 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
572         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
573         CHECK(!val->result_ok);
574         return *val->contents.err;
575 }
576 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
577         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
578 }
579 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
580         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
581         CHECK(val->result_ok);
582         LDKCVec_SignatureZ res_var = (*val->contents.result);
583         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
584         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
585         for (size_t m = 0; m < res_var.datalen; m++) {
586                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
587                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
588                 res_arr_ptr[m] = res_conv_12_arr;
589         }
590         return res_arr;
591 }
592 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
593         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
594         CHECK(!val->result_ok);
595         return *val->contents.err;
596 }
597 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_result_ok(uint32_t arg) {
598         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
599 }
600 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_ok(uint32_t arg) {
601         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
602         CHECK(val->result_ok);
603         return *val->contents.result;
604 }
605 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_err(uint32_t arg) {
606         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
607         CHECK(!val->result_ok);
608         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
609         return err_conv;
610 }
611 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_result_ok(uint32_t arg) {
612         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
613 }
614 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_ok(uint32_t arg) {
615         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
616         CHECK(val->result_ok);
617         LDKRouteHop res_var = (*val->contents.result);
618         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
619         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
620         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
621         return res_ref;
622 }
623 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_err(uint32_t arg) {
624         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
625         CHECK(!val->result_ok);
626         LDKDecodeError err_var = (*val->contents.err);
627         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
628         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
629         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
630         return err_ref;
631 }
632 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
633         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
634         ret->datalen = *((uint32_t*)elems);
635         if (ret->datalen == 0) {
636                 ret->data = NULL;
637         } else {
638                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
639                 uint32_t *java_elems = (uint32_t*)(elems + 4);
640                 for (size_t i = 0; i < ret->datalen; i++) {
641                         uint32_t arr_elem = java_elems[i];
642                         LDKRouteHop arr_elem_conv;
643                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
644                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
645                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
646                         ret->data[i] = arr_elem_conv;
647                 }
648         }
649         return (uint64_t)ret;
650 }
651 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
652         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
653         for (size_t i = 0; i < ret.datalen; i++) {
654                 ret.data[i] = RouteHop_clone(&orig->data[i]);
655         }
656         return ret;
657 }
658 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
659         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
660         for (size_t i = 0; i < ret.datalen; i++) {
661                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
662         }
663         return ret;
664 }
665 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
666         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
667 }
668 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
669         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
670         CHECK(val->result_ok);
671         LDKRoute res_var = (*val->contents.result);
672         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
673         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
674         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
675         return res_ref;
676 }
677 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
678         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
679         CHECK(!val->result_ok);
680         LDKDecodeError err_var = (*val->contents.err);
681         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
682         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
683         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
684         return err_ref;
685 }
686 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
687         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
688         switch(obj->tag) {
689                 case LDKCOption_u64Z_Some: {
690                         return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
691                 }
692                 case LDKCOption_u64Z_None: {
693                         return 0 /* LDKCOption_u64Z - None */;
694                 }
695                 default: abort();
696         }
697 }
698 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
699         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
700         ret->datalen = *((uint32_t*)elems);
701         if (ret->datalen == 0) {
702                 ret->data = NULL;
703         } else {
704                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
705                 uint32_t *java_elems = (uint32_t*)(elems + 4);
706                 for (size_t i = 0; i < ret->datalen; i++) {
707                         uint32_t arr_elem = java_elems[i];
708                         LDKChannelDetails arr_elem_conv;
709                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
710                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
711                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
712                         ret->data[i] = arr_elem_conv;
713                 }
714         }
715         return (uint64_t)ret;
716 }
717 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
718         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
719         for (size_t i = 0; i < ret.datalen; i++) {
720                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
721         }
722         return ret;
723 }
724 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
725         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
726         ret->datalen = *((uint32_t*)elems);
727         if (ret->datalen == 0) {
728                 ret->data = NULL;
729         } else {
730                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
731                 uint32_t *java_elems = (uint32_t*)(elems + 4);
732                 for (size_t i = 0; i < ret->datalen; i++) {
733                         uint32_t arr_elem = java_elems[i];
734                         LDKRouteHint arr_elem_conv;
735                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
736                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
737                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
738                         ret->data[i] = arr_elem_conv;
739                 }
740         }
741         return (uint64_t)ret;
742 }
743 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
744         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
745         for (size_t i = 0; i < ret.datalen; i++) {
746                 ret.data[i] = RouteHint_clone(&orig->data[i]);
747         }
748         return ret;
749 }
750 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
751         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
752 }
753 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
754         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
755         CHECK(val->result_ok);
756         LDKRoute res_var = (*val->contents.result);
757         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
758         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
759         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
760         return res_ref;
761 }
762 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
763         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
764         CHECK(!val->result_ok);
765         LDKLightningError err_var = (*val->contents.err);
766         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
767         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
768         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
769         return err_ref;
770 }
771 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
772         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
773 }
774 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
775         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
776         CHECK(val->result_ok);
777         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
778         return (uint64_t)res_ref;
779 }
780 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
781         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
782         CHECK(!val->result_ok);
783         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
784         return err_conv;
785 }
786 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
787         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
788         ret->a = a;
789         LDKTransaction b_ref;
790         b_ref.datalen = *((uint32_t*)b);
791         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
792         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
793         b_ref.data_is_owned = false;
794         ret->b = b_ref;
795         return (uint64_t)ret;
796 }
797 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
798         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
799         return tuple->a;
800 }
801 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
802         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
803         LDKTransaction b_var = tuple->b;
804         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
805         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
806         return b_arr;
807 }
808 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
809         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
810         ret->datalen = *((uint32_t*)elems);
811         if (ret->datalen == 0) {
812                 ret->data = NULL;
813         } else {
814                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
815                 uint32_t *java_elems = (uint32_t*)(elems + 4);
816                 for (size_t i = 0; i < ret->datalen; i++) {
817                         uint32_t arr_elem = java_elems[i];
818                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
819                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
820                         ret->data[i] = arr_elem_conv;
821                 }
822         }
823         return (uint64_t)ret;
824 }
825 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
826         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
827         for (size_t i = 0; i < ret.datalen; i++) {
828                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
829         }
830         return ret;
831 }
832 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
833         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
834         for (size_t i = 0; i < ret.datalen; i++) {
835                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
836         }
837         return ret;
838 }
839 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
840         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
841 }
842 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
843         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
844         CHECK(val->result_ok);
845         return *val->contents.result;
846 }
847 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
848         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
849         CHECK(!val->result_ok);
850         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
851         return err_conv;
852 }
853 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
854         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
855         switch(obj->tag) {
856                 case LDKMonitorEvent_HTLCEvent: {
857                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
858                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
859                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
860                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
861                         return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
862                 }
863                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
864                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
865                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
866                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
867                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
868                         return 0 /* LDKMonitorEvent - CommitmentTxBroadcasted */; (void) commitment_tx_broadcasted_ref;
869                 }
870                 default: abort();
871         }
872 }
873 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
874         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
875         ret->datalen = *((uint32_t*)elems);
876         if (ret->datalen == 0) {
877                 ret->data = NULL;
878         } else {
879                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
880                 uint32_t *java_elems = (uint32_t*)(elems + 4);
881                 for (size_t i = 0; i < ret->datalen; i++) {
882                         uint32_t arr_elem = java_elems[i];
883                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
884                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
885                         ret->data[i] = arr_elem_conv;
886                 }
887         }
888         return (uint64_t)ret;
889 }
890 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
891         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
892         for (size_t i = 0; i < ret.datalen; i++) {
893                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
894         }
895         return ret;
896 }
897 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(uint32_t ptr) {
898         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
899         switch(obj->tag) {
900                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
901                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
902                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - Some */; (void) some_ref;
903                 }
904                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
905                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - None */;
906                 }
907                 default: abort();
908         }
909 }
910 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
911         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
912         switch(obj->tag) {
913                 case LDKSpendableOutputDescriptor_StaticOutput: {
914                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
915                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
916                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
917                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
918                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
919                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
920                 }
921                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
922                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
923                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
924                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
925                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
926                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
927                 }
928                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
929                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
930                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
931                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
932                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
933                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
934                 }
935                 default: abort();
936         }
937 }
938 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
939         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
940         ret->datalen = *((uint32_t*)elems);
941         if (ret->datalen == 0) {
942                 ret->data = NULL;
943         } else {
944                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
945                 uint32_t *java_elems = (uint32_t*)(elems + 4);
946                 for (size_t i = 0; i < ret->datalen; i++) {
947                         uint32_t arr_elem = java_elems[i];
948                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
949                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
950                         ret->data[i] = arr_elem_conv;
951                 }
952         }
953         return (uint64_t)ret;
954 }
955 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
956         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
957         for (size_t i = 0; i < ret.datalen; i++) {
958                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
959         }
960         return ret;
961 }
962 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
963         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
964         switch(obj->tag) {
965                 case LDKErrorAction_DisconnectPeer: {
966                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
967                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
968                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
969                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
970                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
971                 }
972                 case LDKErrorAction_IgnoreError: {
973                         return 0 /* LDKErrorAction - IgnoreError */;
974                 }
975                 case LDKErrorAction_IgnoreAndLog: {
976                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
977                         return 0 /* LDKErrorAction - IgnoreAndLog */; (void) ignore_and_log_conv;
978                 }
979                 case LDKErrorAction_SendErrorMessage: {
980                         LDKErrorMessage msg_var = obj->send_error_message.msg;
981                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
982                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
983                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
984                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
985                 }
986                 default: abort();
987         }
988 }
989 uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) {
990         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
991         switch(obj->tag) {
992                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
993                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
994                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
995                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
996                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
997                         return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
998                 }
999                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1000                         return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
1001                 }
1002                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1003                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1004                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
1005                         return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
1006                 }
1007                 default: abort();
1008         }
1009 }
1010 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
1011         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1012         switch(obj->tag) {
1013                 case LDKMessageSendEvent_SendAcceptChannel: {
1014                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1015                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
1016                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1017                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1018                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1019                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1020                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
1021                 }
1022                 case LDKMessageSendEvent_SendOpenChannel: {
1023                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1024                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
1025                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1026                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1027                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1028                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1029                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
1030                 }
1031                 case LDKMessageSendEvent_SendFundingCreated: {
1032                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1033                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
1034                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1035                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1036                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1037                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1038                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
1039                 }
1040                 case LDKMessageSendEvent_SendFundingSigned: {
1041                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1042                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
1043                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1044                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1045                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1046                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1047                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
1048                 }
1049                 case LDKMessageSendEvent_SendFundingLocked: {
1050                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1051                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
1052                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1053                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1054                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1055                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1056                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
1057                 }
1058                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1059                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1060                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
1061                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1062                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1063                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1064                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1065                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
1066                 }
1067                 case LDKMessageSendEvent_UpdateHTLCs: {
1068                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1069                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
1070                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1071                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1072                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1073                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1074                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
1075                 }
1076                 case LDKMessageSendEvent_SendRevokeAndACK: {
1077                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1078                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
1079                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1080                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1081                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1082                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1083                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
1084                 }
1085                 case LDKMessageSendEvent_SendClosingSigned: {
1086                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1087                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
1088                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1089                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1090                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1091                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1092                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
1093                 }
1094                 case LDKMessageSendEvent_SendShutdown: {
1095                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1096                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
1097                         LDKShutdown msg_var = obj->send_shutdown.msg;
1098                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1099                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1100                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1101                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
1102                 }
1103                 case LDKMessageSendEvent_SendChannelReestablish: {
1104                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1105                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
1106                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1107                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1108                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1109                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1110                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
1111                 }
1112                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1113                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1114                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1115                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1116                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1117                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1118                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1119                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1120                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1121                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
1122                 }
1123                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1124                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1125                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1126                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1127                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1128                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
1129                 }
1130                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1131                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1132                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1133                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1134                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1135                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
1136                 }
1137                 case LDKMessageSendEvent_SendChannelUpdate: {
1138                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1139                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_update.node_id.compressed_form, 33);
1140                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1141                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1142                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1143                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1144                         return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref;
1145                 }
1146                 case LDKMessageSendEvent_HandleError: {
1147                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1148                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
1149                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1150                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
1151                 }
1152                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1153                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1154                         return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref;
1155                 }
1156                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1157                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1158                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
1159                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1160                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1161                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1162                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1163                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
1164                 }
1165                 case LDKMessageSendEvent_SendShortIdsQuery: {
1166                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1167                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
1168                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1169                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1170                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1171                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1172                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
1173                 }
1174                 case LDKMessageSendEvent_SendReplyChannelRange: {
1175                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1176                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
1177                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1178                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1179                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1180                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1181                         return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
1182                 }
1183                 default: abort();
1184         }
1185 }
1186 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
1187         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1188         ret->datalen = *((uint32_t*)elems);
1189         if (ret->datalen == 0) {
1190                 ret->data = NULL;
1191         } else {
1192                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1193                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1194                 for (size_t i = 0; i < ret->datalen; i++) {
1195                         uint32_t arr_elem = java_elems[i];
1196                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1197                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1198                         ret->data[i] = arr_elem_conv;
1199                 }
1200         }
1201         return (uint64_t)ret;
1202 }
1203 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1204         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1205         for (size_t i = 0; i < ret.datalen; i++) {
1206                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1207         }
1208         return ret;
1209 }
1210 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1211         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1212 }
1213 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1214         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1215         CHECK(val->result_ok);
1216         LDKInitFeatures res_var = (*val->contents.result);
1217         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1218         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1219         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1220         return res_ref;
1221 }
1222 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1223         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1224         CHECK(!val->result_ok);
1225         LDKDecodeError err_var = (*val->contents.err);
1226         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1227         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1228         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1229         return err_ref;
1230 }
1231 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1232         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1233 }
1234 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1235         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1236         CHECK(val->result_ok);
1237         LDKNodeFeatures res_var = (*val->contents.result);
1238         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1239         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1240         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1241         return res_ref;
1242 }
1243 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1244         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1245         CHECK(!val->result_ok);
1246         LDKDecodeError err_var = (*val->contents.err);
1247         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1248         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1249         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1250         return err_ref;
1251 }
1252 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1253         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1254 }
1255 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1256         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1257         CHECK(val->result_ok);
1258         LDKChannelFeatures res_var = (*val->contents.result);
1259         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1260         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1261         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1262         return res_ref;
1263 }
1264 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1265         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1266         CHECK(!val->result_ok);
1267         LDKDecodeError err_var = (*val->contents.err);
1268         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1269         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1270         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1271         return err_ref;
1272 }
1273 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1274         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1275 }
1276 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1277         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1278         CHECK(val->result_ok);
1279         LDKInvoiceFeatures res_var = (*val->contents.result);
1280         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1281         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1282         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1283         return res_ref;
1284 }
1285 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1286         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1287         CHECK(!val->result_ok);
1288         LDKDecodeError err_var = (*val->contents.err);
1289         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1290         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1291         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1292         return err_ref;
1293 }
1294 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1295         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1296 }
1297 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1298         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1299         CHECK(val->result_ok);
1300         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1301         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1302         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1303         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1304         return res_ref;
1305 }
1306 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1307         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1308         CHECK(!val->result_ok);
1309         LDKDecodeError err_var = (*val->contents.err);
1310         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1311         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1312         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1313         return err_ref;
1314 }
1315 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1316         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1317 }
1318 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1319         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1320         CHECK(val->result_ok);
1321         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1322         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1323         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1324         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1325         return res_ref;
1326 }
1327 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1328         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1329         CHECK(!val->result_ok);
1330         LDKDecodeError err_var = (*val->contents.err);
1331         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1332         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1333         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1334         return err_ref;
1335 }
1336 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1337         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1338 }
1339 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1340         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1341         CHECK(val->result_ok);
1342         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1343         return res_ref;
1344 }
1345 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1346         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1347         CHECK(!val->result_ok);
1348         LDKDecodeError err_var = (*val->contents.err);
1349         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1350         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1351         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1352         return err_ref;
1353 }
1354 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
1355         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1356         LDKSignature a_ref;
1357         CHECK(*((uint32_t*)a) == 64);
1358         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
1359         ret->a = a_ref;
1360         LDKCVec_SignatureZ b_constr;
1361         b_constr.datalen = *((uint32_t*)b);
1362         if (b_constr.datalen > 0)
1363                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1364         else
1365                 b_constr.data = NULL;
1366         int8_tArray* b_vals = (int8_tArray*)(b + 4);
1367         for (size_t m = 0; m < b_constr.datalen; m++) {
1368                 int8_tArray b_conv_12 = b_vals[m];
1369                 LDKSignature b_conv_12_ref;
1370                 CHECK(*((uint32_t*)b_conv_12) == 64);
1371                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
1372                 b_constr.data[m] = b_conv_12_ref;
1373         }
1374         ret->b = b_constr;
1375         return (uint64_t)ret;
1376 }
1377 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
1378         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1379         int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1380         memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
1381         return a_arr;
1382 }
1383 ptrArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
1384         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1385         LDKCVec_SignatureZ b_var = tuple->b;
1386         ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1387         int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
1388         for (size_t m = 0; m < b_var.datalen; m++) {
1389                 int8_tArray b_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1390                 memcpy((uint8_t*)(b_conv_12_arr + 4), b_var.data[m].compact_form, 64);
1391                 b_arr_ptr[m] = b_conv_12_arr;
1392         }
1393         return b_arr;
1394 }
1395 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
1396         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1397 }
1398 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1399         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1400         CHECK(val->result_ok);
1401         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
1402         return res_ref;
1403 }
1404 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1405         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1406         CHECK(!val->result_ok);
1407         return *val->contents.err;
1408 }
1409 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
1410         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1411 }
1412 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1413         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1414         CHECK(val->result_ok);
1415         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1416         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1417         return res_arr;
1418 }
1419 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1420         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1421         CHECK(!val->result_ok);
1422         return *val->contents.err;
1423 }
1424 typedef struct LDKBaseSign_JCalls {
1425         atomic_size_t refcnt;
1426         uint32_t get_per_commitment_point_meth;
1427         uint32_t release_commitment_secret_meth;
1428         uint32_t channel_keys_id_meth;
1429         uint32_t sign_counterparty_commitment_meth;
1430         uint32_t sign_holder_commitment_and_htlcs_meth;
1431         uint32_t sign_justice_revoked_output_meth;
1432         uint32_t sign_justice_revoked_htlc_meth;
1433         uint32_t sign_counterparty_htlc_transaction_meth;
1434         uint32_t sign_closing_transaction_meth;
1435         uint32_t sign_channel_announcement_meth;
1436         uint32_t ready_channel_meth;
1437 } LDKBaseSign_JCalls;
1438 static void LDKBaseSign_JCalls_free(void* this_arg) {
1439         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1440         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1441                 js_free(j_calls->get_per_commitment_point_meth);
1442                 js_free(j_calls->release_commitment_secret_meth);
1443                 js_free(j_calls->channel_keys_id_meth);
1444                 js_free(j_calls->sign_counterparty_commitment_meth);
1445                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1446                 js_free(j_calls->sign_justice_revoked_output_meth);
1447                 js_free(j_calls->sign_justice_revoked_htlc_meth);
1448                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1449                 js_free(j_calls->sign_closing_transaction_meth);
1450                 js_free(j_calls->sign_channel_announcement_meth);
1451                 js_free(j_calls->ready_channel_meth);
1452                 FREE(j_calls);
1453         }
1454 }
1455 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1456         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1457         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1458         LDKPublicKey ret_ref;
1459         CHECK(*((uint32_t*)ret) == 33);
1460         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1461         return ret_ref;
1462 }
1463 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1464         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1465         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1466         LDKThirtyTwoBytes ret_ref;
1467         CHECK(*((uint32_t*)ret) == 32);
1468         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1469         return ret_ref;
1470 }
1471 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1472         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1473         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1474         LDKThirtyTwoBytes ret_ref;
1475         CHECK(*((uint32_t*)ret) == 32);
1476         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1477         return ret_ref;
1478 }
1479 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1480         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1481         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1482         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1483         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1484         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1485         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1486         if (commitment_tx_var.is_owned) {
1487                 commitment_tx_ref |= 1;
1488         }
1489         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1490         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1491         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1492         return ret_conv;
1493 }
1494 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1495         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1496         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1497         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1498         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1499         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1500         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1501         if (commitment_tx_var.is_owned) {
1502                 commitment_tx_ref |= 1;
1503         }
1504         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1505         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1506         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1507         return ret_conv;
1508 }
1509 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]) {
1510         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1511         LDKTransaction justice_tx_var = justice_tx;
1512         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1513         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1514         Transaction_free(justice_tx_var);
1515         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1516         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1517         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
1518         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1519         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1520         return ret_conv;
1521 }
1522 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) {
1523         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1524         LDKTransaction justice_tx_var = justice_tx;
1525         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1526         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1527         Transaction_free(justice_tx_var);
1528         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1529         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1530         LDKHTLCOutputInCommitment htlc_var = *htlc;
1531         htlc_var = HTLCOutputInCommitment_clone(htlc);
1532         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1533         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1534         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1535         if (htlc_var.is_owned) {
1536                 htlc_ref |= 1;
1537         }
1538         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
1539         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1540         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1541         return ret_conv;
1542 }
1543 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) {
1544         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1545         LDKTransaction htlc_tx_var = htlc_tx;
1546         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1547         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1548         Transaction_free(htlc_tx_var);
1549         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1550         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1551         LDKHTLCOutputInCommitment htlc_var = *htlc;
1552         htlc_var = HTLCOutputInCommitment_clone(htlc);
1553         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1554         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1555         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1556         if (htlc_var.is_owned) {
1557                 htlc_ref |= 1;
1558         }
1559         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
1560         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1561         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1562         return ret_conv;
1563 }
1564 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
1565         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1566         LDKTransaction closing_tx_var = closing_tx;
1567         int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1568         memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
1569         Transaction_free(closing_tx_var);
1570         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
1571         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1572         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1573         return ret_conv;
1574 }
1575 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1576         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1577         LDKUnsignedChannelAnnouncement msg_var = *msg;
1578         msg_var = UnsignedChannelAnnouncement_clone(msg);
1579         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1580         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1581         uint64_t msg_ref = (uint64_t)msg_var.inner;
1582         if (msg_var.is_owned) {
1583                 msg_ref |= 1;
1584         }
1585         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1586         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1587         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1588         return ret_conv;
1589 }
1590 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1591         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1592         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1593         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1594         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1595         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1596         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
1597         if (channel_parameters_var.is_owned) {
1598                 channel_parameters_ref |= 1;
1599         }
1600         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1601 }
1602 static void* LDKBaseSign_JCalls_clone(const void* this_arg) {
1603         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1604         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1605         return (void*) this_arg;
1606 }
1607 static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1608         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
1609         atomic_init(&calls->refcnt, 1);
1610         //TODO: Assign calls->o from o
1611
1612         LDKChannelPublicKeys pubkeys_conv;
1613         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1614         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1615         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1616
1617         LDKBaseSign ret = {
1618                 .this_arg = (void*) calls,
1619                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
1620                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
1621                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
1622                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
1623                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
1624                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
1625                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
1626                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
1627                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
1628                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
1629                 .ready_channel = ready_channel_LDKBaseSign_jcall,
1630                 .free = LDKBaseSign_JCalls_free,
1631                 .pubkeys = pubkeys_conv,
1632                 .set_pubkeys = NULL,
1633         };
1634         return ret;
1635 }
1636 long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1637         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
1638         *res_ptr = LDKBaseSign_init(o, pubkeys);
1639         return (long)res_ptr;
1640 }
1641 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1642         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1643         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1644         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1645         return ret_arr;
1646 }
1647
1648 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1649         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1650         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1651         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1652         return ret_arr;
1653 }
1654
1655 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
1656         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1657         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1658         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
1659         return ret_arr;
1660 }
1661
1662 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1663         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1664         LDKCommitmentTransaction commitment_tx_conv;
1665         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1666         commitment_tx_conv.is_owned = false;
1667         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1668         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1669         return (uint64_t)ret_conv;
1670 }
1671
1672 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
1673         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1674         LDKHolderCommitmentTransaction commitment_tx_conv;
1675         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1676         commitment_tx_conv.is_owned = false;
1677         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1678         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1679         return (uint64_t)ret_conv;
1680 }
1681
1682 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) {
1683         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1684         LDKTransaction justice_tx_ref;
1685         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1686         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1687         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1688         justice_tx_ref.data_is_owned = true;
1689         unsigned char per_commitment_key_arr[32];
1690         CHECK(*((uint32_t*)per_commitment_key) == 32);
1691         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1692         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1693         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1694         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
1695         return (uint64_t)ret_conv;
1696 }
1697
1698 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) {
1699         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1700         LDKTransaction justice_tx_ref;
1701         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1702         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1703         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1704         justice_tx_ref.data_is_owned = true;
1705         unsigned char per_commitment_key_arr[32];
1706         CHECK(*((uint32_t*)per_commitment_key) == 32);
1707         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1708         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1709         LDKHTLCOutputInCommitment htlc_conv;
1710         htlc_conv.inner = (void*)(htlc & (~1));
1711         htlc_conv.is_owned = false;
1712         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1713         *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);
1714         return (uint64_t)ret_conv;
1715 }
1716
1717 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) {
1718         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1719         LDKTransaction htlc_tx_ref;
1720         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
1721         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1722         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
1723         htlc_tx_ref.data_is_owned = true;
1724         LDKPublicKey per_commitment_point_ref;
1725         CHECK(*((uint32_t*)per_commitment_point) == 33);
1726         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
1727         LDKHTLCOutputInCommitment htlc_conv;
1728         htlc_conv.inner = (void*)(htlc & (~1));
1729         htlc_conv.is_owned = false;
1730         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1731         *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);
1732         return (uint64_t)ret_conv;
1733 }
1734
1735 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) {
1736         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1737         LDKTransaction closing_tx_ref;
1738         closing_tx_ref.datalen = *((uint32_t*)closing_tx);
1739         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1740         memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen);
1741         closing_tx_ref.data_is_owned = true;
1742         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1743         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1744         return (uint64_t)ret_conv;
1745 }
1746
1747 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
1748         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1749         LDKUnsignedChannelAnnouncement msg_conv;
1750         msg_conv.inner = (void*)(msg & (~1));
1751         msg_conv.is_owned = false;
1752         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1753         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1754         return (uint64_t)ret_conv;
1755 }
1756
1757 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
1758         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1759         LDKChannelTransactionParameters channel_parameters_conv;
1760         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1761         channel_parameters_conv.is_owned = false;
1762         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1763 }
1764
1765 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
1766         if (this_arg->set_pubkeys != NULL)
1767                 this_arg->set_pubkeys(this_arg);
1768         return this_arg->pubkeys;
1769 }
1770 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
1771         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1772         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
1773         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1774         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1775         uint64_t ret_ref = (uint64_t)ret_var.inner;
1776         if (ret_var.is_owned) {
1777                 ret_ref |= 1;
1778         }
1779         return ret_ref;
1780 }
1781
1782 typedef struct LDKSign_JCalls {
1783         atomic_size_t refcnt;
1784         LDKBaseSign_JCalls* BaseSign;
1785         uint32_t write_meth;
1786 } LDKSign_JCalls;
1787 static void LDKSign_JCalls_free(void* this_arg) {
1788         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1789         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1790                 js_free(j_calls->write_meth);
1791                 FREE(j_calls);
1792         }
1793 }
1794 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
1795         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1796         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
1797         LDKCVec_u8Z ret_ref;
1798         ret_ref.datalen = *((uint32_t*)ret);
1799         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1800         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
1801         return ret_ref;
1802 }
1803 static void* LDKSign_JCalls_clone(const void* this_arg) {
1804         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1805         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1806         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
1807         return (void*) this_arg;
1808 }
1809 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
1810         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1811         atomic_init(&calls->refcnt, 1);
1812         //TODO: Assign calls->o from o
1813
1814         LDKChannelPublicKeys pubkeys_conv;
1815         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1816         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1817         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1818
1819         LDKSign ret = {
1820                 .this_arg = (void*) calls,
1821                 .write = write_LDKSign_jcall,
1822                 .clone = LDKSign_JCalls_clone,
1823                 .free = LDKSign_JCalls_free,
1824                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
1825         };
1826         calls->BaseSign = ret.BaseSign.this_arg;
1827         return ret;
1828 }
1829 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
1830         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
1831         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
1832         return (long)res_ptr;
1833 }
1834 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
1835         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1836         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1837         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1838         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
1839         CVec_u8Z_free(ret_var);
1840         return ret_arr;
1841 }
1842
1843 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
1844         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
1845 }
1846 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
1847         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
1848         CHECK(val->result_ok);
1849         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
1850         *ret = Sign_clone(&(*val->contents.result));
1851         return (uint64_t)ret;
1852 }
1853 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
1854         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
1855         CHECK(!val->result_ok);
1856         LDKDecodeError err_var = (*val->contents.err);
1857         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1858         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1859         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1860         return err_ref;
1861 }
1862 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_result_ok(uint32_t arg) {
1863         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
1864 }
1865 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_ok(uint32_t arg) {
1866         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
1867         CHECK(val->result_ok);
1868         int8_tArray es_arr = init_arr(68, sizeof(uint8_t), "Native int8_tArray Bytes");
1869         memcpy((uint8_t*)(es_arr + 4), (*val->contents.result).serialized_form, 68);
1870         return es_arr;
1871 }
1872 void  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_err(uint32_t arg) {
1873         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
1874         CHECK(!val->result_ok);
1875         return *val->contents.err;
1876 }
1877 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
1878         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
1879         for (size_t i = 0; i < ret.datalen; i++) {
1880                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
1881         }
1882         return ret;
1883 }
1884 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
1885         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
1886 }
1887 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
1888         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
1889         CHECK(val->result_ok);
1890         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
1891         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1892         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
1893         for (size_t m = 0; m < res_var.datalen; m++) {
1894                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
1895                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1896                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
1897                 res_arr_ptr[m] = res_conv_12_arr;
1898         }
1899         return res_arr;
1900 }
1901 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
1902         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
1903         CHECK(!val->result_ok);
1904         return *val->contents.err;
1905 }
1906 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
1907         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
1908 }
1909 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
1910         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
1911         CHECK(val->result_ok);
1912         LDKInMemorySigner res_var = (*val->contents.result);
1913         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1914         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1915         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1916         return res_ref;
1917 }
1918 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
1919         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
1920         CHECK(!val->result_ok);
1921         LDKDecodeError err_var = (*val->contents.err);
1922         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1923         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1924         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1925         return err_ref;
1926 }
1927 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
1928         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
1929         ret->datalen = *((uint32_t*)elems);
1930         if (ret->datalen == 0) {
1931                 ret->data = NULL;
1932         } else {
1933                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
1934                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1935                 for (size_t i = 0; i < ret->datalen; i++) {
1936                         uint32_t arr_elem = java_elems[i];
1937                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
1938                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
1939                         ret->data[i] = arr_elem_conv;
1940                 }
1941         }
1942         return (uint64_t)ret;
1943 }
1944 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
1945         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
1946         for (size_t i = 0; i < ret.datalen; i++) {
1947                 ret.data[i] = TxOut_clone(&orig->data[i]);
1948         }
1949         return ret;
1950 }
1951 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
1952         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
1953 }
1954 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
1955         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
1956         CHECK(val->result_ok);
1957         LDKTransaction res_var = (*val->contents.result);
1958         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1959         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
1960         return res_arr;
1961 }
1962 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
1963         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
1964         CHECK(!val->result_ok);
1965         return *val->contents.err;
1966 }
1967 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
1968         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
1969         LDKThirtyTwoBytes a_ref;
1970         CHECK(*((uint32_t*)a) == 32);
1971         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1972         ret->a = a_ref;
1973         LDKChannelMonitor b_conv;
1974         b_conv.inner = (void*)(b & (~1));
1975         b_conv.is_owned = (b & 1) || (b == 0);
1976         b_conv = ChannelMonitor_clone(&b_conv);
1977         ret->b = b_conv;
1978         return (uint64_t)ret;
1979 }
1980 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
1981         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1982         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1983         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1984         return a_arr;
1985 }
1986 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
1987         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1988         LDKChannelMonitor b_var = tuple->b;
1989         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1990         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1991         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
1992         return b_ref;
1993 }
1994 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_BlockHashChannelMonitorZZ_new(uint32_tArray elems) {
1995         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
1996         ret->datalen = *((uint32_t*)elems);
1997         if (ret->datalen == 0) {
1998                 ret->data = NULL;
1999         } else {
2000                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2001                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2002                 for (size_t i = 0; i < ret->datalen; i++) {
2003                         uint32_t arr_elem = java_elems[i];
2004                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2005                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2006                         ret->data[i] = arr_elem_conv;
2007                 }
2008         }
2009         return (uint64_t)ret;
2010 }
2011 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(uint32_t arg) {
2012         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2013 }
2014 uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(uint32_t arg) {
2015         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2016         CHECK(val->result_ok);
2017         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2018         uint32_tArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2019         uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
2020         for (size_t m = 0; m < res_var.datalen; m++) {
2021                 uint64_t res_conv_38_ref = (uint64_t)(&res_var.data[m]) | 1;
2022                 res_arr_ptr[m] = res_conv_38_ref;
2023         }
2024         return res_arr;
2025 }
2026 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
2027         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2028         CHECK(!val->result_ok);
2029         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
2030         return err_conv;
2031 }
2032 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) {
2033         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2034         switch(obj->tag) {
2035                 case LDKCOption_u16Z_Some: {
2036                         return 0 /* LDKCOption_u16Z - Some */; (void) obj->some;
2037                 }
2038                 case LDKCOption_u16Z_None: {
2039                         return 0 /* LDKCOption_u16Z - None */;
2040                 }
2041                 default: abort();
2042         }
2043 }
2044 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2045         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2046         switch(obj->tag) {
2047                 case LDKAPIError_APIMisuseError: {
2048                         LDKStr err_str = obj->api_misuse_error.err;
2049                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2050                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_conv;
2051                 }
2052                 case LDKAPIError_FeeRateTooHigh: {
2053                         LDKStr err_str = obj->fee_rate_too_high.err;
2054                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2055                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_conv; (void) obj->fee_rate_too_high.feerate;
2056                 }
2057                 case LDKAPIError_RouteError: {
2058                         LDKStr err_str = obj->route_error.err;
2059                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2060                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2061                 }
2062                 case LDKAPIError_ChannelUnavailable: {
2063                         LDKStr err_str = obj->channel_unavailable.err;
2064                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2065                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_conv;
2066                 }
2067                 case LDKAPIError_MonitorUpdateFailed: {
2068                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2069                 }
2070                 default: abort();
2071         }
2072 }
2073 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
2074         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2075 }
2076 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2077         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2078         CHECK(val->result_ok);
2079         return *val->contents.result;
2080 }
2081 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2082         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2083         CHECK(!val->result_ok);
2084         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2085         return err_ref;
2086 }
2087 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
2088         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2089         ret->datalen = *((uint32_t*)elems);
2090         if (ret->datalen == 0) {
2091                 ret->data = NULL;
2092         } else {
2093                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2094                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2095                 for (size_t i = 0; i < ret->datalen; i++) {
2096                         uint32_t arr_elem = java_elems[i];
2097                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2098                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2099                         ret->data[i] = arr_elem_conv;
2100                 }
2101         }
2102         return (uint64_t)ret;
2103 }
2104 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2105         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2106         for (size_t i = 0; i < ret.datalen; i++) {
2107                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2108         }
2109         return ret;
2110 }
2111 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
2112         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2113         ret->datalen = *((uint32_t*)elems);
2114         if (ret->datalen == 0) {
2115                 ret->data = NULL;
2116         } else {
2117                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2118                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2119                 for (size_t i = 0; i < ret->datalen; i++) {
2120                         uint32_t arr_elem = java_elems[i];
2121                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2122                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
2123                         ret->data[i] = arr_elem_conv;
2124                 }
2125         }
2126         return (uint64_t)ret;
2127 }
2128 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2129         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2130         for (size_t i = 0; i < ret.datalen; i++) {
2131                 ret.data[i] = APIError_clone(&orig->data[i]);
2132         }
2133         return ret;
2134 }
2135 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2136         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
2137         switch(obj->tag) {
2138                 case LDKPaymentSendFailure_ParameterError: {
2139                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
2140                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
2141                 }
2142                 case LDKPaymentSendFailure_PathParameterError: {
2143                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
2144                         uint32_tArray path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2145                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
2146                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
2147                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2148                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
2149                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
2150                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
2151                         }
2152                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
2153                 }
2154                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2155                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
2156                         uint32_tArray all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2157                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
2158                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
2159                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
2160                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
2161                         }
2162                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
2163                 }
2164                 case LDKPaymentSendFailure_PartialFailure: {
2165                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
2166                         uint32_tArray partial_failure_arr = init_arr(partial_failure_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2167                         uint32_t *partial_failure_arr_ptr = (uint32_t*)(partial_failure_arr + 4);
2168                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
2169                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2170                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
2171                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
2172                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
2173                         }
2174                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) partial_failure_arr;
2175                 }
2176                 default: abort();
2177         }
2178 }
2179 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
2180         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2181 }
2182 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2183         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2184         CHECK(val->result_ok);
2185         return *val->contents.result;
2186 }
2187 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2188         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2189         CHECK(!val->result_ok);
2190         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2191         return err_ref;
2192 }
2193 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
2194         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2195         switch(obj->tag) {
2196                 case LDKNetAddress_IPv4: {
2197                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
2198                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
2199                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
2200                 }
2201                 case LDKNetAddress_IPv6: {
2202                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
2203                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
2204                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
2205                 }
2206                 case LDKNetAddress_OnionV2: {
2207                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
2208                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
2209                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
2210                 }
2211                 case LDKNetAddress_OnionV3: {
2212                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2213                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
2214                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
2215                 }
2216                 default: abort();
2217         }
2218 }
2219 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
2220         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
2221         ret->datalen = *((uint32_t*)elems);
2222         if (ret->datalen == 0) {
2223                 ret->data = NULL;
2224         } else {
2225                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
2226                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2227                 for (size_t i = 0; i < ret->datalen; i++) {
2228                         uint32_t arr_elem = java_elems[i];
2229                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
2230                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
2231                         ret->data[i] = arr_elem_conv;
2232                 }
2233         }
2234         return (uint64_t)ret;
2235 }
2236 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2237         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2238         for (size_t i = 0; i < ret.datalen; i++) {
2239                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2240         }
2241         return ret;
2242 }
2243 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
2244         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
2245         LDKThirtyTwoBytes a_ref;
2246         CHECK(*((uint32_t*)a) == 32);
2247         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2248         ret->a = a_ref;
2249         LDKThirtyTwoBytes b_ref;
2250         CHECK(*((uint32_t*)b) == 32);
2251         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2252         ret->b = b_ref;
2253         return (uint64_t)ret;
2254 }
2255 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t ptr) {
2256         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
2257         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2258         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2259         return a_arr;
2260 }
2261 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t ptr) {
2262         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
2263         int8_tArray b_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2264         memcpy((uint8_t*)(b_arr + 4), tuple->b.data, 32);
2265         return b_arr;
2266 }
2267 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_result_ok(uint32_t arg) {
2268         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
2269 }
2270 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_ok(uint32_t arg) {
2271         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2272         CHECK(val->result_ok);
2273         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2274         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2275         return res_arr;
2276 }
2277 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_err(uint32_t arg) {
2278         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2279         CHECK(!val->result_ok);
2280         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2281         return err_ref;
2282 }
2283 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
2284         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2285         ret->datalen = *((uint32_t*)elems);
2286         if (ret->datalen == 0) {
2287                 ret->data = NULL;
2288         } else {
2289                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2290                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2291                 for (size_t i = 0; i < ret->datalen; i++) {
2292                         uint32_t arr_elem = java_elems[i];
2293                         LDKChannelMonitor arr_elem_conv;
2294                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2295                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2296                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2297                         ret->data[i] = arr_elem_conv;
2298                 }
2299         }
2300         return (uint64_t)ret;
2301 }
2302 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2303         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2304         for (size_t i = 0; i < ret.datalen; i++) {
2305                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2306         }
2307         return ret;
2308 }
2309 typedef struct LDKWatch_JCalls {
2310         atomic_size_t refcnt;
2311         uint32_t watch_channel_meth;
2312         uint32_t update_channel_meth;
2313         uint32_t release_pending_monitor_events_meth;
2314 } LDKWatch_JCalls;
2315 static void LDKWatch_JCalls_free(void* this_arg) {
2316         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2317         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2318                 js_free(j_calls->watch_channel_meth);
2319                 js_free(j_calls->update_channel_meth);
2320                 js_free(j_calls->release_pending_monitor_events_meth);
2321                 FREE(j_calls);
2322         }
2323 }
2324 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2325         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2326         LDKOutPoint funding_txo_var = funding_txo;
2327         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2328         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2329         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2330         if (funding_txo_var.is_owned) {
2331                 funding_txo_ref |= 1;
2332         }
2333         LDKChannelMonitor monitor_var = monitor;
2334         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2335         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2336         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
2337         if (monitor_var.is_owned) {
2338                 monitor_ref |= 1;
2339         }
2340         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2341         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2342         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2343         return ret_conv;
2344 }
2345 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2346         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2347         LDKOutPoint funding_txo_var = funding_txo;
2348         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2349         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2350         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2351         if (funding_txo_var.is_owned) {
2352                 funding_txo_ref |= 1;
2353         }
2354         LDKChannelMonitorUpdate update_var = update;
2355         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2356         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2357         uint64_t update_ref = (uint64_t)update_var.inner;
2358         if (update_var.is_owned) {
2359                 update_ref |= 1;
2360         }
2361         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2362         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2363         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2364         return ret_conv;
2365 }
2366 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
2367         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2368         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2369         LDKCVec_MonitorEventZ ret_constr;
2370         ret_constr.datalen = *((uint32_t*)ret);
2371         if (ret_constr.datalen > 0)
2372                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2373         else
2374                 ret_constr.data = NULL;
2375         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2376         for (size_t o = 0; o < ret_constr.datalen; o++) {
2377                 uint32_t ret_conv_14 = ret_vals[o];
2378                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
2379                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
2380                 ret_constr.data[o] = ret_conv_14_conv;
2381         }
2382         return ret_constr;
2383 }
2384 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2385         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2386         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2387         return (void*) this_arg;
2388 }
2389 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2390         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2391         atomic_init(&calls->refcnt, 1);
2392         //TODO: Assign calls->o from o
2393
2394         LDKWatch ret = {
2395                 .this_arg = (void*) calls,
2396                 .watch_channel = watch_channel_LDKWatch_jcall,
2397                 .update_channel = update_channel_LDKWatch_jcall,
2398                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
2399                 .free = LDKWatch_JCalls_free,
2400         };
2401         return ret;
2402 }
2403 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2404         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2405         *res_ptr = LDKWatch_init(o);
2406         return (long)res_ptr;
2407 }
2408 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2409         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2410         LDKOutPoint funding_txo_conv;
2411         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2412         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2413         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2414         LDKChannelMonitor monitor_conv;
2415         monitor_conv.inner = (void*)(monitor & (~1));
2416         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2417         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2418         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2419         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2420         return (uint64_t)ret_conv;
2421 }
2422
2423 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
2424         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2425         LDKOutPoint funding_txo_conv;
2426         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2427         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2428         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2429         LDKChannelMonitorUpdate update_conv;
2430         update_conv.inner = (void*)(update & (~1));
2431         update_conv.is_owned = (update & 1) || (update == 0);
2432         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2433         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2434         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2435         return (uint64_t)ret_conv;
2436 }
2437
2438 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
2439         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2440         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2441         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2442         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2443         for (size_t o = 0; o < ret_var.datalen; o++) {
2444                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2445                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
2446                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
2447                 ret_arr_ptr[o] = ret_conv_14_ref;
2448         }
2449         FREE(ret_var.data);
2450         return ret_arr;
2451 }
2452
2453 typedef struct LDKBroadcasterInterface_JCalls {
2454         atomic_size_t refcnt;
2455         uint32_t broadcast_transaction_meth;
2456 } LDKBroadcasterInterface_JCalls;
2457 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2458         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2459         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2460                 js_free(j_calls->broadcast_transaction_meth);
2461                 FREE(j_calls);
2462         }
2463 }
2464 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
2465         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2466         LDKTransaction tx_var = tx;
2467         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2468         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
2469         Transaction_free(tx_var);
2470         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
2471 }
2472 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2473         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2474         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2475         return (void*) this_arg;
2476 }
2477 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
2478         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2479         atomic_init(&calls->refcnt, 1);
2480         //TODO: Assign calls->o from o
2481
2482         LDKBroadcasterInterface ret = {
2483                 .this_arg = (void*) calls,
2484                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
2485                 .free = LDKBroadcasterInterface_JCalls_free,
2486         };
2487         return ret;
2488 }
2489 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
2490         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2491         *res_ptr = LDKBroadcasterInterface_init(o);
2492         return (long)res_ptr;
2493 }
2494 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
2495         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
2496         LDKTransaction tx_ref;
2497         tx_ref.datalen = *((uint32_t*)tx);
2498         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2499         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
2500         tx_ref.data_is_owned = true;
2501         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2502 }
2503
2504 typedef struct LDKKeysInterface_JCalls {
2505         atomic_size_t refcnt;
2506         uint32_t get_node_secret_meth;
2507         uint32_t get_destination_script_meth;
2508         uint32_t get_shutdown_pubkey_meth;
2509         uint32_t get_channel_signer_meth;
2510         uint32_t get_secure_random_bytes_meth;
2511         uint32_t read_chan_signer_meth;
2512         uint32_t sign_invoice_meth;
2513 } LDKKeysInterface_JCalls;
2514 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2515         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2516         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2517                 js_free(j_calls->get_node_secret_meth);
2518                 js_free(j_calls->get_destination_script_meth);
2519                 js_free(j_calls->get_shutdown_pubkey_meth);
2520                 js_free(j_calls->get_channel_signer_meth);
2521                 js_free(j_calls->get_secure_random_bytes_meth);
2522                 js_free(j_calls->read_chan_signer_meth);
2523                 js_free(j_calls->sign_invoice_meth);
2524                 FREE(j_calls);
2525         }
2526 }
2527 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
2528         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2529         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
2530         LDKSecretKey ret_ref;
2531         CHECK(*((uint32_t*)ret) == 32);
2532         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
2533         return ret_ref;
2534 }
2535 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
2536         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2537         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
2538         LDKCVec_u8Z ret_ref;
2539         ret_ref.datalen = *((uint32_t*)ret);
2540         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2541         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2542         return ret_ref;
2543 }
2544 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
2545         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2546         int8_tArray ret = js_invoke_function_0(j_calls->get_shutdown_pubkey_meth);
2547         LDKPublicKey ret_ref;
2548         CHECK(*((uint32_t*)ret) == 33);
2549         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
2550         return ret_ref;
2551 }
2552 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2553         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2554         LDKSign* ret = (LDKSign*)js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
2555         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
2556         ret_conv = Sign_clone(ret);
2557         return ret_conv;
2558 }
2559 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
2560         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2561         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
2562         LDKThirtyTwoBytes ret_ref;
2563         CHECK(*((uint32_t*)ret) == 32);
2564         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
2565         return ret_ref;
2566 }
2567 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
2568         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2569         LDKu8slice reader_var = reader;
2570         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2571         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
2572         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
2573         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
2574         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
2575         return ret_conv;
2576 }
2577 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
2578         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2579         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
2580         int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2581         memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
2582         CVec_u8Z_free(invoice_preimage_var);
2583         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
2584         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
2585         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
2586         return ret_conv;
2587 }
2588 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2589         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2590         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2591         return (void*) this_arg;
2592 }
2593 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
2594         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2595         atomic_init(&calls->refcnt, 1);
2596         //TODO: Assign calls->o from o
2597
2598         LDKKeysInterface ret = {
2599                 .this_arg = (void*) calls,
2600                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
2601                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
2602                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
2603                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
2604                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
2605                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
2606                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
2607                 .free = LDKKeysInterface_JCalls_free,
2608         };
2609         return ret;
2610 }
2611 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
2612         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2613         *res_ptr = LDKKeysInterface_init(o);
2614         return (long)res_ptr;
2615 }
2616 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
2617         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2618         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2619         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
2620         return ret_arr;
2621 }
2622
2623 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
2624         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2625         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2626         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2627         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2628         CVec_u8Z_free(ret_var);
2629         return ret_arr;
2630 }
2631
2632 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_pubkey(uint32_t this_arg) {
2633         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2634         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2635         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
2636         return ret_arr;
2637 }
2638
2639 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
2640         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2641         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2642         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2643         return (uint64_t)ret;
2644 }
2645
2646 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2647         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2648         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2649         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2650         return ret_arr;
2651 }
2652
2653 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2654         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2655         LDKu8slice reader_ref;
2656         reader_ref.datalen = *((uint32_t*)reader);
2657         reader_ref.data = (int8_t*)(reader + 4);
2658         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
2659         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2660         return (uint64_t)ret_conv;
2661 }
2662
2663 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
2664         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2665         LDKCVec_u8Z invoice_preimage_ref;
2666         invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
2667         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
2668         memcpy(invoice_preimage_ref.data, (uint8_t*)(invoice_preimage + 4), invoice_preimage_ref.datalen);
2669         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
2670         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
2671         return (uint64_t)ret_conv;
2672 }
2673
2674 typedef struct LDKFeeEstimator_JCalls {
2675         atomic_size_t refcnt;
2676         uint32_t get_est_sat_per_1000_weight_meth;
2677 } LDKFeeEstimator_JCalls;
2678 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2679         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2680         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2681                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
2682                 FREE(j_calls);
2683         }
2684 }
2685 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2686         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2687         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
2688         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2689 }
2690 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2691         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2692         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2693         return (void*) this_arg;
2694 }
2695 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
2696         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2697         atomic_init(&calls->refcnt, 1);
2698         //TODO: Assign calls->o from o
2699
2700         LDKFeeEstimator ret = {
2701                 .this_arg = (void*) calls,
2702                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
2703                 .free = LDKFeeEstimator_JCalls_free,
2704         };
2705         return ret;
2706 }
2707 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
2708         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2709         *res_ptr = LDKFeeEstimator_init(o);
2710         return (long)res_ptr;
2711 }
2712 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
2713         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
2714         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
2715         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2716         return ret_val;
2717 }
2718
2719 typedef struct LDKLogger_JCalls {
2720         atomic_size_t refcnt;
2721         uint32_t log_meth;
2722 } LDKLogger_JCalls;
2723 static void LDKLogger_JCalls_free(void* this_arg) {
2724         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2725         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2726                 js_free(j_calls->log_meth);
2727                 FREE(j_calls);
2728         }
2729 }
2730 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
2731         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2732         const char* record_str = record;
2733         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
2734         js_invoke_function_1(j_calls->log_meth, record_conv);
2735 }
2736 static void* LDKLogger_JCalls_clone(const void* this_arg) {
2737         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2738         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2739         return (void*) this_arg;
2740 }
2741 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
2742         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2743         atomic_init(&calls->refcnt, 1);
2744         //TODO: Assign calls->o from o
2745
2746         LDKLogger ret = {
2747                 .this_arg = (void*) calls,
2748                 .log = log_LDKLogger_jcall,
2749                 .free = LDKLogger_JCalls_free,
2750         };
2751         return ret;
2752 }
2753 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
2754         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2755         *res_ptr = LDKLogger_init(o);
2756         return (long)res_ptr;
2757 }
2758 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
2759         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
2760         LDKThirtyTwoBytes a_ref;
2761         CHECK(*((uint32_t*)a) == 32);
2762         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2763         ret->a = a_ref;
2764         LDKChannelManager b_conv;
2765         b_conv.inner = (void*)(b & (~1));
2766         b_conv.is_owned = (b & 1) || (b == 0);
2767         // Warning: we need a move here but no clone is available for LDKChannelManager
2768         ret->b = b_conv;
2769         return (uint64_t)ret;
2770 }
2771 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
2772         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2773         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2774         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2775         return a_arr;
2776 }
2777 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
2778         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2779         LDKChannelManager b_var = tuple->b;
2780         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2781         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2782         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2783         return b_ref;
2784 }
2785 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
2786         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
2787 }
2788 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
2789         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2790         CHECK(val->result_ok);
2791         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2792         return res_ref;
2793 }
2794 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
2795         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2796         CHECK(!val->result_ok);
2797         LDKDecodeError err_var = (*val->contents.err);
2798         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2799         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2800         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2801         return err_ref;
2802 }
2803 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
2804         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
2805 }
2806 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
2807         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
2808         CHECK(val->result_ok);
2809         LDKChannelConfig res_var = (*val->contents.result);
2810         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2811         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2812         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2813         return res_ref;
2814 }
2815 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
2816         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
2817         CHECK(!val->result_ok);
2818         LDKDecodeError err_var = (*val->contents.err);
2819         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2820         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2821         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2822         return err_ref;
2823 }
2824 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
2825         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
2826 }
2827 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
2828         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
2829         CHECK(val->result_ok);
2830         LDKOutPoint res_var = (*val->contents.result);
2831         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2832         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2833         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2834         return res_ref;
2835 }
2836 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
2837         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
2838         CHECK(!val->result_ok);
2839         LDKDecodeError err_var = (*val->contents.err);
2840         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2841         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2842         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2843         return err_ref;
2844 }
2845 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) {
2846         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
2847 }
2848 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_ok(uint32_t arg) {
2849         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
2850         CHECK(val->result_ok);
2851         uint32_t res_conv = LDKSiPrefix_to_js((*val->contents.result));
2852         return res_conv;
2853 }
2854 void  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_err(uint32_t arg) {
2855         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
2856         CHECK(!val->result_ok);
2857         return *val->contents.err;
2858 }
2859 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_result_ok(uint32_t arg) {
2860         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
2861 }
2862 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_ok(uint32_t arg) {
2863         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
2864         CHECK(val->result_ok);
2865         LDKInvoice res_var = (*val->contents.result);
2866         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2867         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2868         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2869         return res_ref;
2870 }
2871 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
2872         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
2873         CHECK(!val->result_ok);
2874         return *val->contents.err;
2875 }
2876 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_result_ok(uint32_t arg) {
2877         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
2878 }
2879 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_ok(uint32_t arg) {
2880         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
2881         CHECK(val->result_ok);
2882         LDKSignedRawInvoice res_var = (*val->contents.result);
2883         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2884         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2885         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2886         return res_ref;
2887 }
2888 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
2889         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
2890         CHECK(!val->result_ok);
2891         return *val->contents.err;
2892 }
2893 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
2894         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
2895         LDKRawInvoice a_conv;
2896         a_conv.inner = (void*)(a & (~1));
2897         a_conv.is_owned = (a & 1) || (a == 0);
2898         a_conv = RawInvoice_clone(&a_conv);
2899         ret->a = a_conv;
2900         LDKThirtyTwoBytes b_ref;
2901         CHECK(*((uint32_t*)b) == 32);
2902         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2903         ret->b = b_ref;
2904         LDKInvoiceSignature c_conv;
2905         c_conv.inner = (void*)(c & (~1));
2906         c_conv.is_owned = (c & 1) || (c == 0);
2907         c_conv = InvoiceSignature_clone(&c_conv);
2908         ret->c = c_conv;
2909         return (uint64_t)ret;
2910 }
2911 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t ptr) {
2912         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2913         LDKRawInvoice a_var = tuple->a;
2914         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2915         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2916         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
2917         return a_ref;
2918 }
2919 int8_tArray  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t ptr) {
2920         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2921         int8_tArray b_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2922         memcpy((uint8_t*)(b_arr + 4), tuple->b.data, 32);
2923         return b_arr;
2924 }
2925 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t ptr) {
2926         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2927         LDKInvoiceSignature c_var = tuple->c;
2928         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2929         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2930         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
2931         return c_ref;
2932 }
2933 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_result_ok(uint32_t arg) {
2934         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
2935 }
2936 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_ok(uint32_t arg) {
2937         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
2938         CHECK(val->result_ok);
2939         LDKPayeePubKey res_var = (*val->contents.result);
2940         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2941         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2942         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2943         return res_ref;
2944 }
2945 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
2946         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
2947         CHECK(!val->result_ok);
2948         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2949         return err_conv;
2950 }
2951 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_PrivateRouteZ_new(uint32_tArray elems) {
2952         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
2953         ret->datalen = *((uint32_t*)elems);
2954         if (ret->datalen == 0) {
2955                 ret->data = NULL;
2956         } else {
2957                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
2958                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2959                 for (size_t i = 0; i < ret->datalen; i++) {
2960                         uint32_t arr_elem = java_elems[i];
2961                         LDKPrivateRoute arr_elem_conv;
2962                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2963                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2964                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
2965                         ret->data[i] = arr_elem_conv;
2966                 }
2967         }
2968         return (uint64_t)ret;
2969 }
2970 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
2971         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
2972         for (size_t i = 0; i < ret.datalen; i++) {
2973                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
2974         }
2975         return ret;
2976 }
2977 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_result_ok(uint32_t arg) {
2978         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
2979 }
2980 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t arg) {
2981         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
2982         CHECK(val->result_ok);
2983         LDKPositiveTimestamp res_var = (*val->contents.result);
2984         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2985         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2986         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2987         return res_ref;
2988 }
2989 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
2990         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
2991         CHECK(!val->result_ok);
2992         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
2993         return err_conv;
2994 }
2995 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_result_ok(uint32_t arg) {
2996         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
2997 }
2998 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_ok(uint32_t arg) {
2999         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3000         CHECK(val->result_ok);
3001         return *val->contents.result;
3002 }
3003 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_err(uint32_t arg) {
3004         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3005         CHECK(!val->result_ok);
3006         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3007         return err_conv;
3008 }
3009 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_result_ok(uint32_t arg) {
3010         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
3011 }
3012 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_ok(uint32_t arg) {
3013         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3014         CHECK(val->result_ok);
3015         LDKInvoice res_var = (*val->contents.result);
3016         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3017         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3018         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3019         return res_ref;
3020 }
3021 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
3022         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3023         CHECK(!val->result_ok);
3024         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3025         return err_conv;
3026 }
3027 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_result_ok(uint32_t arg) {
3028         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
3029 }
3030 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_ok(uint32_t arg) {
3031         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3032         CHECK(val->result_ok);
3033         LDKDescription res_var = (*val->contents.result);
3034         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3035         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3036         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3037         return res_ref;
3038 }
3039 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
3040         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3041         CHECK(!val->result_ok);
3042         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3043         return err_conv;
3044 }
3045 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_result_ok(uint32_t arg) {
3046         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
3047 }
3048 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_ok(uint32_t arg) {
3049         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3050         CHECK(val->result_ok);
3051         LDKExpiryTime res_var = (*val->contents.result);
3052         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3053         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3054         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3055         return res_ref;
3056 }
3057 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
3058         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3059         CHECK(!val->result_ok);
3060         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3061         return err_conv;
3062 }
3063 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_result_ok(uint32_t arg) {
3064         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
3065 }
3066 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_ok(uint32_t arg) {
3067         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3068         CHECK(val->result_ok);
3069         LDKPrivateRoute res_var = (*val->contents.result);
3070         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3071         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3072         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3073         return res_ref;
3074 }
3075 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
3076         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3077         CHECK(!val->result_ok);
3078         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3079         return err_conv;
3080 }
3081 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_result_ok(uint32_t arg) {
3082         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
3083 }
3084 jstring  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_ok(uint32_t arg) {
3085         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3086         CHECK(val->result_ok);
3087         LDKStr res_str = (*val->contents.result);
3088         jstring res_conv = str_ref_to_ts(res_str.chars, res_str.len);
3089         return res_conv;
3090 }
3091 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_err(uint32_t arg) {
3092         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3093         CHECK(!val->result_ok);
3094         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3095         return err_conv;
3096 }
3097 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3098         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
3099 }
3100 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3101         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3102         CHECK(val->result_ok);
3103         LDKChannelMonitorUpdate res_var = (*val->contents.result);
3104         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3105         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3106         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3107         return res_ref;
3108 }
3109 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
3110         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3111         CHECK(!val->result_ok);
3112         LDKDecodeError err_var = (*val->contents.err);
3113         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3114         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3115         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3116         return err_ref;
3117 }
3118 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3119         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
3120 }
3121 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3122         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3123         CHECK(val->result_ok);
3124         LDKHTLCUpdate res_var = (*val->contents.result);
3125         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3126         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3127         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3128         return res_ref;
3129 }
3130 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
3131         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3132         CHECK(!val->result_ok);
3133         LDKDecodeError err_var = (*val->contents.err);
3134         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3135         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3136         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3137         return err_ref;
3138 }
3139 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
3140         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
3141 }
3142 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
3143         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3144         CHECK(val->result_ok);
3145         return *val->contents.result;
3146 }
3147 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
3148         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3149         CHECK(!val->result_ok);
3150         LDKMonitorUpdateError err_var = (*val->contents.err);
3151         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3152         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3153         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3154         return err_ref;
3155 }
3156 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
3157         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
3158         LDKOutPoint a_conv;
3159         a_conv.inner = (void*)(a & (~1));
3160         a_conv.is_owned = (a & 1) || (a == 0);
3161         a_conv = OutPoint_clone(&a_conv);
3162         ret->a = a_conv;
3163         LDKCVec_u8Z b_ref;
3164         b_ref.datalen = *((uint32_t*)b);
3165         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3166         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3167         ret->b = b_ref;
3168         return (uint64_t)ret;
3169 }
3170 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
3171         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
3172         LDKOutPoint a_var = tuple->a;
3173         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3174         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3175         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3176         return a_ref;
3177 }
3178 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
3179         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
3180         LDKCVec_u8Z b_var = tuple->b;
3181         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3182         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
3183         return b_arr;
3184 }
3185 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
3186         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
3187         ret->a = a;
3188         LDKCVec_u8Z b_ref;
3189         b_ref.datalen = *((uint32_t*)b);
3190         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3191         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3192         ret->b = b_ref;
3193         return (uint64_t)ret;
3194 }
3195 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_a(uint32_t ptr) {
3196         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
3197         return tuple->a;
3198 }
3199 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_b(uint32_t ptr) {
3200         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
3201         LDKCVec_u8Z b_var = tuple->b;
3202         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3203         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
3204         return b_arr;
3205 }
3206 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
3207         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
3208         ret->datalen = *((uint32_t*)elems);
3209         if (ret->datalen == 0) {
3210                 ret->data = NULL;
3211         } else {
3212                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
3213                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3214                 for (size_t i = 0; i < ret->datalen; i++) {
3215                         uint32_t arr_elem = java_elems[i];
3216                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
3217                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
3218                         ret->data[i] = arr_elem_conv;
3219                 }
3220         }
3221         return (uint64_t)ret;
3222 }
3223 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
3224         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
3225         for (size_t i = 0; i < ret.datalen; i++) {
3226                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
3227         }
3228         return ret;
3229 }
3230 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
3231         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
3232         LDKThirtyTwoBytes a_ref;
3233         CHECK(*((uint32_t*)a) == 32);
3234         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3235         ret->a = a_ref;
3236         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
3237         b_constr.datalen = *((uint32_t*)b);
3238         if (b_constr.datalen > 0)
3239                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
3240         else
3241                 b_constr.data = NULL;
3242         uint32_t* b_vals = (uint32_t*)(b + 4);
3243         for (size_t e = 0; e < b_constr.datalen; e++) {
3244                 uint32_t b_conv_30 = b_vals[e];
3245                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
3246                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
3247                 b_constr.data[e] = b_conv_30_conv;
3248         }
3249         ret->b = b_constr;
3250         return (uint64_t)ret;
3251 }
3252 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t ptr) {
3253         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
3254         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3255         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
3256         return a_arr;
3257 }
3258 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t ptr) {
3259         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
3260         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
3261         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3262         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
3263         for (size_t e = 0; e < b_var.datalen; e++) {
3264                 uint64_t b_conv_30_ref = (uint64_t)(&b_var.data[e]) | 1;
3265                 b_arr_ptr[e] = b_conv_30_ref;
3266         }
3267         return b_arr;
3268 }
3269 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
3270         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
3271         ret->datalen = *((uint32_t*)elems);
3272         if (ret->datalen == 0) {
3273                 ret->data = NULL;
3274         } else {
3275                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
3276                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3277                 for (size_t i = 0; i < ret->datalen; i++) {
3278                         uint32_t arr_elem = java_elems[i];
3279                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
3280                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
3281                         ret->data[i] = arr_elem_conv;
3282                 }
3283         }
3284         return (uint64_t)ret;
3285 }
3286 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
3287         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 };
3288         for (size_t i = 0; i < ret.datalen; i++) {
3289                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
3290         }
3291         return ret;
3292 }
3293 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
3294         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
3295         switch(obj->tag) {
3296                 case LDKEvent_FundingGenerationReady: {
3297                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3298                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
3299                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3300                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3301                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
3302                         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;
3303                 }
3304                 case LDKEvent_PaymentReceived: {
3305                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3306                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
3307                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3308                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_received.payment_preimage.data, 32);
3309                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3310                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32);
3311                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) payment_preimage_arr; (void) payment_secret_arr; (void) obj->payment_received.amt; (void) obj->payment_received.user_payment_id;
3312                 }
3313                 case LDKEvent_PaymentSent: {
3314                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3315                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
3316                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
3317                 }
3318                 case LDKEvent_PaymentFailed: {
3319                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3320                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
3321                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
3322                 }
3323                 case LDKEvent_PendingHTLCsForwardable: {
3324                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
3325                 }
3326                 case LDKEvent_SpendableOutputs: {
3327                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3328                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3329                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
3330                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3331                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
3332                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3333                         }
3334                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
3335                 }
3336                 default: abort();
3337         }
3338 }
3339 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
3340         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
3341         ret->datalen = *((uint32_t*)elems);
3342         if (ret->datalen == 0) {
3343                 ret->data = NULL;
3344         } else {
3345                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
3346                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3347                 for (size_t i = 0; i < ret->datalen; i++) {
3348                         uint32_t arr_elem = java_elems[i];
3349                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
3350                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
3351                         ret->data[i] = arr_elem_conv;
3352                 }
3353         }
3354         return (uint64_t)ret;
3355 }
3356 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
3357         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
3358         for (size_t i = 0; i < ret.datalen; i++) {
3359                 ret.data[i] = Event_clone(&orig->data[i]);
3360         }
3361         return ret;
3362 }
3363 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
3364         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
3365         ret->a = a;
3366         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
3367         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
3368         ret->b = b_conv;
3369         return (uint64_t)ret;
3370 }
3371 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
3372         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
3373         return tuple->a;
3374 }
3375 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
3376         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
3377         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
3378         return (uint64_t)b_ref;
3379 }
3380 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
3381         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
3382         ret->datalen = *((uint32_t*)elems);
3383         if (ret->datalen == 0) {
3384                 ret->data = NULL;
3385         } else {
3386                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
3387                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3388                 for (size_t i = 0; i < ret->datalen; i++) {
3389                         uint32_t arr_elem = java_elems[i];
3390                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
3391                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
3392                         ret->data[i] = arr_elem_conv;
3393                 }
3394         }
3395         return (uint64_t)ret;
3396 }
3397 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
3398         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
3399         for (size_t i = 0; i < ret.datalen; i++) {
3400                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
3401         }
3402         return ret;
3403 }
3404 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
3405         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
3406         LDKThirtyTwoBytes a_ref;
3407         CHECK(*((uint32_t*)a) == 32);
3408         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3409         ret->a = a_ref;
3410         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
3411         b_constr.datalen = *((uint32_t*)b);
3412         if (b_constr.datalen > 0)
3413                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
3414         else
3415                 b_constr.data = NULL;
3416         uint32_t* b_vals = (uint32_t*)(b + 4);
3417         for (size_t z = 0; z < b_constr.datalen; z++) {
3418                 uint32_t b_conv_25 = b_vals[z];
3419                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
3420                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
3421                 b_constr.data[z] = b_conv_25_conv;
3422         }
3423         ret->b = b_constr;
3424         return (uint64_t)ret;
3425 }
3426 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
3427         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
3428         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3429         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
3430         return a_arr;
3431 }
3432 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
3433         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
3434         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
3435         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3436         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
3437         for (size_t z = 0; z < b_var.datalen; z++) {
3438                 uint64_t b_conv_25_ref = (uint64_t)(&b_var.data[z]) | 1;
3439                 b_arr_ptr[z] = b_conv_25_ref;
3440         }
3441         return b_arr;
3442 }
3443 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
3444         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
3445         ret->datalen = *((uint32_t*)elems);
3446         if (ret->datalen == 0) {
3447                 ret->data = NULL;
3448         } else {
3449                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
3450                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3451                 for (size_t i = 0; i < ret->datalen; i++) {
3452                         uint32_t arr_elem = java_elems[i];
3453                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
3454                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
3455                         ret->data[i] = arr_elem_conv;
3456                 }
3457         }
3458         return (uint64_t)ret;
3459 }
3460 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
3461         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 };
3462         for (size_t i = 0; i < ret.datalen; i++) {
3463                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
3464         }
3465         return ret;
3466 }
3467 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
3468         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
3469 }
3470 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
3471         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
3472         CHECK(val->result_ok);
3473         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
3474         return res_ref;
3475 }
3476 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
3477         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
3478         CHECK(!val->result_ok);
3479         LDKDecodeError err_var = (*val->contents.err);
3480         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3481         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3482         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3483         return err_ref;
3484 }
3485 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
3486         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3487 }
3488 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
3489         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
3490         CHECK(val->result_ok);
3491         return *val->contents.result;
3492 }
3493 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
3494         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
3495         CHECK(!val->result_ok);
3496         LDKLightningError err_var = (*val->contents.err);
3497         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3498         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3499         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3500         return err_ref;
3501 }
3502 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
3503         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
3504         LDKChannelAnnouncement a_conv;
3505         a_conv.inner = (void*)(a & (~1));
3506         a_conv.is_owned = (a & 1) || (a == 0);
3507         a_conv = ChannelAnnouncement_clone(&a_conv);
3508         ret->a = a_conv;
3509         LDKChannelUpdate b_conv;
3510         b_conv.inner = (void*)(b & (~1));
3511         b_conv.is_owned = (b & 1) || (b == 0);
3512         b_conv = ChannelUpdate_clone(&b_conv);
3513         ret->b = b_conv;
3514         LDKChannelUpdate c_conv;
3515         c_conv.inner = (void*)(c & (~1));
3516         c_conv.is_owned = (c & 1) || (c == 0);
3517         c_conv = ChannelUpdate_clone(&c_conv);
3518         ret->c = c_conv;
3519         return (uint64_t)ret;
3520 }
3521 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t ptr) {
3522         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3523         LDKChannelAnnouncement a_var = tuple->a;
3524         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3525         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3526         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3527         return a_ref;
3528 }
3529 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t ptr) {
3530         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3531         LDKChannelUpdate b_var = tuple->b;
3532         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3533         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3534         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
3535         return b_ref;
3536 }
3537 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t ptr) {
3538         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3539         LDKChannelUpdate c_var = tuple->c;
3540         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3541         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3542         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
3543         return c_ref;
3544 }
3545 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
3546         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
3547         ret->datalen = *((uint32_t*)elems);
3548         if (ret->datalen == 0) {
3549                 ret->data = NULL;
3550         } else {
3551                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
3552                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3553                 for (size_t i = 0; i < ret->datalen; i++) {
3554                         uint32_t arr_elem = java_elems[i];
3555                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
3556                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
3557                         ret->data[i] = arr_elem_conv;
3558                 }
3559         }
3560         return (uint64_t)ret;
3561 }
3562 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3563         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3564         for (size_t i = 0; i < ret.datalen; i++) {
3565                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3566         }
3567         return ret;
3568 }
3569 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
3570         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
3571         ret->datalen = *((uint32_t*)elems);
3572         if (ret->datalen == 0) {
3573                 ret->data = NULL;
3574         } else {
3575                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
3576                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3577                 for (size_t i = 0; i < ret->datalen; i++) {
3578                         uint32_t arr_elem = java_elems[i];
3579                         LDKNodeAnnouncement arr_elem_conv;
3580                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3581                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3582                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
3583                         ret->data[i] = arr_elem_conv;
3584                 }
3585         }
3586         return (uint64_t)ret;
3587 }
3588 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3589         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3590         for (size_t i = 0; i < ret.datalen; i++) {
3591                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3592         }
3593         return ret;
3594 }
3595 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
3596         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
3597 }
3598 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
3599         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
3600         CHECK(val->result_ok);
3601         return *val->contents.result;
3602 }
3603 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
3604         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
3605         CHECK(!val->result_ok);
3606         LDKLightningError err_var = (*val->contents.err);
3607         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3608         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3609         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3610         return err_ref;
3611 }
3612 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
3613         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
3614 }
3615 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
3616         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
3617         CHECK(val->result_ok);
3618         LDKCVec_u8Z res_var = (*val->contents.result);
3619         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3620         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
3621         return res_arr;
3622 }
3623 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
3624         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
3625         CHECK(!val->result_ok);
3626         LDKPeerHandleError err_var = (*val->contents.err);
3627         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3628         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3629         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3630         return err_ref;
3631 }
3632 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
3633         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
3634 }
3635 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
3636         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
3637         CHECK(val->result_ok);
3638         return *val->contents.result;
3639 }
3640 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
3641         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
3642         CHECK(!val->result_ok);
3643         LDKPeerHandleError err_var = (*val->contents.err);
3644         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3645         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3646         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3647         return err_ref;
3648 }
3649 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
3650         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
3651 }
3652 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
3653         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
3654         CHECK(val->result_ok);
3655         return *val->contents.result;
3656 }
3657 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
3658         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
3659         CHECK(!val->result_ok);
3660         LDKPeerHandleError err_var = (*val->contents.err);
3661         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3662         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3663         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3664         return err_ref;
3665 }
3666 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
3667         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
3668 }
3669 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
3670         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
3671         CHECK(val->result_ok);
3672         LDKDirectionalChannelInfo res_var = (*val->contents.result);
3673         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3674         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3675         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3676         return res_ref;
3677 }
3678 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
3679         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
3680         CHECK(!val->result_ok);
3681         LDKDecodeError err_var = (*val->contents.err);
3682         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3683         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3684         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3685         return err_ref;
3686 }
3687 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
3688         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
3689 }
3690 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
3691         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
3692         CHECK(val->result_ok);
3693         LDKChannelInfo res_var = (*val->contents.result);
3694         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3695         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3696         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3697         return res_ref;
3698 }
3699 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
3700         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
3701         CHECK(!val->result_ok);
3702         LDKDecodeError err_var = (*val->contents.err);
3703         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3704         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3705         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3706         return err_ref;
3707 }
3708 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
3709         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
3710 }
3711 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
3712         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
3713         CHECK(val->result_ok);
3714         LDKRoutingFees res_var = (*val->contents.result);
3715         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3716         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3717         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3718         return res_ref;
3719 }
3720 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
3721         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
3722         CHECK(!val->result_ok);
3723         LDKDecodeError err_var = (*val->contents.err);
3724         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3725         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3726         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3727         return err_ref;
3728 }
3729 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
3730         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
3731 }
3732 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
3733         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
3734         CHECK(val->result_ok);
3735         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
3736         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3737         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3738         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3739         return res_ref;
3740 }
3741 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
3742         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
3743         CHECK(!val->result_ok);
3744         LDKDecodeError err_var = (*val->contents.err);
3745         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3746         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3747         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3748         return err_ref;
3749 }
3750 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
3751         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
3752         ret->datalen = *((uint32_t*)elems);
3753         if (ret->datalen == 0) {
3754                 ret->data = NULL;
3755         } else {
3756                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
3757                 int64_t *java_elems = (int64_t*)(elems + 4);
3758                 for (size_t i = 0; i < ret->datalen; i++) {
3759                         ret->data[i] = java_elems[i];
3760                 }
3761         }
3762         return (uint64_t)ret;
3763 }
3764 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3765         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3766         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3767         return ret;
3768 }
3769 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
3770         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
3771 }
3772 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
3773         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3774         CHECK(val->result_ok);
3775         LDKNodeInfo res_var = (*val->contents.result);
3776         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3777         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3778         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3779         return res_ref;
3780 }
3781 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
3782         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3783         CHECK(!val->result_ok);
3784         LDKDecodeError err_var = (*val->contents.err);
3785         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3786         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3787         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3788         return err_ref;
3789 }
3790 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
3791         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
3792 }
3793 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
3794         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3795         CHECK(val->result_ok);
3796         LDKNetworkGraph res_var = (*val->contents.result);
3797         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3798         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3799         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3800         return res_ref;
3801 }
3802 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
3803         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3804         CHECK(!val->result_ok);
3805         LDKDecodeError err_var = (*val->contents.err);
3806         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3807         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3808         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3809         return err_ref;
3810 }
3811 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
3812         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3813 }
3814 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
3815         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3816         CHECK(val->result_ok);
3817         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3818         return res_ref;
3819 }
3820 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
3821         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3822         CHECK(!val->result_ok);
3823         return *val->contents.err;
3824 }
3825 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
3826         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3827 }
3828 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
3829         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3830         CHECK(val->result_ok);
3831         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3832         *res_conv = (*val->contents.result);
3833         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3834         return (uint64_t)res_conv;
3835 }
3836 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
3837         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3838         CHECK(!val->result_ok);
3839         LDKDecodeError err_var = (*val->contents.err);
3840         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3841         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3842         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3843         return err_ref;
3844 }
3845 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_result_ok(uint32_t arg) {
3846         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
3847 }
3848 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_ok(uint32_t arg) {
3849         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
3850         CHECK(val->result_ok);
3851         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3852         return res_ref;
3853 }
3854 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_err(uint32_t arg) {
3855         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
3856         CHECK(!val->result_ok);
3857         LDKDecodeError err_var = (*val->contents.err);
3858         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3859         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3860         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3861         return err_ref;
3862 }
3863 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
3864         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3865         ret->datalen = *((uint32_t*)elems);
3866         if (ret->datalen == 0) {
3867                 ret->data = NULL;
3868         } else {
3869                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3870                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3871                 for (size_t i = 0; i < ret->datalen; i++) {
3872                         uint32_t arr_elem = java_elems[i];
3873                         LDKUpdateAddHTLC arr_elem_conv;
3874                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3875                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3876                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3877                         ret->data[i] = arr_elem_conv;
3878                 }
3879         }
3880         return (uint64_t)ret;
3881 }
3882 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3883         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3884         for (size_t i = 0; i < ret.datalen; i++) {
3885                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3886         }
3887         return ret;
3888 }
3889 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
3890         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3891         ret->datalen = *((uint32_t*)elems);
3892         if (ret->datalen == 0) {
3893                 ret->data = NULL;
3894         } else {
3895                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3896                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3897                 for (size_t i = 0; i < ret->datalen; i++) {
3898                         uint32_t arr_elem = java_elems[i];
3899                         LDKUpdateFulfillHTLC arr_elem_conv;
3900                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3901                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3902                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3903                         ret->data[i] = arr_elem_conv;
3904                 }
3905         }
3906         return (uint64_t)ret;
3907 }
3908 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
3909         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
3910         for (size_t i = 0; i < ret.datalen; i++) {
3911                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
3912         }
3913         return ret;
3914 }
3915 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
3916         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
3917         ret->datalen = *((uint32_t*)elems);
3918         if (ret->datalen == 0) {
3919                 ret->data = NULL;
3920         } else {
3921                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
3922                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3923                 for (size_t i = 0; i < ret->datalen; i++) {
3924                         uint32_t arr_elem = java_elems[i];
3925                         LDKUpdateFailHTLC arr_elem_conv;
3926                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3927                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3928                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3929                         ret->data[i] = arr_elem_conv;
3930                 }
3931         }
3932         return (uint64_t)ret;
3933 }
3934 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
3935         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
3936         for (size_t i = 0; i < ret.datalen; i++) {
3937                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
3938         }
3939         return ret;
3940 }
3941 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
3942         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
3943         ret->datalen = *((uint32_t*)elems);
3944         if (ret->datalen == 0) {
3945                 ret->data = NULL;
3946         } else {
3947                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
3948                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3949                 for (size_t i = 0; i < ret->datalen; i++) {
3950                         uint32_t arr_elem = java_elems[i];
3951                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3952                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3953                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3954                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3955                         ret->data[i] = arr_elem_conv;
3956                 }
3957         }
3958         return (uint64_t)ret;
3959 }
3960 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
3961         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
3962         for (size_t i = 0; i < ret.datalen; i++) {
3963                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
3964         }
3965         return ret;
3966 }
3967 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
3968         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
3969 }
3970 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
3971         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3972         CHECK(val->result_ok);
3973         LDKAcceptChannel res_var = (*val->contents.result);
3974         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3975         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3976         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3977         return res_ref;
3978 }
3979 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
3980         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3981         CHECK(!val->result_ok);
3982         LDKDecodeError err_var = (*val->contents.err);
3983         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3984         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3985         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3986         return err_ref;
3987 }
3988 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
3989         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
3990 }
3991 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
3992         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3993         CHECK(val->result_ok);
3994         LDKAnnouncementSignatures res_var = (*val->contents.result);
3995         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3996         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3997         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3998         return res_ref;
3999 }
4000 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
4001         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4002         CHECK(!val->result_ok);
4003         LDKDecodeError err_var = (*val->contents.err);
4004         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4005         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4006         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4007         return err_ref;
4008 }
4009 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
4010         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
4011 }
4012 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
4013         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4014         CHECK(val->result_ok);
4015         LDKChannelReestablish res_var = (*val->contents.result);
4016         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4017         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4018         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4019         return res_ref;
4020 }
4021 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
4022         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4023         CHECK(!val->result_ok);
4024         LDKDecodeError err_var = (*val->contents.err);
4025         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4026         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4027         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4028         return err_ref;
4029 }
4030 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4031         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
4032 }
4033 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4034         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4035         CHECK(val->result_ok);
4036         LDKClosingSigned res_var = (*val->contents.result);
4037         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4038         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4039         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4040         return res_ref;
4041 }
4042 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
4043         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4044         CHECK(!val->result_ok);
4045         LDKDecodeError err_var = (*val->contents.err);
4046         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4047         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4048         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4049         return err_ref;
4050 }
4051 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
4052         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
4053 }
4054 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
4055         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4056         CHECK(val->result_ok);
4057         LDKCommitmentSigned res_var = (*val->contents.result);
4058         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4059         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4060         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4061         return res_ref;
4062 }
4063 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
4064         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4065         CHECK(!val->result_ok);
4066         LDKDecodeError err_var = (*val->contents.err);
4067         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4068         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4069         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4070         return err_ref;
4071 }
4072 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
4073         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
4074 }
4075 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
4076         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4077         CHECK(val->result_ok);
4078         LDKFundingCreated res_var = (*val->contents.result);
4079         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4080         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4081         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4082         return res_ref;
4083 }
4084 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
4085         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4086         CHECK(!val->result_ok);
4087         LDKDecodeError err_var = (*val->contents.err);
4088         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4089         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4090         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4091         return err_ref;
4092 }
4093 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4094         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
4095 }
4096 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4097         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4098         CHECK(val->result_ok);
4099         LDKFundingSigned res_var = (*val->contents.result);
4100         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4101         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4102         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4103         return res_ref;
4104 }
4105 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
4106         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4107         CHECK(!val->result_ok);
4108         LDKDecodeError err_var = (*val->contents.err);
4109         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4110         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4111         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4112         return err_ref;
4113 }
4114 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
4115         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
4116 }
4117 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
4118         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4119         CHECK(val->result_ok);
4120         LDKFundingLocked res_var = (*val->contents.result);
4121         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4122         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4123         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4124         return res_ref;
4125 }
4126 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
4127         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4128         CHECK(!val->result_ok);
4129         LDKDecodeError err_var = (*val->contents.err);
4130         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4131         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4132         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4133         return err_ref;
4134 }
4135 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
4136         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
4137 }
4138 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
4139         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4140         CHECK(val->result_ok);
4141         LDKInit res_var = (*val->contents.result);
4142         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4143         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4144         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4145         return res_ref;
4146 }
4147 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
4148         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4149         CHECK(!val->result_ok);
4150         LDKDecodeError err_var = (*val->contents.err);
4151         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4152         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4153         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4154         return err_ref;
4155 }
4156 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
4157         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
4158 }
4159 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
4160         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4161         CHECK(val->result_ok);
4162         LDKOpenChannel res_var = (*val->contents.result);
4163         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4164         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4165         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4166         return res_ref;
4167 }
4168 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
4169         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4170         CHECK(!val->result_ok);
4171         LDKDecodeError err_var = (*val->contents.err);
4172         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4173         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4174         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4175         return err_ref;
4176 }
4177 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
4178         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
4179 }
4180 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
4181         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4182         CHECK(val->result_ok);
4183         LDKRevokeAndACK res_var = (*val->contents.result);
4184         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4185         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4186         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4187         return res_ref;
4188 }
4189 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
4190         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4191         CHECK(!val->result_ok);
4192         LDKDecodeError err_var = (*val->contents.err);
4193         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4194         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4195         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4196         return err_ref;
4197 }
4198 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
4199         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
4200 }
4201 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
4202         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4203         CHECK(val->result_ok);
4204         LDKShutdown res_var = (*val->contents.result);
4205         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4206         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4207         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4208         return res_ref;
4209 }
4210 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
4211         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4212         CHECK(!val->result_ok);
4213         LDKDecodeError err_var = (*val->contents.err);
4214         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4215         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4216         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4217         return err_ref;
4218 }
4219 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4220         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
4221 }
4222 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4223         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4224         CHECK(val->result_ok);
4225         LDKUpdateFailHTLC res_var = (*val->contents.result);
4226         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4227         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4228         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4229         return res_ref;
4230 }
4231 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
4232         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4233         CHECK(!val->result_ok);
4234         LDKDecodeError err_var = (*val->contents.err);
4235         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4236         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4237         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4238         return err_ref;
4239 }
4240 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4241         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
4242 }
4243 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4244         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4245         CHECK(val->result_ok);
4246         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
4247         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4248         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4249         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4250         return res_ref;
4251 }
4252 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
4253         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4254         CHECK(!val->result_ok);
4255         LDKDecodeError err_var = (*val->contents.err);
4256         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4257         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4258         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4259         return err_ref;
4260 }
4261 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
4262         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
4263 }
4264 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
4265         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4266         CHECK(val->result_ok);
4267         LDKUpdateFee res_var = (*val->contents.result);
4268         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4269         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4270         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4271         return res_ref;
4272 }
4273 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
4274         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4275         CHECK(!val->result_ok);
4276         LDKDecodeError err_var = (*val->contents.err);
4277         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4278         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4279         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4280         return err_ref;
4281 }
4282 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4283         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
4284 }
4285 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4286         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4287         CHECK(val->result_ok);
4288         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
4289         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4290         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4291         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4292         return res_ref;
4293 }
4294 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
4295         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4296         CHECK(!val->result_ok);
4297         LDKDecodeError err_var = (*val->contents.err);
4298         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4299         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4300         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4301         return err_ref;
4302 }
4303 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4304         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
4305 }
4306 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4307         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4308         CHECK(val->result_ok);
4309         LDKUpdateAddHTLC res_var = (*val->contents.result);
4310         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4311         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4312         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4313         return res_ref;
4314 }
4315 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
4316         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4317         CHECK(!val->result_ok);
4318         LDKDecodeError err_var = (*val->contents.err);
4319         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4320         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4321         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4322         return err_ref;
4323 }
4324 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
4325         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
4326 }
4327 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
4328         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4329         CHECK(val->result_ok);
4330         LDKPing res_var = (*val->contents.result);
4331         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4332         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4333         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4334         return res_ref;
4335 }
4336 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
4337         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4338         CHECK(!val->result_ok);
4339         LDKDecodeError err_var = (*val->contents.err);
4340         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4341         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4342         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4343         return err_ref;
4344 }
4345 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
4346         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
4347 }
4348 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
4349         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4350         CHECK(val->result_ok);
4351         LDKPong res_var = (*val->contents.result);
4352         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4353         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4354         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4355         return res_ref;
4356 }
4357 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
4358         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4359         CHECK(!val->result_ok);
4360         LDKDecodeError err_var = (*val->contents.err);
4361         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4362         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4363         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4364         return err_ref;
4365 }
4366 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4367         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4368 }
4369 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4370         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4371         CHECK(val->result_ok);
4372         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
4373         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4374         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4375         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4376         return res_ref;
4377 }
4378 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4379         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4380         CHECK(!val->result_ok);
4381         LDKDecodeError err_var = (*val->contents.err);
4382         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4383         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4384         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4385         return err_ref;
4386 }
4387 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4388         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4389 }
4390 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4391         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4392         CHECK(val->result_ok);
4393         LDKChannelAnnouncement res_var = (*val->contents.result);
4394         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4395         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4396         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4397         return res_ref;
4398 }
4399 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4400         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4401         CHECK(!val->result_ok);
4402         LDKDecodeError err_var = (*val->contents.err);
4403         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4404         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4405         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4406         return err_ref;
4407 }
4408 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
4409         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
4410 }
4411 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
4412         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4413         CHECK(val->result_ok);
4414         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
4415         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4416         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4417         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4418         return res_ref;
4419 }
4420 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
4421         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4422         CHECK(!val->result_ok);
4423         LDKDecodeError err_var = (*val->contents.err);
4424         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4425         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4426         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4427         return err_ref;
4428 }
4429 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
4430         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
4431 }
4432 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
4433         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4434         CHECK(val->result_ok);
4435         LDKChannelUpdate res_var = (*val->contents.result);
4436         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4437         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4438         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4439         return res_ref;
4440 }
4441 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
4442         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4443         CHECK(!val->result_ok);
4444         LDKDecodeError err_var = (*val->contents.err);
4445         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4446         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4447         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4448         return err_ref;
4449 }
4450 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
4451         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
4452 }
4453 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
4454         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4455         CHECK(val->result_ok);
4456         LDKErrorMessage res_var = (*val->contents.result);
4457         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4458         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4459         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4460         return res_ref;
4461 }
4462 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
4463         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4464         CHECK(!val->result_ok);
4465         LDKDecodeError err_var = (*val->contents.err);
4466         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4467         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4468         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4469         return err_ref;
4470 }
4471 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4472         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4473 }
4474 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4475         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4476         CHECK(val->result_ok);
4477         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
4478         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4479         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4480         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4481         return res_ref;
4482 }
4483 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4484         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4485         CHECK(!val->result_ok);
4486         LDKDecodeError err_var = (*val->contents.err);
4487         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4488         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4489         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4490         return err_ref;
4491 }
4492 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4493         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4494 }
4495 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4496         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4497         CHECK(val->result_ok);
4498         LDKNodeAnnouncement res_var = (*val->contents.result);
4499         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4500         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4501         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4502         return res_ref;
4503 }
4504 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4505         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4506         CHECK(!val->result_ok);
4507         LDKDecodeError err_var = (*val->contents.err);
4508         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4509         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4510         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4511         return err_ref;
4512 }
4513 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
4514         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
4515 }
4516 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
4517         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4518         CHECK(val->result_ok);
4519         LDKQueryShortChannelIds res_var = (*val->contents.result);
4520         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4521         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4522         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4523         return res_ref;
4524 }
4525 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
4526         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4527         CHECK(!val->result_ok);
4528         LDKDecodeError err_var = (*val->contents.err);
4529         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4530         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4531         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4532         return err_ref;
4533 }
4534 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
4535         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
4536 }
4537 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
4538         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4539         CHECK(val->result_ok);
4540         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
4541         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4542         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4543         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4544         return res_ref;
4545 }
4546 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
4547         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4548         CHECK(!val->result_ok);
4549         LDKDecodeError err_var = (*val->contents.err);
4550         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4551         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4552         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4553         return err_ref;
4554 }
4555 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
4556         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
4557 }
4558 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
4559         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4560         CHECK(val->result_ok);
4561         LDKQueryChannelRange res_var = (*val->contents.result);
4562         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4563         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4564         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4565         return res_ref;
4566 }
4567 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
4568         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4569         CHECK(!val->result_ok);
4570         LDKDecodeError err_var = (*val->contents.err);
4571         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4572         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4573         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4574         return err_ref;
4575 }
4576 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
4577         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
4578 }
4579 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
4580         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4581         CHECK(val->result_ok);
4582         LDKReplyChannelRange res_var = (*val->contents.result);
4583         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4584         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4585         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4586         return res_ref;
4587 }
4588 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
4589         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4590         CHECK(!val->result_ok);
4591         LDKDecodeError err_var = (*val->contents.err);
4592         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4593         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4594         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4595         return err_ref;
4596 }
4597 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
4598         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
4599 }
4600 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
4601         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4602         CHECK(val->result_ok);
4603         LDKGossipTimestampFilter res_var = (*val->contents.result);
4604         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4605         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4606         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4607         return res_ref;
4608 }
4609 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
4610         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4611         CHECK(!val->result_ok);
4612         LDKDecodeError err_var = (*val->contents.err);
4613         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4614         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4615         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4616         return err_ref;
4617 }
4618 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
4619         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
4620         switch(obj->tag) {
4621                 case LDKSignOrCreationError_SignError: {
4622                         return 0 /* LDKSignOrCreationError - SignError */;
4623                 }
4624                 case LDKSignOrCreationError_CreationError: {
4625                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
4626                         return 0 /* LDKSignOrCreationError - CreationError */; (void) creation_error_conv;
4627                 }
4628                 default: abort();
4629         }
4630 }
4631 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_result_ok(uint32_t arg) {
4632         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
4633 }
4634 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t arg) {
4635         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
4636         CHECK(val->result_ok);
4637         LDKInvoice res_var = (*val->contents.result);
4638         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4639         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4640         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4641         return res_ref;
4642 }
4643 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
4644         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
4645         CHECK(!val->result_ok);
4646         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4647         return err_ref;
4648 }
4649 typedef struct LDKMessageSendEventsProvider_JCalls {
4650         atomic_size_t refcnt;
4651         uint32_t get_and_clear_pending_msg_events_meth;
4652 } LDKMessageSendEventsProvider_JCalls;
4653 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
4654         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4655         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4656                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
4657                 FREE(j_calls);
4658         }
4659 }
4660 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
4661         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4662         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
4663         LDKCVec_MessageSendEventZ ret_constr;
4664         ret_constr.datalen = *((uint32_t*)ret);
4665         if (ret_constr.datalen > 0)
4666                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4667         else
4668                 ret_constr.data = NULL;
4669         uint32_t* ret_vals = (uint32_t*)(ret + 4);
4670         for (size_t s = 0; s < ret_constr.datalen; s++) {
4671                 uint32_t ret_conv_18 = ret_vals[s];
4672                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
4673                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
4674                 ret_constr.data[s] = ret_conv_18_conv;
4675         }
4676         return ret_constr;
4677 }
4678 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
4679         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4680         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4681         return (void*) this_arg;
4682 }
4683 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
4684         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
4685         atomic_init(&calls->refcnt, 1);
4686         //TODO: Assign calls->o from o
4687
4688         LDKMessageSendEventsProvider ret = {
4689                 .this_arg = (void*) calls,
4690                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
4691                 .free = LDKMessageSendEventsProvider_JCalls_free,
4692         };
4693         return ret;
4694 }
4695 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4696         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
4697         *res_ptr = LDKMessageSendEventsProvider_init(o);
4698         return (long)res_ptr;
4699 }
4700 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
4701         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
4702         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
4703         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4704         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4705         for (size_t s = 0; s < ret_var.datalen; s++) {
4706                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
4707                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
4708                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
4709                 ret_arr_ptr[s] = ret_conv_18_ref;
4710         }
4711         FREE(ret_var.data);
4712         return ret_arr;
4713 }
4714
4715 typedef struct LDKEventHandler_JCalls {
4716         atomic_size_t refcnt;
4717         uint32_t handle_event_meth;
4718 } LDKEventHandler_JCalls;
4719 static void LDKEventHandler_JCalls_free(void* this_arg) {
4720         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4721         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4722                 js_free(j_calls->handle_event_meth);
4723                 FREE(j_calls);
4724         }
4725 }
4726 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
4727         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4728         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
4729         *event_copy = event;
4730         uint64_t event_ref = (uint64_t)event_copy;
4731         js_invoke_function_1(j_calls->handle_event_meth, event_ref);
4732 }
4733 static void* LDKEventHandler_JCalls_clone(const void* this_arg) {
4734         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4735         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4736         return (void*) this_arg;
4737 }
4738 static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) {
4739         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
4740         atomic_init(&calls->refcnt, 1);
4741         //TODO: Assign calls->o from o
4742
4743         LDKEventHandler ret = {
4744                 .this_arg = (void*) calls,
4745                 .handle_event = handle_event_LDKEventHandler_jcall,
4746                 .free = LDKEventHandler_JCalls_free,
4747         };
4748         return ret;
4749 }
4750 long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS Object Reference */void* o) {
4751         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
4752         *res_ptr = LDKEventHandler_init(o);
4753         return (long)res_ptr;
4754 }
4755 void  __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
4756         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
4757         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
4758         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
4759 }
4760
4761 typedef struct LDKEventsProvider_JCalls {
4762         atomic_size_t refcnt;
4763         uint32_t process_pending_events_meth;
4764 } LDKEventsProvider_JCalls;
4765 static void LDKEventsProvider_JCalls_free(void* this_arg) {
4766         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4767         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4768                 js_free(j_calls->process_pending_events_meth);
4769                 FREE(j_calls);
4770         }
4771 }
4772 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
4773         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4774         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
4775         *ret = handler;
4776         js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)ret);
4777 }
4778 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
4779         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4780         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4781         return (void*) this_arg;
4782 }
4783 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
4784         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
4785         atomic_init(&calls->refcnt, 1);
4786         //TODO: Assign calls->o from o
4787
4788         LDKEventsProvider ret = {
4789                 .this_arg = (void*) calls,
4790                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
4791                 .free = LDKEventsProvider_JCalls_free,
4792         };
4793         return ret;
4794 }
4795 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4796         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4797         *res_ptr = LDKEventsProvider_init(o);
4798         return (long)res_ptr;
4799 }
4800 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
4801         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
4802         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
4803         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
4804 }
4805
4806 typedef struct LDKAccess_JCalls {
4807         atomic_size_t refcnt;
4808         uint32_t get_utxo_meth;
4809 } LDKAccess_JCalls;
4810 static void LDKAccess_JCalls_free(void* this_arg) {
4811         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4812         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4813                 js_free(j_calls->get_utxo_meth);
4814                 FREE(j_calls);
4815         }
4816 }
4817 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4818         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4819         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4820         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4821         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4822         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4823         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
4824         return ret_conv;
4825 }
4826 static void* LDKAccess_JCalls_clone(const void* this_arg) {
4827         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4828         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4829         return (void*) this_arg;
4830 }
4831 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4832         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4833         atomic_init(&calls->refcnt, 1);
4834         //TODO: Assign calls->o from o
4835
4836         LDKAccess ret = {
4837                 .this_arg = (void*) calls,
4838                 .get_utxo = get_utxo_LDKAccess_jcall,
4839                 .free = LDKAccess_JCalls_free,
4840         };
4841         return ret;
4842 }
4843 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4844         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4845         *res_ptr = LDKAccess_init(o);
4846         return (long)res_ptr;
4847 }
4848 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4849         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
4850         unsigned char genesis_hash_arr[32];
4851         CHECK(*((uint32_t*)genesis_hash) == 32);
4852         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4853         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4854         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4855         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4856         return (uint64_t)ret_conv;
4857 }
4858
4859 typedef struct LDKListen_JCalls {
4860         atomic_size_t refcnt;
4861         uint32_t block_connected_meth;
4862         uint32_t block_disconnected_meth;
4863 } LDKListen_JCalls;
4864 static void LDKListen_JCalls_free(void* this_arg) {
4865         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4866         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4867                 js_free(j_calls->block_connected_meth);
4868                 js_free(j_calls->block_disconnected_meth);
4869                 FREE(j_calls);
4870         }
4871 }
4872 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
4873         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4874         LDKu8slice block_var = block;
4875         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4876         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
4877         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
4878 }
4879 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4880         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4881         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4882         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4883         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
4884 }
4885 static void* LDKListen_JCalls_clone(const void* this_arg) {
4886         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4887         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4888         return (void*) this_arg;
4889 }
4890 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
4891         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
4892         atomic_init(&calls->refcnt, 1);
4893         //TODO: Assign calls->o from o
4894
4895         LDKListen ret = {
4896                 .this_arg = (void*) calls,
4897                 .block_connected = block_connected_LDKListen_jcall,
4898                 .block_disconnected = block_disconnected_LDKListen_jcall,
4899                 .free = LDKListen_JCalls_free,
4900         };
4901         return ret;
4902 }
4903 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
4904         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
4905         *res_ptr = LDKListen_init(o);
4906         return (long)res_ptr;
4907 }
4908 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
4909         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4910         LDKu8slice block_ref;
4911         block_ref.datalen = *((uint32_t*)block);
4912         block_ref.data = (int8_t*)(block + 4);
4913         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
4914 }
4915
4916 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
4917         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4918         unsigned char header_arr[80];
4919         CHECK(*((uint32_t*)header) == 80);
4920         memcpy(header_arr, (uint8_t*)(header + 4), 80);
4921         unsigned char (*header_ref)[80] = &header_arr;
4922         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
4923 }
4924
4925 typedef struct LDKConfirm_JCalls {
4926         atomic_size_t refcnt;
4927         uint32_t transactions_confirmed_meth;
4928         uint32_t transaction_unconfirmed_meth;
4929         uint32_t best_block_updated_meth;
4930         uint32_t get_relevant_txids_meth;
4931 } LDKConfirm_JCalls;
4932 static void LDKConfirm_JCalls_free(void* this_arg) {
4933         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4934         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4935                 js_free(j_calls->transactions_confirmed_meth);
4936                 js_free(j_calls->transaction_unconfirmed_meth);
4937                 js_free(j_calls->best_block_updated_meth);
4938                 js_free(j_calls->get_relevant_txids_meth);
4939                 FREE(j_calls);
4940         }
4941 }
4942 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
4943         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4944         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4945         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4946         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
4947         uint32_tArray txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4948         uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
4949         for (size_t e = 0; e < txdata_var.datalen; e++) {
4950                 LDKC2Tuple_usizeTransactionZ* txdata_conv_30_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
4951                 *txdata_conv_30_ref = txdata_var.data[e];
4952                 txdata_arr_ptr[e] = (uint64_t)txdata_conv_30_ref;
4953         }
4954         FREE(txdata_var.data);
4955         js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
4956 }
4957 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
4958         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4959         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4960         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
4961         js_invoke_function_1(j_calls->transaction_unconfirmed_meth, txid_arr);
4962 }
4963 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4964         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4965         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4966         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4967         js_invoke_function_2(j_calls->best_block_updated_meth, header_arr, height);
4968 }
4969 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
4970         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4971         ptrArray ret = js_invoke_function_0(j_calls->get_relevant_txids_meth);
4972         LDKCVec_TxidZ ret_constr;
4973         ret_constr.datalen = *((uint32_t*)ret);
4974         if (ret_constr.datalen > 0)
4975                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
4976         else
4977                 ret_constr.data = NULL;
4978         int8_tArray* ret_vals = (int8_tArray*)(ret + 4);
4979         for (size_t m = 0; m < ret_constr.datalen; m++) {
4980                 int8_tArray ret_conv_12 = ret_vals[m];
4981                 LDKThirtyTwoBytes ret_conv_12_ref;
4982                 CHECK(*((uint32_t*)ret_conv_12) == 32);
4983                 memcpy(ret_conv_12_ref.data, (uint8_t*)(ret_conv_12 + 4), 32);
4984                 ret_constr.data[m] = ret_conv_12_ref;
4985         }
4986         return ret_constr;
4987 }
4988 static void* LDKConfirm_JCalls_clone(const void* this_arg) {
4989         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4990         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4991         return (void*) this_arg;
4992 }
4993 static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) {
4994         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
4995         atomic_init(&calls->refcnt, 1);
4996         //TODO: Assign calls->o from o
4997
4998         LDKConfirm ret = {
4999                 .this_arg = (void*) calls,
5000                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
5001                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
5002                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
5003                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
5004                 .free = LDKConfirm_JCalls_free,
5005         };
5006         return ret;
5007 }
5008 long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object Reference */void* o) {
5009         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
5010         *res_ptr = LDKConfirm_init(o);
5011         return (long)res_ptr;
5012 }
5013 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
5014         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5015         unsigned char header_arr[80];
5016         CHECK(*((uint32_t*)header) == 80);
5017         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5018         unsigned char (*header_ref)[80] = &header_arr;
5019         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5020         txdata_constr.datalen = *((uint32_t*)txdata);
5021         if (txdata_constr.datalen > 0)
5022                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5023         else
5024                 txdata_constr.data = NULL;
5025         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
5026         for (size_t e = 0; e < txdata_constr.datalen; e++) {
5027                 uint32_t txdata_conv_30 = txdata_vals[e];
5028                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
5029                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
5030                 txdata_constr.data[e] = txdata_conv_30_conv;
5031         }
5032         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
5033 }
5034
5035 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
5036         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5037         unsigned char txid_arr[32];
5038         CHECK(*((uint32_t*)txid) == 32);
5039         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5040         unsigned char (*txid_ref)[32] = &txid_arr;
5041         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
5042 }
5043
5044 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
5045         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5046         unsigned char header_arr[80];
5047         CHECK(*((uint32_t*)header) == 80);
5048         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5049         unsigned char (*header_ref)[80] = &header_arr;
5050         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
5051 }
5052
5053 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
5054         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5055         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
5056         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
5057         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
5058         for (size_t m = 0; m < ret_var.datalen; m++) {
5059                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5060                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
5061                 ret_arr_ptr[m] = ret_conv_12_arr;
5062         }
5063         FREE(ret_var.data);
5064         return ret_arr;
5065 }
5066
5067 typedef struct LDKFilter_JCalls {
5068         atomic_size_t refcnt;
5069         uint32_t register_tx_meth;
5070         uint32_t register_output_meth;
5071 } LDKFilter_JCalls;
5072 static void LDKFilter_JCalls_free(void* this_arg) {
5073         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5074         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5075                 js_free(j_calls->register_tx_meth);
5076                 js_free(j_calls->register_output_meth);
5077                 FREE(j_calls);
5078         }
5079 }
5080 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5081         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5082         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5083         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5084         LDKu8slice script_pubkey_var = script_pubkey;
5085         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5086         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
5087         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5088 }
5089 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5090         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5091         LDKWatchedOutput output_var = output;
5092         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5093         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5094         uint64_t output_ref = (uint64_t)output_var.inner;
5095         if (output_var.is_owned) {
5096                 output_ref |= 1;
5097         }
5098         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)js_invoke_function_1(j_calls->register_output_meth, output_ref);
5099         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
5100         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
5101         return ret_conv;
5102 }
5103 static void* LDKFilter_JCalls_clone(const void* this_arg) {
5104         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5105         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5106         return (void*) this_arg;
5107 }
5108 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
5109         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5110         atomic_init(&calls->refcnt, 1);
5111         //TODO: Assign calls->o from o
5112
5113         LDKFilter ret = {
5114                 .this_arg = (void*) calls,
5115                 .register_tx = register_tx_LDKFilter_jcall,
5116                 .register_output = register_output_LDKFilter_jcall,
5117                 .free = LDKFilter_JCalls_free,
5118         };
5119         return ret;
5120 }
5121 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
5122         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5123         *res_ptr = LDKFilter_init(o);
5124         return (long)res_ptr;
5125 }
5126 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5127         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5128         unsigned char txid_arr[32];
5129         CHECK(*((uint32_t*)txid) == 32);
5130         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5131         unsigned char (*txid_ref)[32] = &txid_arr;
5132         LDKu8slice script_pubkey_ref;
5133         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
5134         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
5135         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5136 }
5137
5138 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5139         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5140         LDKWatchedOutput output_conv;
5141         output_conv.inner = (void*)(output & (~1));
5142         output_conv.is_owned = (output & 1) || (output == 0);
5143         output_conv = WatchedOutput_clone(&output_conv);
5144         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5145         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5146         uint64_t ret_ref = (uint64_t)ret_copy;
5147         return ret_ref;
5148 }
5149
5150 typedef struct LDKPersist_JCalls {
5151         atomic_size_t refcnt;
5152         uint32_t persist_new_channel_meth;
5153         uint32_t update_persisted_channel_meth;
5154 } LDKPersist_JCalls;
5155 static void LDKPersist_JCalls_free(void* this_arg) {
5156         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5157         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5158                 js_free(j_calls->persist_new_channel_meth);
5159                 js_free(j_calls->update_persisted_channel_meth);
5160                 FREE(j_calls);
5161         }
5162 }
5163 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
5164         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5165         LDKOutPoint id_var = id;
5166         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5167         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5168         uint64_t id_ref = (uint64_t)id_var.inner;
5169         if (id_var.is_owned) {
5170                 id_ref |= 1;
5171         }
5172         LDKChannelMonitor data_var = *data;
5173         data_var = ChannelMonitor_clone(data);
5174         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5175         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5176         uint64_t data_ref = (uint64_t)data_var.inner;
5177         if (data_var.is_owned) {
5178                 data_ref |= 1;
5179         }
5180         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
5181         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5182         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5183         return ret_conv;
5184 }
5185 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
5186         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5187         LDKOutPoint id_var = id;
5188         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5189         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5190         uint64_t id_ref = (uint64_t)id_var.inner;
5191         if (id_var.is_owned) {
5192                 id_ref |= 1;
5193         }
5194         LDKChannelMonitorUpdate update_var = *update;
5195         update_var = ChannelMonitorUpdate_clone(update);
5196         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5197         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5198         uint64_t update_ref = (uint64_t)update_var.inner;
5199         if (update_var.is_owned) {
5200                 update_ref |= 1;
5201         }
5202         LDKChannelMonitor data_var = *data;
5203         data_var = ChannelMonitor_clone(data);
5204         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5205         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5206         uint64_t data_ref = (uint64_t)data_var.inner;
5207         if (data_var.is_owned) {
5208                 data_ref |= 1;
5209         }
5210         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
5211         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5212         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5213         return ret_conv;
5214 }
5215 static void* LDKPersist_JCalls_clone(const void* this_arg) {
5216         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5217         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5218         return (void*) this_arg;
5219 }
5220 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
5221         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5222         atomic_init(&calls->refcnt, 1);
5223         //TODO: Assign calls->o from o
5224
5225         LDKPersist ret = {
5226                 .this_arg = (void*) calls,
5227                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
5228                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
5229                 .free = LDKPersist_JCalls_free,
5230         };
5231         return ret;
5232 }
5233 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
5234         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5235         *res_ptr = LDKPersist_init(o);
5236         return (long)res_ptr;
5237 }
5238 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
5239         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5240         LDKOutPoint id_conv;
5241         id_conv.inner = (void*)(id & (~1));
5242         id_conv.is_owned = (id & 1) || (id == 0);
5243         id_conv = OutPoint_clone(&id_conv);
5244         LDKChannelMonitor data_conv;
5245         data_conv.inner = (void*)(data & (~1));
5246         data_conv.is_owned = false;
5247         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5248         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
5249         return (uint64_t)ret_conv;
5250 }
5251
5252 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
5253         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5254         LDKOutPoint id_conv;
5255         id_conv.inner = (void*)(id & (~1));
5256         id_conv.is_owned = (id & 1) || (id == 0);
5257         id_conv = OutPoint_clone(&id_conv);
5258         LDKChannelMonitorUpdate update_conv;
5259         update_conv.inner = (void*)(update & (~1));
5260         update_conv.is_owned = false;
5261         LDKChannelMonitor data_conv;
5262         data_conv.inner = (void*)(data & (~1));
5263         data_conv.is_owned = false;
5264         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5265         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
5266         return (uint64_t)ret_conv;
5267 }
5268
5269 typedef struct LDKChannelMessageHandler_JCalls {
5270         atomic_size_t refcnt;
5271         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5272         uint32_t handle_open_channel_meth;
5273         uint32_t handle_accept_channel_meth;
5274         uint32_t handle_funding_created_meth;
5275         uint32_t handle_funding_signed_meth;
5276         uint32_t handle_funding_locked_meth;
5277         uint32_t handle_shutdown_meth;
5278         uint32_t handle_closing_signed_meth;
5279         uint32_t handle_update_add_htlc_meth;
5280         uint32_t handle_update_fulfill_htlc_meth;
5281         uint32_t handle_update_fail_htlc_meth;
5282         uint32_t handle_update_fail_malformed_htlc_meth;
5283         uint32_t handle_commitment_signed_meth;
5284         uint32_t handle_revoke_and_ack_meth;
5285         uint32_t handle_update_fee_meth;
5286         uint32_t handle_announcement_signatures_meth;
5287         uint32_t peer_disconnected_meth;
5288         uint32_t peer_connected_meth;
5289         uint32_t handle_channel_reestablish_meth;
5290         uint32_t handle_channel_update_meth;
5291         uint32_t handle_error_meth;
5292 } LDKChannelMessageHandler_JCalls;
5293 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5294         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5295         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5296                 js_free(j_calls->handle_open_channel_meth);
5297                 js_free(j_calls->handle_accept_channel_meth);
5298                 js_free(j_calls->handle_funding_created_meth);
5299                 js_free(j_calls->handle_funding_signed_meth);
5300                 js_free(j_calls->handle_funding_locked_meth);
5301                 js_free(j_calls->handle_shutdown_meth);
5302                 js_free(j_calls->handle_closing_signed_meth);
5303                 js_free(j_calls->handle_update_add_htlc_meth);
5304                 js_free(j_calls->handle_update_fulfill_htlc_meth);
5305                 js_free(j_calls->handle_update_fail_htlc_meth);
5306                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
5307                 js_free(j_calls->handle_commitment_signed_meth);
5308                 js_free(j_calls->handle_revoke_and_ack_meth);
5309                 js_free(j_calls->handle_update_fee_meth);
5310                 js_free(j_calls->handle_announcement_signatures_meth);
5311                 js_free(j_calls->peer_disconnected_meth);
5312                 js_free(j_calls->peer_connected_meth);
5313                 js_free(j_calls->handle_channel_reestablish_meth);
5314                 js_free(j_calls->handle_channel_update_meth);
5315                 js_free(j_calls->handle_error_meth);
5316                 FREE(j_calls);
5317         }
5318 }
5319 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5320         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5321         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5322         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5323         LDKInitFeatures their_features_var = their_features;
5324         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5325         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5326         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5327         if (their_features_var.is_owned) {
5328                 their_features_ref |= 1;
5329         }
5330         LDKOpenChannel msg_var = *msg;
5331         msg_var = OpenChannel_clone(msg);
5332         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5333         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5334         uint64_t msg_ref = (uint64_t)msg_var.inner;
5335         if (msg_var.is_owned) {
5336                 msg_ref |= 1;
5337         }
5338         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5339 }
5340 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
5341         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5342         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5343         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5344         LDKInitFeatures their_features_var = their_features;
5345         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5346         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5347         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5348         if (their_features_var.is_owned) {
5349                 their_features_ref |= 1;
5350         }
5351         LDKAcceptChannel msg_var = *msg;
5352         msg_var = AcceptChannel_clone(msg);
5353         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5354         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5355         uint64_t msg_ref = (uint64_t)msg_var.inner;
5356         if (msg_var.is_owned) {
5357                 msg_ref |= 1;
5358         }
5359         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5360 }
5361 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
5362         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5363         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5364         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5365         LDKFundingCreated msg_var = *msg;
5366         msg_var = FundingCreated_clone(msg);
5367         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5368         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5369         uint64_t msg_ref = (uint64_t)msg_var.inner;
5370         if (msg_var.is_owned) {
5371                 msg_ref |= 1;
5372         }
5373         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
5374 }
5375 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
5376         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5377         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5378         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5379         LDKFundingSigned msg_var = *msg;
5380         msg_var = FundingSigned_clone(msg);
5381         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5382         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5383         uint64_t msg_ref = (uint64_t)msg_var.inner;
5384         if (msg_var.is_owned) {
5385                 msg_ref |= 1;
5386         }
5387         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
5388 }
5389 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
5390         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5391         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5392         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5393         LDKFundingLocked msg_var = *msg;
5394         msg_var = FundingLocked_clone(msg);
5395         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5396         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5397         uint64_t msg_ref = (uint64_t)msg_var.inner;
5398         if (msg_var.is_owned) {
5399                 msg_ref |= 1;
5400         }
5401         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
5402 }
5403 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
5404         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5405         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5406         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5407         LDKInitFeatures their_features_var = *their_features;
5408         their_features_var = InitFeatures_clone(their_features);
5409         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5410         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5411         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5412         if (their_features_var.is_owned) {
5413                 their_features_ref |= 1;
5414         }
5415         LDKShutdown msg_var = *msg;
5416         msg_var = Shutdown_clone(msg);
5417         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5418         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5419         uint64_t msg_ref = (uint64_t)msg_var.inner;
5420         if (msg_var.is_owned) {
5421                 msg_ref |= 1;
5422         }
5423         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
5424 }
5425 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
5426         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5427         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5428         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5429         LDKClosingSigned msg_var = *msg;
5430         msg_var = ClosingSigned_clone(msg);
5431         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5432         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5433         uint64_t msg_ref = (uint64_t)msg_var.inner;
5434         if (msg_var.is_owned) {
5435                 msg_ref |= 1;
5436         }
5437         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
5438 }
5439 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
5440         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5441         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5442         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5443         LDKUpdateAddHTLC msg_var = *msg;
5444         msg_var = UpdateAddHTLC_clone(msg);
5445         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5446         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5447         uint64_t msg_ref = (uint64_t)msg_var.inner;
5448         if (msg_var.is_owned) {
5449                 msg_ref |= 1;
5450         }
5451         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
5452 }
5453 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
5454         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5455         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5456         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5457         LDKUpdateFulfillHTLC msg_var = *msg;
5458         msg_var = UpdateFulfillHTLC_clone(msg);
5459         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5460         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5461         uint64_t msg_ref = (uint64_t)msg_var.inner;
5462         if (msg_var.is_owned) {
5463                 msg_ref |= 1;
5464         }
5465         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
5466 }
5467 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
5468         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5469         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5470         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5471         LDKUpdateFailHTLC msg_var = *msg;
5472         msg_var = UpdateFailHTLC_clone(msg);
5473         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5474         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5475         uint64_t msg_ref = (uint64_t)msg_var.inner;
5476         if (msg_var.is_owned) {
5477                 msg_ref |= 1;
5478         }
5479         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
5480 }
5481 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
5482         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5483         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5484         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5485         LDKUpdateFailMalformedHTLC msg_var = *msg;
5486         msg_var = UpdateFailMalformedHTLC_clone(msg);
5487         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5488         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5489         uint64_t msg_ref = (uint64_t)msg_var.inner;
5490         if (msg_var.is_owned) {
5491                 msg_ref |= 1;
5492         }
5493         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
5494 }
5495 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
5496         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5497         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5498         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5499         LDKCommitmentSigned msg_var = *msg;
5500         msg_var = CommitmentSigned_clone(msg);
5501         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5502         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5503         uint64_t msg_ref = (uint64_t)msg_var.inner;
5504         if (msg_var.is_owned) {
5505                 msg_ref |= 1;
5506         }
5507         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
5508 }
5509 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
5510         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5511         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5512         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5513         LDKRevokeAndACK msg_var = *msg;
5514         msg_var = RevokeAndACK_clone(msg);
5515         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5516         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5517         uint64_t msg_ref = (uint64_t)msg_var.inner;
5518         if (msg_var.is_owned) {
5519                 msg_ref |= 1;
5520         }
5521         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
5522 }
5523 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
5524         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5525         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5526         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5527         LDKUpdateFee msg_var = *msg;
5528         msg_var = UpdateFee_clone(msg);
5529         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5530         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5531         uint64_t msg_ref = (uint64_t)msg_var.inner;
5532         if (msg_var.is_owned) {
5533                 msg_ref |= 1;
5534         }
5535         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
5536 }
5537 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
5538         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5539         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5540         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5541         LDKAnnouncementSignatures msg_var = *msg;
5542         msg_var = AnnouncementSignatures_clone(msg);
5543         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5544         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5545         uint64_t msg_ref = (uint64_t)msg_var.inner;
5546         if (msg_var.is_owned) {
5547                 msg_ref |= 1;
5548         }
5549         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
5550 }
5551 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
5552         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5553         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5554         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5555         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
5556 }
5557 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
5558         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5559         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5560         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5561         LDKInit msg_var = *msg;
5562         msg_var = Init_clone(msg);
5563         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5564         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5565         uint64_t msg_ref = (uint64_t)msg_var.inner;
5566         if (msg_var.is_owned) {
5567                 msg_ref |= 1;
5568         }
5569         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
5570 }
5571 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
5572         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5573         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5574         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5575         LDKChannelReestablish msg_var = *msg;
5576         msg_var = ChannelReestablish_clone(msg);
5577         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5578         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5579         uint64_t msg_ref = (uint64_t)msg_var.inner;
5580         if (msg_var.is_owned) {
5581                 msg_ref |= 1;
5582         }
5583         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
5584 }
5585 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
5586         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5587         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5588         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5589         LDKChannelUpdate msg_var = *msg;
5590         msg_var = ChannelUpdate_clone(msg);
5591         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5592         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5593         uint64_t msg_ref = (uint64_t)msg_var.inner;
5594         if (msg_var.is_owned) {
5595                 msg_ref |= 1;
5596         }
5597         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
5598 }
5599 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
5600         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5601         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5602         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5603         LDKErrorMessage msg_var = *msg;
5604         msg_var = ErrorMessage_clone(msg);
5605         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5606         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5607         uint64_t msg_ref = (uint64_t)msg_var.inner;
5608         if (msg_var.is_owned) {
5609                 msg_ref |= 1;
5610         }
5611         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
5612 }
5613 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
5614         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5615         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5616         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5617         return (void*) this_arg;
5618 }
5619 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
5620         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
5621         atomic_init(&calls->refcnt, 1);
5622         //TODO: Assign calls->o from o
5623
5624         LDKChannelMessageHandler ret = {
5625                 .this_arg = (void*) calls,
5626                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
5627                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
5628                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
5629                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
5630                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
5631                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
5632                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
5633                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
5634                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
5635                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
5636                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
5637                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
5638                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
5639                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
5640                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
5641                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
5642                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
5643                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
5644                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
5645                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
5646                 .free = LDKChannelMessageHandler_JCalls_free,
5647                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
5648         };
5649         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5650         return ret;
5651 }
5652 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
5653         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5654         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
5655         return (long)res_ptr;
5656 }
5657 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) {
5658         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5659         LDKPublicKey their_node_id_ref;
5660         CHECK(*((uint32_t*)their_node_id) == 33);
5661         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5662         LDKInitFeatures their_features_conv;
5663         their_features_conv.inner = (void*)(their_features & (~1));
5664         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5665         their_features_conv = InitFeatures_clone(&their_features_conv);
5666         LDKOpenChannel msg_conv;
5667         msg_conv.inner = (void*)(msg & (~1));
5668         msg_conv.is_owned = false;
5669         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5670 }
5671
5672 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) {
5673         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5674         LDKPublicKey their_node_id_ref;
5675         CHECK(*((uint32_t*)their_node_id) == 33);
5676         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5677         LDKInitFeatures their_features_conv;
5678         their_features_conv.inner = (void*)(their_features & (~1));
5679         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5680         their_features_conv = InitFeatures_clone(&their_features_conv);
5681         LDKAcceptChannel msg_conv;
5682         msg_conv.inner = (void*)(msg & (~1));
5683         msg_conv.is_owned = false;
5684         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5685 }
5686
5687 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5688         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5689         LDKPublicKey their_node_id_ref;
5690         CHECK(*((uint32_t*)their_node_id) == 33);
5691         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5692         LDKFundingCreated msg_conv;
5693         msg_conv.inner = (void*)(msg & (~1));
5694         msg_conv.is_owned = false;
5695         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5696 }
5697
5698 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5699         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5700         LDKPublicKey their_node_id_ref;
5701         CHECK(*((uint32_t*)their_node_id) == 33);
5702         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5703         LDKFundingSigned msg_conv;
5704         msg_conv.inner = (void*)(msg & (~1));
5705         msg_conv.is_owned = false;
5706         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5707 }
5708
5709 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5710         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5711         LDKPublicKey their_node_id_ref;
5712         CHECK(*((uint32_t*)their_node_id) == 33);
5713         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5714         LDKFundingLocked msg_conv;
5715         msg_conv.inner = (void*)(msg & (~1));
5716         msg_conv.is_owned = false;
5717         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5718 }
5719
5720 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
5721         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5722         LDKPublicKey their_node_id_ref;
5723         CHECK(*((uint32_t*)their_node_id) == 33);
5724         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5725         LDKInitFeatures their_features_conv;
5726         their_features_conv.inner = (void*)(their_features & (~1));
5727         their_features_conv.is_owned = false;
5728         LDKShutdown msg_conv;
5729         msg_conv.inner = (void*)(msg & (~1));
5730         msg_conv.is_owned = false;
5731         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
5732 }
5733
5734 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5735         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5736         LDKPublicKey their_node_id_ref;
5737         CHECK(*((uint32_t*)their_node_id) == 33);
5738         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5739         LDKClosingSigned msg_conv;
5740         msg_conv.inner = (void*)(msg & (~1));
5741         msg_conv.is_owned = false;
5742         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5743 }
5744
5745 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5746         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5747         LDKPublicKey their_node_id_ref;
5748         CHECK(*((uint32_t*)their_node_id) == 33);
5749         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5750         LDKUpdateAddHTLC msg_conv;
5751         msg_conv.inner = (void*)(msg & (~1));
5752         msg_conv.is_owned = false;
5753         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5754 }
5755
5756 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5757         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5758         LDKPublicKey their_node_id_ref;
5759         CHECK(*((uint32_t*)their_node_id) == 33);
5760         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5761         LDKUpdateFulfillHTLC msg_conv;
5762         msg_conv.inner = (void*)(msg & (~1));
5763         msg_conv.is_owned = false;
5764         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5765 }
5766
5767 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, 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         LDKUpdateFailHTLC msg_conv;
5773         msg_conv.inner = (void*)(msg & (~1));
5774         msg_conv.is_owned = false;
5775         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5776 }
5777
5778 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5779         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5780         LDKPublicKey their_node_id_ref;
5781         CHECK(*((uint32_t*)their_node_id) == 33);
5782         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5783         LDKUpdateFailMalformedHTLC msg_conv;
5784         msg_conv.inner = (void*)(msg & (~1));
5785         msg_conv.is_owned = false;
5786         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5787 }
5788
5789 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5790         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5791         LDKPublicKey their_node_id_ref;
5792         CHECK(*((uint32_t*)their_node_id) == 33);
5793         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5794         LDKCommitmentSigned msg_conv;
5795         msg_conv.inner = (void*)(msg & (~1));
5796         msg_conv.is_owned = false;
5797         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5798 }
5799
5800 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5801         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5802         LDKPublicKey their_node_id_ref;
5803         CHECK(*((uint32_t*)their_node_id) == 33);
5804         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5805         LDKRevokeAndACK msg_conv;
5806         msg_conv.inner = (void*)(msg & (~1));
5807         msg_conv.is_owned = false;
5808         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5809 }
5810
5811 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5812         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5813         LDKPublicKey their_node_id_ref;
5814         CHECK(*((uint32_t*)their_node_id) == 33);
5815         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5816         LDKUpdateFee msg_conv;
5817         msg_conv.inner = (void*)(msg & (~1));
5818         msg_conv.is_owned = false;
5819         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5820 }
5821
5822 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5823         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5824         LDKPublicKey their_node_id_ref;
5825         CHECK(*((uint32_t*)their_node_id) == 33);
5826         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5827         LDKAnnouncementSignatures msg_conv;
5828         msg_conv.inner = (void*)(msg & (~1));
5829         msg_conv.is_owned = false;
5830         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5831 }
5832
5833 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
5834         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5835         LDKPublicKey their_node_id_ref;
5836         CHECK(*((uint32_t*)their_node_id) == 33);
5837         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5838         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
5839 }
5840
5841 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5842         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5843         LDKPublicKey their_node_id_ref;
5844         CHECK(*((uint32_t*)their_node_id) == 33);
5845         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5846         LDKInit msg_conv;
5847         msg_conv.inner = (void*)(msg & (~1));
5848         msg_conv.is_owned = false;
5849         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5850 }
5851
5852 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5853         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5854         LDKPublicKey their_node_id_ref;
5855         CHECK(*((uint32_t*)their_node_id) == 33);
5856         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5857         LDKChannelReestablish msg_conv;
5858         msg_conv.inner = (void*)(msg & (~1));
5859         msg_conv.is_owned = false;
5860         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5861 }
5862
5863 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5864         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5865         LDKPublicKey their_node_id_ref;
5866         CHECK(*((uint32_t*)their_node_id) == 33);
5867         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5868         LDKChannelUpdate msg_conv;
5869         msg_conv.inner = (void*)(msg & (~1));
5870         msg_conv.is_owned = false;
5871         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5872 }
5873
5874 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5875         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5876         LDKPublicKey their_node_id_ref;
5877         CHECK(*((uint32_t*)their_node_id) == 33);
5878         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5879         LDKErrorMessage msg_conv;
5880         msg_conv.inner = (void*)(msg & (~1));
5881         msg_conv.is_owned = false;
5882         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5883 }
5884
5885 typedef struct LDKRoutingMessageHandler_JCalls {
5886         atomic_size_t refcnt;
5887         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5888         uint32_t handle_node_announcement_meth;
5889         uint32_t handle_channel_announcement_meth;
5890         uint32_t handle_channel_update_meth;
5891         uint32_t handle_htlc_fail_channel_update_meth;
5892         uint32_t get_next_channel_announcements_meth;
5893         uint32_t get_next_node_announcements_meth;
5894         uint32_t sync_routing_table_meth;
5895         uint32_t handle_reply_channel_range_meth;
5896         uint32_t handle_reply_short_channel_ids_end_meth;
5897         uint32_t handle_query_channel_range_meth;
5898         uint32_t handle_query_short_channel_ids_meth;
5899 } LDKRoutingMessageHandler_JCalls;
5900 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
5901         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5902         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5903                 js_free(j_calls->handle_node_announcement_meth);
5904                 js_free(j_calls->handle_channel_announcement_meth);
5905                 js_free(j_calls->handle_channel_update_meth);
5906                 js_free(j_calls->handle_htlc_fail_channel_update_meth);
5907                 js_free(j_calls->get_next_channel_announcements_meth);
5908                 js_free(j_calls->get_next_node_announcements_meth);
5909                 js_free(j_calls->sync_routing_table_meth);
5910                 js_free(j_calls->handle_reply_channel_range_meth);
5911                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
5912                 js_free(j_calls->handle_query_channel_range_meth);
5913                 js_free(j_calls->handle_query_short_channel_ids_meth);
5914                 FREE(j_calls);
5915         }
5916 }
5917 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
5918         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5919         LDKNodeAnnouncement msg_var = *msg;
5920         msg_var = NodeAnnouncement_clone(msg);
5921         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5922         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5923         uint64_t msg_ref = (uint64_t)msg_var.inner;
5924         if (msg_var.is_owned) {
5925                 msg_ref |= 1;
5926         }
5927         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
5928         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5929         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5930         return ret_conv;
5931 }
5932 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
5933         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5934         LDKChannelAnnouncement msg_var = *msg;
5935         msg_var = ChannelAnnouncement_clone(msg);
5936         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5937         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5938         uint64_t msg_ref = (uint64_t)msg_var.inner;
5939         if (msg_var.is_owned) {
5940                 msg_ref |= 1;
5941         }
5942         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
5943         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5944         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5945         return ret_conv;
5946 }
5947 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
5948         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5949         LDKChannelUpdate msg_var = *msg;
5950         msg_var = ChannelUpdate_clone(msg);
5951         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5952         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5953         uint64_t msg_ref = (uint64_t)msg_var.inner;
5954         if (msg_var.is_owned) {
5955                 msg_ref |= 1;
5956         }
5957         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
5958         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5959         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5960         return ret_conv;
5961 }
5962 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
5963         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5964         uint64_t ret_update = (uint64_t)update;
5965         js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
5966 }
5967 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
5968         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5969         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
5970         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
5971         ret_constr.datalen = *((uint32_t*)ret);
5972         if (ret_constr.datalen > 0)
5973                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5974         else
5975                 ret_constr.data = NULL;
5976         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5977         for (size_t l = 0; l < ret_constr.datalen; l++) {
5978                 uint32_t ret_conv_63 = ret_vals[l];
5979                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
5980                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
5981                 ret_constr.data[l] = ret_conv_63_conv;
5982         }
5983         return ret_constr;
5984 }
5985 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
5986         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5987         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5988         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
5989         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
5990         LDKCVec_NodeAnnouncementZ ret_constr;
5991         ret_constr.datalen = *((uint32_t*)ret);
5992         if (ret_constr.datalen > 0)
5993                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5994         else
5995                 ret_constr.data = NULL;
5996         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5997         for (size_t s = 0; s < ret_constr.datalen; s++) {
5998                 uint32_t ret_conv_18 = ret_vals[s];
5999                 LDKNodeAnnouncement ret_conv_18_conv;
6000                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
6001                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
6002                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
6003                 ret_constr.data[s] = ret_conv_18_conv;
6004         }
6005         return ret_constr;
6006 }
6007 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
6008         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6009         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6010         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6011         LDKInit init_var = *init;
6012         init_var = Init_clone(init);
6013         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6014         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6015         uint64_t init_ref = (uint64_t)init_var.inner;
6016         if (init_var.is_owned) {
6017                 init_ref |= 1;
6018         }
6019         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
6020 }
6021 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
6022         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6023         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6024         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6025         LDKReplyChannelRange msg_var = msg;
6026         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6027         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6028         uint64_t msg_ref = (uint64_t)msg_var.inner;
6029         if (msg_var.is_owned) {
6030                 msg_ref |= 1;
6031         }
6032         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6033         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6034         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6035         return ret_conv;
6036 }
6037 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6038         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6039         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6040         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6041         LDKReplyShortChannelIdsEnd msg_var = msg;
6042         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6043         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6044         uint64_t msg_ref = (uint64_t)msg_var.inner;
6045         if (msg_var.is_owned) {
6046                 msg_ref |= 1;
6047         }
6048         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6049         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6050         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6051         return ret_conv;
6052 }
6053 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6054         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6055         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6056         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6057         LDKQueryChannelRange msg_var = msg;
6058         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6059         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6060         uint64_t msg_ref = (uint64_t)msg_var.inner;
6061         if (msg_var.is_owned) {
6062                 msg_ref |= 1;
6063         }
6064         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6065         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6066         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6067         return ret_conv;
6068 }
6069 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6070         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6071         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6072         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6073         LDKQueryShortChannelIds msg_var = msg;
6074         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6075         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6076         uint64_t msg_ref = (uint64_t)msg_var.inner;
6077         if (msg_var.is_owned) {
6078                 msg_ref |= 1;
6079         }
6080         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6081         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6082         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6083         return ret_conv;
6084 }
6085 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
6086         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6087         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6088         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6089         return (void*) this_arg;
6090 }
6091 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6092         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6093         atomic_init(&calls->refcnt, 1);
6094         //TODO: Assign calls->o from o
6095
6096         LDKRoutingMessageHandler ret = {
6097                 .this_arg = (void*) calls,
6098                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
6099                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
6100                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
6101                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
6102                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
6103                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
6104                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
6105                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
6106                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
6107                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
6108                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
6109                 .free = LDKRoutingMessageHandler_JCalls_free,
6110                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6111         };
6112         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6113         return ret;
6114 }
6115 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6116         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6117         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
6118         return (long)res_ptr;
6119 }
6120 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
6121         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6122         LDKNodeAnnouncement msg_conv;
6123         msg_conv.inner = (void*)(msg & (~1));
6124         msg_conv.is_owned = false;
6125         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6126         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6127         return (uint64_t)ret_conv;
6128 }
6129
6130 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
6131         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6132         LDKChannelAnnouncement msg_conv;
6133         msg_conv.inner = (void*)(msg & (~1));
6134         msg_conv.is_owned = false;
6135         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6136         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6137         return (uint64_t)ret_conv;
6138 }
6139
6140 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
6141         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6142         LDKChannelUpdate msg_conv;
6143         msg_conv.inner = (void*)(msg & (~1));
6144         msg_conv.is_owned = false;
6145         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6146         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6147         return (uint64_t)ret_conv;
6148 }
6149
6150 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
6151         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6152         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
6153         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
6154 }
6155
6156 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
6157         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6158         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6159         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6160         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6161         for (size_t l = 0; l < ret_var.datalen; l++) {
6162                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6163                 *ret_conv_63_ref = ret_var.data[l];
6164                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
6165         }
6166         FREE(ret_var.data);
6167         return ret_arr;
6168 }
6169
6170 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
6171         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6172         LDKPublicKey starting_point_ref;
6173         CHECK(*((uint32_t*)starting_point) == 33);
6174         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
6175         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6176         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6177         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6178         for (size_t s = 0; s < ret_var.datalen; s++) {
6179                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6180                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6181                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6182                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
6183                 if (ret_conv_18_var.is_owned) {
6184                         ret_conv_18_ref |= 1;
6185                 }
6186                 ret_arr_ptr[s] = ret_conv_18_ref;
6187         }
6188         FREE(ret_var.data);
6189         return ret_arr;
6190 }
6191
6192 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
6193         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6194         LDKPublicKey their_node_id_ref;
6195         CHECK(*((uint32_t*)their_node_id) == 33);
6196         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6197         LDKInit init_conv;
6198         init_conv.inner = (void*)(init & (~1));
6199         init_conv.is_owned = false;
6200         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
6201 }
6202
6203 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6204         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6205         LDKPublicKey their_node_id_ref;
6206         CHECK(*((uint32_t*)their_node_id) == 33);
6207         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6208         LDKReplyChannelRange msg_conv;
6209         msg_conv.inner = (void*)(msg & (~1));
6210         msg_conv.is_owned = (msg & 1) || (msg == 0);
6211         msg_conv = ReplyChannelRange_clone(&msg_conv);
6212         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6213         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6214         return (uint64_t)ret_conv;
6215 }
6216
6217 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) {
6218         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6219         LDKPublicKey their_node_id_ref;
6220         CHECK(*((uint32_t*)their_node_id) == 33);
6221         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6222         LDKReplyShortChannelIdsEnd msg_conv;
6223         msg_conv.inner = (void*)(msg & (~1));
6224         msg_conv.is_owned = (msg & 1) || (msg == 0);
6225         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
6226         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6227         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6228         return (uint64_t)ret_conv;
6229 }
6230
6231 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6232         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6233         LDKPublicKey their_node_id_ref;
6234         CHECK(*((uint32_t*)their_node_id) == 33);
6235         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6236         LDKQueryChannelRange msg_conv;
6237         msg_conv.inner = (void*)(msg & (~1));
6238         msg_conv.is_owned = (msg & 1) || (msg == 0);
6239         msg_conv = QueryChannelRange_clone(&msg_conv);
6240         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6241         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6242         return (uint64_t)ret_conv;
6243 }
6244
6245 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6246         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6247         LDKPublicKey their_node_id_ref;
6248         CHECK(*((uint32_t*)their_node_id) == 33);
6249         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6250         LDKQueryShortChannelIds msg_conv;
6251         msg_conv.inner = (void*)(msg & (~1));
6252         msg_conv.is_owned = (msg & 1) || (msg == 0);
6253         msg_conv = QueryShortChannelIds_clone(&msg_conv);
6254         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6255         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6256         return (uint64_t)ret_conv;
6257 }
6258
6259 typedef struct LDKSocketDescriptor_JCalls {
6260         atomic_size_t refcnt;
6261         uint32_t send_data_meth;
6262         uint32_t disconnect_socket_meth;
6263         uint32_t eq_meth;
6264         uint32_t hash_meth;
6265 } LDKSocketDescriptor_JCalls;
6266 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
6267         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6268         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6269                 js_free(j_calls->send_data_meth);
6270                 js_free(j_calls->disconnect_socket_meth);
6271                 js_free(j_calls->eq_meth);
6272                 js_free(j_calls->hash_meth);
6273                 FREE(j_calls);
6274         }
6275 }
6276 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
6277         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6278         LDKu8slice data_var = data;
6279         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6280         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
6281         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
6282 }
6283 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
6284         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6285         js_invoke_function_0(j_calls->disconnect_socket_meth);
6286 }
6287 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
6288         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6289         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6290         *other_arg_clone = SocketDescriptor_clone(other_arg);
6291         return js_invoke_function_1(j_calls->eq_meth, (uint64_t)other_arg_clone);
6292 }
6293 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
6294         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6295         return js_invoke_function_0(j_calls->hash_meth);
6296 }
6297 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
6298         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6299         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6300         return (void*) this_arg;
6301 }
6302 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
6303         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
6304         atomic_init(&calls->refcnt, 1);
6305         //TODO: Assign calls->o from o
6306
6307         LDKSocketDescriptor ret = {
6308                 .this_arg = (void*) calls,
6309                 .send_data = send_data_LDKSocketDescriptor_jcall,
6310                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
6311                 .eq = eq_LDKSocketDescriptor_jcall,
6312                 .hash = hash_LDKSocketDescriptor_jcall,
6313                 .clone = LDKSocketDescriptor_JCalls_clone,
6314                 .free = LDKSocketDescriptor_JCalls_free,
6315         };
6316         return ret;
6317 }
6318 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
6319         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6320         *res_ptr = LDKSocketDescriptor_init(o);
6321         return (long)res_ptr;
6322 }
6323 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
6324         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6325         LDKu8slice data_ref;
6326         data_ref.datalen = *((uint32_t*)data);
6327         data_ref.data = (int8_t*)(data + 4);
6328         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
6329         return ret_val;
6330 }
6331
6332 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
6333         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6334         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
6335 }
6336
6337 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
6338         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6339         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
6340         return ret_val;
6341 }
6342
6343 typedef struct LDKChannelManagerPersister_JCalls {
6344         atomic_size_t refcnt;
6345         uint32_t persist_manager_meth;
6346 } LDKChannelManagerPersister_JCalls;
6347 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
6348         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6349         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6350                 js_free(j_calls->persist_manager_meth);
6351                 FREE(j_calls);
6352         }
6353 }
6354 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
6355         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6356         LDKChannelManager channel_manager_var = *channel_manager;
6357         // Warning: we may need a move here but no clone is available for LDKChannelManager
6358         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6359         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6360         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
6361         if (channel_manager_var.is_owned) {
6362                 channel_manager_ref |= 1;
6363         }
6364         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
6365         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
6366         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
6367         return ret_conv;
6368 }
6369 static void* LDKChannelManagerPersister_JCalls_clone(const void* this_arg) {
6370         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6371         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6372         return (void*) this_arg;
6373 }
6374 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (/*TODO: JS Object Reference */void* o) {
6375         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
6376         atomic_init(&calls->refcnt, 1);
6377         //TODO: Assign calls->o from o
6378
6379         LDKChannelManagerPersister ret = {
6380                 .this_arg = (void*) calls,
6381                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
6382                 .free = LDKChannelManagerPersister_JCalls_free,
6383         };
6384         return ret;
6385 }
6386 long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/*TODO: JS Object Reference */void* o) {
6387         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
6388         *res_ptr = LDKChannelManagerPersister_init(o);
6389         return (long)res_ptr;
6390 }
6391 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
6392         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
6393         LDKChannelManager channel_manager_conv;
6394         channel_manager_conv.inner = (void*)(channel_manager & (~1));
6395         channel_manager_conv.is_owned = false;
6396         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6397         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
6398         return (uint64_t)ret_conv;
6399 }
6400
6401 uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint32_t ptr) {
6402         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
6403         switch(obj->tag) {
6404                 case LDKFallback_SegWitProgram: {
6405                         uint8_t version_val = obj->seg_wit_program.version._0;
6406                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
6407                         int8_tArray program_arr = init_arr(program_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6408                         memcpy((uint8_t*)(program_arr + 4), program_var.data, program_var.datalen);
6409                         return 0 /* LDKFallback - SegWitProgram */; (void) version_val; (void) program_arr;
6410                 }
6411                 case LDKFallback_PubKeyHash: {
6412                         int8_tArray pub_key_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
6413                         memcpy((uint8_t*)(pub_key_hash_arr + 4), obj->pub_key_hash.data, 20);
6414                         return 0 /* LDKFallback - PubKeyHash */; (void) pub_key_hash_arr;
6415                 }
6416                 case LDKFallback_ScriptHash: {
6417                         int8_tArray script_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
6418                         memcpy((uint8_t*)(script_hash_arr + 4), obj->script_hash.data, 20);
6419                         return 0 /* LDKFallback - ScriptHash */; (void) script_hash_arr;
6420                 }
6421                 default: abort();
6422         }
6423 }
6424 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
6425         LDKStr ret_str = _ldk_get_compiled_version();
6426         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6427         return ret_conv;
6428 }
6429
6430 jstring  __attribute__((visibility("default"))) TS__ldk_c_bindings_get_compiled_version() {
6431         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
6432         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6433         return ret_conv;
6434 }
6435
6436 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
6437         LDKTransaction _res_ref;
6438         _res_ref.datalen = *((uint32_t*)_res);
6439         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
6440         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
6441         _res_ref.data_is_owned = true;
6442         Transaction_free(_res_ref);
6443 }
6444
6445 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
6446         if ((_res & 1) != 0) return;
6447         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
6448         FREE((void*)_res);
6449         TxOut_free(_res_conv);
6450 }
6451
6452 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
6453         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
6454         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6455         *ret_ref = TxOut_clone(orig_conv);
6456         return (uint64_t)ret_ref;
6457 }
6458
6459 void  __attribute__((visibility("default"))) TS_Str_free(jstring _res) {
6460         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
6461         Str_free(dummy);
6462 }
6463
6464 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
6465         LDKSecretKey o_ref;
6466         CHECK(*((uint32_t*)o) == 32);
6467         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
6468         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6469         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
6470         return (uint64_t)ret_conv;
6471 }
6472
6473 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
6474         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6475         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6476         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
6477         return (uint64_t)ret_conv;
6478 }
6479
6480 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
6481         if ((_res & 1) != 0) return;
6482         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
6483         FREE((void*)_res);
6484         CResult_SecretKeyErrorZ_free(_res_conv);
6485 }
6486
6487 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
6488         LDKPublicKey o_ref;
6489         CHECK(*((uint32_t*)o) == 33);
6490         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
6491         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6492         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
6493         return (uint64_t)ret_conv;
6494 }
6495
6496 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
6497         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6498         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6499         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
6500         return (uint64_t)ret_conv;
6501 }
6502
6503 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
6504         if ((_res & 1) != 0) return;
6505         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
6506         FREE((void*)_res);
6507         CResult_PublicKeyErrorZ_free(_res_conv);
6508 }
6509
6510 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
6511         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
6512         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6513         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
6514         return (uint64_t)ret_conv;
6515 }
6516
6517 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
6518         LDKTxCreationKeys o_conv;
6519         o_conv.inner = (void*)(o & (~1));
6520         o_conv.is_owned = (o & 1) || (o == 0);
6521         o_conv = TxCreationKeys_clone(&o_conv);
6522         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6523         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
6524         return (uint64_t)ret_conv;
6525 }
6526
6527 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
6528         LDKDecodeError e_conv;
6529         e_conv.inner = (void*)(e & (~1));
6530         e_conv.is_owned = (e & 1) || (e == 0);
6531         e_conv = DecodeError_clone(&e_conv);
6532         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6533         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
6534         return (uint64_t)ret_conv;
6535 }
6536
6537 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
6538         if ((_res & 1) != 0) return;
6539         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6540         FREE((void*)_res);
6541         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
6542 }
6543
6544 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
6545         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
6546         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6547         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
6548         return (uint64_t)ret_conv;
6549 }
6550
6551 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
6552         LDKChannelPublicKeys o_conv;
6553         o_conv.inner = (void*)(o & (~1));
6554         o_conv.is_owned = (o & 1) || (o == 0);
6555         o_conv = ChannelPublicKeys_clone(&o_conv);
6556         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6557         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
6558         return (uint64_t)ret_conv;
6559 }
6560
6561 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
6562         LDKDecodeError e_conv;
6563         e_conv.inner = (void*)(e & (~1));
6564         e_conv.is_owned = (e & 1) || (e == 0);
6565         e_conv = DecodeError_clone(&e_conv);
6566         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6567         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
6568         return (uint64_t)ret_conv;
6569 }
6570
6571 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
6572         if ((_res & 1) != 0) return;
6573         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6574         FREE((void*)_res);
6575         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
6576 }
6577
6578 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
6579         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
6580         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6581         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
6582         return (uint64_t)ret_conv;
6583 }
6584
6585 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
6586         LDKTxCreationKeys o_conv;
6587         o_conv.inner = (void*)(o & (~1));
6588         o_conv.is_owned = (o & 1) || (o == 0);
6589         o_conv = TxCreationKeys_clone(&o_conv);
6590         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6591         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
6592         return (uint64_t)ret_conv;
6593 }
6594
6595 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
6596         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6597         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6598         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
6599         return (uint64_t)ret_conv;
6600 }
6601
6602 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
6603         if ((_res & 1) != 0) return;
6604         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
6605         FREE((void*)_res);
6606         CResult_TxCreationKeysErrorZ_free(_res_conv);
6607 }
6608
6609 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
6610         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
6611         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6612         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
6613         return (uint64_t)ret_conv;
6614 }
6615
6616 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
6617         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6618         *ret_copy = COption_u32Z_some(o);
6619         uint64_t ret_ref = (uint64_t)ret_copy;
6620         return ret_ref;
6621 }
6622
6623 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
6624         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6625         *ret_copy = COption_u32Z_none();
6626         uint64_t ret_ref = (uint64_t)ret_copy;
6627         return ret_ref;
6628 }
6629
6630 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
6631         if ((_res & 1) != 0) return;
6632         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
6633         FREE((void*)_res);
6634         COption_u32Z_free(_res_conv);
6635 }
6636
6637 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
6638         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
6639         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6640         *ret_copy = COption_u32Z_clone(orig_conv);
6641         uint64_t ret_ref = (uint64_t)ret_copy;
6642         return ret_ref;
6643 }
6644
6645 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
6646         LDKHTLCOutputInCommitment o_conv;
6647         o_conv.inner = (void*)(o & (~1));
6648         o_conv.is_owned = (o & 1) || (o == 0);
6649         o_conv = HTLCOutputInCommitment_clone(&o_conv);
6650         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6651         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
6652         return (uint64_t)ret_conv;
6653 }
6654
6655 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
6656         LDKDecodeError e_conv;
6657         e_conv.inner = (void*)(e & (~1));
6658         e_conv.is_owned = (e & 1) || (e == 0);
6659         e_conv = DecodeError_clone(&e_conv);
6660         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6661         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
6662         return (uint64_t)ret_conv;
6663 }
6664
6665 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
6666         if ((_res & 1) != 0) return;
6667         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
6668         FREE((void*)_res);
6669         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
6670 }
6671
6672 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
6673         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
6674         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6675         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
6676         return (uint64_t)ret_conv;
6677 }
6678
6679 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
6680         LDKCounterpartyChannelTransactionParameters o_conv;
6681         o_conv.inner = (void*)(o & (~1));
6682         o_conv.is_owned = (o & 1) || (o == 0);
6683         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
6684         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6685         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6686         return (uint64_t)ret_conv;
6687 }
6688
6689 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
6690         LDKDecodeError e_conv;
6691         e_conv.inner = (void*)(e & (~1));
6692         e_conv.is_owned = (e & 1) || (e == 0);
6693         e_conv = DecodeError_clone(&e_conv);
6694         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6695         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
6696         return (uint64_t)ret_conv;
6697 }
6698
6699 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
6700         if ((_res & 1) != 0) return;
6701         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6702         FREE((void*)_res);
6703         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6704 }
6705
6706 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
6707         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6708         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6709         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6710         return (uint64_t)ret_conv;
6711 }
6712
6713 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
6714         LDKChannelTransactionParameters o_conv;
6715         o_conv.inner = (void*)(o & (~1));
6716         o_conv.is_owned = (o & 1) || (o == 0);
6717         o_conv = ChannelTransactionParameters_clone(&o_conv);
6718         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6719         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6720         return (uint64_t)ret_conv;
6721 }
6722
6723 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
6724         LDKDecodeError e_conv;
6725         e_conv.inner = (void*)(e & (~1));
6726         e_conv.is_owned = (e & 1) || (e == 0);
6727         e_conv = DecodeError_clone(&e_conv);
6728         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6729         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
6730         return (uint64_t)ret_conv;
6731 }
6732
6733 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
6734         if ((_res & 1) != 0) return;
6735         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6736         FREE((void*)_res);
6737         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6738 }
6739
6740 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
6741         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6742         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6743         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6744         return (uint64_t)ret_conv;
6745 }
6746
6747 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
6748         LDKCVec_SignatureZ _res_constr;
6749         _res_constr.datalen = *((uint32_t*)_res);
6750         if (_res_constr.datalen > 0)
6751                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6752         else
6753                 _res_constr.data = NULL;
6754         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
6755         for (size_t m = 0; m < _res_constr.datalen; m++) {
6756                 int8_tArray _res_conv_12 = _res_vals[m];
6757                 LDKSignature _res_conv_12_ref;
6758                 CHECK(*((uint32_t*)_res_conv_12) == 64);
6759                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
6760                 _res_constr.data[m] = _res_conv_12_ref;
6761         }
6762         CVec_SignatureZ_free(_res_constr);
6763 }
6764
6765 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6766         LDKHolderCommitmentTransaction o_conv;
6767         o_conv.inner = (void*)(o & (~1));
6768         o_conv.is_owned = (o & 1) || (o == 0);
6769         o_conv = HolderCommitmentTransaction_clone(&o_conv);
6770         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6771         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
6772         return (uint64_t)ret_conv;
6773 }
6774
6775 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6776         LDKDecodeError e_conv;
6777         e_conv.inner = (void*)(e & (~1));
6778         e_conv.is_owned = (e & 1) || (e == 0);
6779         e_conv = DecodeError_clone(&e_conv);
6780         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6781         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
6782         return (uint64_t)ret_conv;
6783 }
6784
6785 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6786         if ((_res & 1) != 0) return;
6787         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6788         FREE((void*)_res);
6789         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
6790 }
6791
6792 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6793         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6794         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6795         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6796         return (uint64_t)ret_conv;
6797 }
6798
6799 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6800         LDKBuiltCommitmentTransaction o_conv;
6801         o_conv.inner = (void*)(o & (~1));
6802         o_conv.is_owned = (o & 1) || (o == 0);
6803         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
6804         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6805         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
6806         return (uint64_t)ret_conv;
6807 }
6808
6809 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6810         LDKDecodeError e_conv;
6811         e_conv.inner = (void*)(e & (~1));
6812         e_conv.is_owned = (e & 1) || (e == 0);
6813         e_conv = DecodeError_clone(&e_conv);
6814         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6815         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
6816         return (uint64_t)ret_conv;
6817 }
6818
6819 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6820         if ((_res & 1) != 0) return;
6821         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6822         FREE((void*)_res);
6823         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
6824 }
6825
6826 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6827         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6828         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6829         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6830         return (uint64_t)ret_conv;
6831 }
6832
6833 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6834         LDKCommitmentTransaction o_conv;
6835         o_conv.inner = (void*)(o & (~1));
6836         o_conv.is_owned = (o & 1) || (o == 0);
6837         o_conv = CommitmentTransaction_clone(&o_conv);
6838         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6839         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
6840         return (uint64_t)ret_conv;
6841 }
6842
6843 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6844         LDKDecodeError e_conv;
6845         e_conv.inner = (void*)(e & (~1));
6846         e_conv.is_owned = (e & 1) || (e == 0);
6847         e_conv = DecodeError_clone(&e_conv);
6848         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6849         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
6850         return (uint64_t)ret_conv;
6851 }
6852
6853 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6854         if ((_res & 1) != 0) return;
6855         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6856         FREE((void*)_res);
6857         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
6858 }
6859
6860 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6861         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
6862         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6863         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
6864         return (uint64_t)ret_conv;
6865 }
6866
6867 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
6868         LDKTrustedCommitmentTransaction o_conv;
6869         o_conv.inner = (void*)(o & (~1));
6870         o_conv.is_owned = (o & 1) || (o == 0);
6871         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
6872         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6873         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
6874         return (uint64_t)ret_conv;
6875 }
6876
6877 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
6878         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6879         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
6880         return (uint64_t)ret_conv;
6881 }
6882
6883 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
6884         if ((_res & 1) != 0) return;
6885         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
6886         FREE((void*)_res);
6887         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
6888 }
6889
6890 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
6891         LDKCVec_SignatureZ o_constr;
6892         o_constr.datalen = *((uint32_t*)o);
6893         if (o_constr.datalen > 0)
6894                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6895         else
6896                 o_constr.data = NULL;
6897         int8_tArray* o_vals = (int8_tArray*)(o + 4);
6898         for (size_t m = 0; m < o_constr.datalen; m++) {
6899                 int8_tArray o_conv_12 = o_vals[m];
6900                 LDKSignature o_conv_12_ref;
6901                 CHECK(*((uint32_t*)o_conv_12) == 64);
6902                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
6903                 o_constr.data[m] = o_conv_12_ref;
6904         }
6905         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6906         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
6907         return (uint64_t)ret_conv;
6908 }
6909
6910 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
6911         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6912         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
6913         return (uint64_t)ret_conv;
6914 }
6915
6916 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
6917         if ((_res & 1) != 0) return;
6918         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
6919         FREE((void*)_res);
6920         CResult_CVec_SignatureZNoneZ_free(_res_conv);
6921 }
6922
6923 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
6924         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
6925         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6926         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
6927         return (uint64_t)ret_conv;
6928 }
6929
6930 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
6931         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6932         *ret_conv = CResult_NoneErrorZ_ok();
6933         return (uint64_t)ret_conv;
6934 }
6935
6936 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
6937         LDKIOError e_conv = LDKIOError_from_js(e);
6938         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6939         *ret_conv = CResult_NoneErrorZ_err(e_conv);
6940         return (uint64_t)ret_conv;
6941 }
6942
6943 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
6944         if ((_res & 1) != 0) return;
6945         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
6946         FREE((void*)_res);
6947         CResult_NoneErrorZ_free(_res_conv);
6948 }
6949
6950 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
6951         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
6952         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6953         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
6954         return (uint64_t)ret_conv;
6955 }
6956
6957 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
6958         LDKRouteHop o_conv;
6959         o_conv.inner = (void*)(o & (~1));
6960         o_conv.is_owned = (o & 1) || (o == 0);
6961         o_conv = RouteHop_clone(&o_conv);
6962         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
6963         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
6964         return (uint64_t)ret_conv;
6965 }
6966
6967 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
6968         LDKDecodeError e_conv;
6969         e_conv.inner = (void*)(e & (~1));
6970         e_conv.is_owned = (e & 1) || (e == 0);
6971         e_conv = DecodeError_clone(&e_conv);
6972         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
6973         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
6974         return (uint64_t)ret_conv;
6975 }
6976
6977 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
6978         if ((_res & 1) != 0) return;
6979         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
6980         FREE((void*)_res);
6981         CResult_RouteHopDecodeErrorZ_free(_res_conv);
6982 }
6983
6984 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
6985         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
6986         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
6987         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
6988         return (uint64_t)ret_conv;
6989 }
6990
6991 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
6992         LDKCVec_RouteHopZ _res_constr;
6993         _res_constr.datalen = *((uint32_t*)_res);
6994         if (_res_constr.datalen > 0)
6995                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
6996         else
6997                 _res_constr.data = NULL;
6998         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6999         for (size_t k = 0; k < _res_constr.datalen; k++) {
7000                 uint32_t _res_conv_10 = _res_vals[k];
7001                 LDKRouteHop _res_conv_10_conv;
7002                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
7003                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
7004                 _res_constr.data[k] = _res_conv_10_conv;
7005         }
7006         CVec_RouteHopZ_free(_res_constr);
7007 }
7008
7009 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
7010         LDKCVec_CVec_RouteHopZZ _res_constr;
7011         _res_constr.datalen = *((uint32_t*)_res);
7012         if (_res_constr.datalen > 0)
7013                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
7014         else
7015                 _res_constr.data = NULL;
7016         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
7017         for (size_t m = 0; m < _res_constr.datalen; m++) {
7018                 uint32_tArray _res_conv_12 = _res_vals[m];
7019                 LDKCVec_RouteHopZ _res_conv_12_constr;
7020                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
7021                 if (_res_conv_12_constr.datalen > 0)
7022                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7023                 else
7024                         _res_conv_12_constr.data = NULL;
7025                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
7026                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
7027                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
7028                         LDKRouteHop _res_conv_12_conv_10_conv;
7029                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
7030                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
7031                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
7032                 }
7033                 _res_constr.data[m] = _res_conv_12_constr;
7034         }
7035         CVec_CVec_RouteHopZZ_free(_res_constr);
7036 }
7037
7038 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
7039         LDKRoute o_conv;
7040         o_conv.inner = (void*)(o & (~1));
7041         o_conv.is_owned = (o & 1) || (o == 0);
7042         o_conv = Route_clone(&o_conv);
7043         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7044         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7045         return (uint64_t)ret_conv;
7046 }
7047
7048 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
7049         LDKDecodeError e_conv;
7050         e_conv.inner = (void*)(e & (~1));
7051         e_conv.is_owned = (e & 1) || (e == 0);
7052         e_conv = DecodeError_clone(&e_conv);
7053         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7054         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7055         return (uint64_t)ret_conv;
7056 }
7057
7058 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
7059         if ((_res & 1) != 0) return;
7060         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7061         FREE((void*)_res);
7062         CResult_RouteDecodeErrorZ_free(_res_conv);
7063 }
7064
7065 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
7066         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7067         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7068         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7069         return (uint64_t)ret_conv;
7070 }
7071
7072 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
7073         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7074         *ret_copy = COption_u64Z_some(o);
7075         uint64_t ret_ref = (uint64_t)ret_copy;
7076         return ret_ref;
7077 }
7078
7079 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
7080         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7081         *ret_copy = COption_u64Z_none();
7082         uint64_t ret_ref = (uint64_t)ret_copy;
7083         return ret_ref;
7084 }
7085
7086 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
7087         if ((_res & 1) != 0) return;
7088         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
7089         FREE((void*)_res);
7090         COption_u64Z_free(_res_conv);
7091 }
7092
7093 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
7094         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
7095         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7096         *ret_copy = COption_u64Z_clone(orig_conv);
7097         uint64_t ret_ref = (uint64_t)ret_copy;
7098         return ret_ref;
7099 }
7100
7101 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
7102         LDKCVec_ChannelDetailsZ _res_constr;
7103         _res_constr.datalen = *((uint32_t*)_res);
7104         if (_res_constr.datalen > 0)
7105                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7106         else
7107                 _res_constr.data = NULL;
7108         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7109         for (size_t q = 0; q < _res_constr.datalen; q++) {
7110                 uint32_t _res_conv_16 = _res_vals[q];
7111                 LDKChannelDetails _res_conv_16_conv;
7112                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7113                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7114                 _res_constr.data[q] = _res_conv_16_conv;
7115         }
7116         CVec_ChannelDetailsZ_free(_res_constr);
7117 }
7118
7119 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
7120         LDKCVec_RouteHintZ _res_constr;
7121         _res_constr.datalen = *((uint32_t*)_res);
7122         if (_res_constr.datalen > 0)
7123                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7124         else
7125                 _res_constr.data = NULL;
7126         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7127         for (size_t l = 0; l < _res_constr.datalen; l++) {
7128                 uint32_t _res_conv_11 = _res_vals[l];
7129                 LDKRouteHint _res_conv_11_conv;
7130                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
7131                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
7132                 _res_constr.data[l] = _res_conv_11_conv;
7133         }
7134         CVec_RouteHintZ_free(_res_constr);
7135 }
7136
7137 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
7138         LDKRoute o_conv;
7139         o_conv.inner = (void*)(o & (~1));
7140         o_conv.is_owned = (o & 1) || (o == 0);
7141         o_conv = Route_clone(&o_conv);
7142         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7143         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
7144         return (uint64_t)ret_conv;
7145 }
7146
7147 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
7148         LDKLightningError e_conv;
7149         e_conv.inner = (void*)(e & (~1));
7150         e_conv.is_owned = (e & 1) || (e == 0);
7151         e_conv = LightningError_clone(&e_conv);
7152         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7153         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
7154         return (uint64_t)ret_conv;
7155 }
7156
7157 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
7158         if ((_res & 1) != 0) return;
7159         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
7160         FREE((void*)_res);
7161         CResult_RouteLightningErrorZ_free(_res_conv);
7162 }
7163
7164 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
7165         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
7166         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7167         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
7168         return (uint64_t)ret_conv;
7169 }
7170
7171 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
7172         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
7173         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7174         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
7175         return (uint64_t)ret_conv;
7176 }
7177
7178 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
7179         LDKAccessError e_conv = LDKAccessError_from_js(e);
7180         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7181         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
7182         return (uint64_t)ret_conv;
7183 }
7184
7185 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
7186         if ((_res & 1) != 0) return;
7187         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
7188         FREE((void*)_res);
7189         CResult_TxOutAccessErrorZ_free(_res_conv);
7190 }
7191
7192 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
7193         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
7194         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7195         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
7196         return (uint64_t)ret_conv;
7197 }
7198
7199 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
7200         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
7201         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7202         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
7203         return (uint64_t)ret_ref;
7204 }
7205
7206 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
7207         LDKTransaction b_ref;
7208         b_ref.datalen = *((uint32_t*)b);
7209         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
7210         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
7211         b_ref.data_is_owned = true;
7212         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7213         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
7214         return (uint64_t)ret_ref;
7215 }
7216
7217 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
7218         if ((_res & 1) != 0) return;
7219         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
7220         FREE((void*)_res);
7221         C2Tuple_usizeTransactionZ_free(_res_conv);
7222 }
7223
7224 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
7225         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
7226         _res_constr.datalen = *((uint32_t*)_res);
7227         if (_res_constr.datalen > 0)
7228                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7229         else
7230                 _res_constr.data = NULL;
7231         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7232         for (size_t e = 0; e < _res_constr.datalen; e++) {
7233                 uint32_t _res_conv_30 = _res_vals[e];
7234                 LDKC2Tuple_usizeTransactionZ _res_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_30) & ~1);
7235                 FREE((void*)_res_conv_30);
7236                 _res_constr.data[e] = _res_conv_30_conv;
7237         }
7238         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
7239 }
7240
7241 void  __attribute__((visibility("default"))) TS_CVec_TxidZ_free(ptrArray _res) {
7242         LDKCVec_TxidZ _res_constr;
7243         _res_constr.datalen = *((uint32_t*)_res);
7244         if (_res_constr.datalen > 0)
7245                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7246         else
7247                 _res_constr.data = NULL;
7248         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7249         for (size_t m = 0; m < _res_constr.datalen; m++) {
7250                 int8_tArray _res_conv_12 = _res_vals[m];
7251                 LDKThirtyTwoBytes _res_conv_12_ref;
7252                 CHECK(*((uint32_t*)_res_conv_12) == 32);
7253                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), 32);
7254                 _res_constr.data[m] = _res_conv_12_ref;
7255         }
7256         CVec_TxidZ_free(_res_constr);
7257 }
7258
7259 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
7260         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7261         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
7262         return (uint64_t)ret_conv;
7263 }
7264
7265 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
7266         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
7267         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7268         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
7269         return (uint64_t)ret_conv;
7270 }
7271
7272 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
7273         if ((_res & 1) != 0) return;
7274         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
7275         FREE((void*)_res);
7276         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
7277 }
7278
7279 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
7280         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
7281         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7282         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
7283         return (uint64_t)ret_conv;
7284 }
7285
7286 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
7287         LDKCVec_MonitorEventZ _res_constr;
7288         _res_constr.datalen = *((uint32_t*)_res);
7289         if (_res_constr.datalen > 0)
7290                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
7291         else
7292                 _res_constr.data = NULL;
7293         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7294         for (size_t o = 0; o < _res_constr.datalen; o++) {
7295                 uint32_t _res_conv_14 = _res_vals[o];
7296                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
7297                 FREE((void*)_res_conv_14);
7298                 _res_constr.data[o] = _res_conv_14_conv;
7299         }
7300         CVec_MonitorEventZ_free(_res_constr);
7301 }
7302
7303 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
7304         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
7305         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7306         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
7307         uint64_t ret_ref = (uint64_t)ret_copy;
7308         return ret_ref;
7309 }
7310
7311 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
7312         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7313         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
7314         uint64_t ret_ref = (uint64_t)ret_copy;
7315         return ret_ref;
7316 }
7317
7318 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
7319         if ((_res & 1) != 0) return;
7320         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
7321         FREE((void*)_res);
7322         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
7323 }
7324
7325 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
7326         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
7327         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7328         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
7329         uint64_t ret_ref = (uint64_t)ret_copy;
7330         return ret_ref;
7331 }
7332
7333 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
7334         LDKCVec_SpendableOutputDescriptorZ _res_constr;
7335         _res_constr.datalen = *((uint32_t*)_res);
7336         if (_res_constr.datalen > 0)
7337                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
7338         else
7339                 _res_constr.data = NULL;
7340         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7341         for (size_t b = 0; b < _res_constr.datalen; b++) {
7342                 uint32_t _res_conv_27 = _res_vals[b];
7343                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
7344                 FREE((void*)_res_conv_27);
7345                 _res_constr.data[b] = _res_conv_27_conv;
7346         }
7347         CVec_SpendableOutputDescriptorZ_free(_res_constr);
7348 }
7349
7350 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
7351         LDKCVec_MessageSendEventZ _res_constr;
7352         _res_constr.datalen = *((uint32_t*)_res);
7353         if (_res_constr.datalen > 0)
7354                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7355         else
7356                 _res_constr.data = NULL;
7357         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7358         for (size_t s = 0; s < _res_constr.datalen; s++) {
7359                 uint32_t _res_conv_18 = _res_vals[s];
7360                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
7361                 FREE((void*)_res_conv_18);
7362                 _res_constr.data[s] = _res_conv_18_conv;
7363         }
7364         CVec_MessageSendEventZ_free(_res_constr);
7365 }
7366
7367 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
7368         LDKInitFeatures o_conv;
7369         o_conv.inner = (void*)(o & (~1));
7370         o_conv.is_owned = (o & 1) || (o == 0);
7371         o_conv = InitFeatures_clone(&o_conv);
7372         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7373         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
7374         return (uint64_t)ret_conv;
7375 }
7376
7377 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
7378         LDKDecodeError e_conv;
7379         e_conv.inner = (void*)(e & (~1));
7380         e_conv.is_owned = (e & 1) || (e == 0);
7381         e_conv = DecodeError_clone(&e_conv);
7382         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7383         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
7384         return (uint64_t)ret_conv;
7385 }
7386
7387 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
7388         if ((_res & 1) != 0) return;
7389         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7390         FREE((void*)_res);
7391         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
7392 }
7393
7394 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
7395         LDKNodeFeatures o_conv;
7396         o_conv.inner = (void*)(o & (~1));
7397         o_conv.is_owned = (o & 1) || (o == 0);
7398         o_conv = NodeFeatures_clone(&o_conv);
7399         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7400         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
7401         return (uint64_t)ret_conv;
7402 }
7403
7404 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
7405         LDKDecodeError e_conv;
7406         e_conv.inner = (void*)(e & (~1));
7407         e_conv.is_owned = (e & 1) || (e == 0);
7408         e_conv = DecodeError_clone(&e_conv);
7409         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7410         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
7411         return (uint64_t)ret_conv;
7412 }
7413
7414 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
7415         if ((_res & 1) != 0) return;
7416         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7417         FREE((void*)_res);
7418         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
7419 }
7420
7421 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
7422         LDKChannelFeatures o_conv;
7423         o_conv.inner = (void*)(o & (~1));
7424         o_conv.is_owned = (o & 1) || (o == 0);
7425         o_conv = ChannelFeatures_clone(&o_conv);
7426         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7427         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
7428         return (uint64_t)ret_conv;
7429 }
7430
7431 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
7432         LDKDecodeError e_conv;
7433         e_conv.inner = (void*)(e & (~1));
7434         e_conv.is_owned = (e & 1) || (e == 0);
7435         e_conv = DecodeError_clone(&e_conv);
7436         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7437         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
7438         return (uint64_t)ret_conv;
7439 }
7440
7441 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
7442         if ((_res & 1) != 0) return;
7443         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7444         FREE((void*)_res);
7445         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
7446 }
7447
7448 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
7449         LDKInvoiceFeatures o_conv;
7450         o_conv.inner = (void*)(o & (~1));
7451         o_conv.is_owned = (o & 1) || (o == 0);
7452         o_conv = InvoiceFeatures_clone(&o_conv);
7453         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7454         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
7455         return (uint64_t)ret_conv;
7456 }
7457
7458 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
7459         LDKDecodeError e_conv;
7460         e_conv.inner = (void*)(e & (~1));
7461         e_conv.is_owned = (e & 1) || (e == 0);
7462         e_conv = DecodeError_clone(&e_conv);
7463         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7464         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
7465         return (uint64_t)ret_conv;
7466 }
7467
7468 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
7469         if ((_res & 1) != 0) return;
7470         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7471         FREE((void*)_res);
7472         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
7473 }
7474
7475 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7476         LDKDelayedPaymentOutputDescriptor o_conv;
7477         o_conv.inner = (void*)(o & (~1));
7478         o_conv.is_owned = (o & 1) || (o == 0);
7479         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
7480         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7481         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
7482         return (uint64_t)ret_conv;
7483 }
7484
7485 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7486         LDKDecodeError e_conv;
7487         e_conv.inner = (void*)(e & (~1));
7488         e_conv.is_owned = (e & 1) || (e == 0);
7489         e_conv = DecodeError_clone(&e_conv);
7490         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7491         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
7492         return (uint64_t)ret_conv;
7493 }
7494
7495 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7496         if ((_res & 1) != 0) return;
7497         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7498         FREE((void*)_res);
7499         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
7500 }
7501
7502 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7503         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
7504         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7505         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
7506         return (uint64_t)ret_conv;
7507 }
7508
7509 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7510         LDKStaticPaymentOutputDescriptor o_conv;
7511         o_conv.inner = (void*)(o & (~1));
7512         o_conv.is_owned = (o & 1) || (o == 0);
7513         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
7514         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7515         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
7516         return (uint64_t)ret_conv;
7517 }
7518
7519 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7520         LDKDecodeError e_conv;
7521         e_conv.inner = (void*)(e & (~1));
7522         e_conv.is_owned = (e & 1) || (e == 0);
7523         e_conv = DecodeError_clone(&e_conv);
7524         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7525         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
7526         return (uint64_t)ret_conv;
7527 }
7528
7529 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7530         if ((_res & 1) != 0) return;
7531         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7532         FREE((void*)_res);
7533         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
7534 }
7535
7536 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7537         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
7538         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7539         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
7540         return (uint64_t)ret_conv;
7541 }
7542
7543 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7544         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
7545         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7546         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
7547         return (uint64_t)ret_conv;
7548 }
7549
7550 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7551         LDKDecodeError e_conv;
7552         e_conv.inner = (void*)(e & (~1));
7553         e_conv.is_owned = (e & 1) || (e == 0);
7554         e_conv = DecodeError_clone(&e_conv);
7555         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7556         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
7557         return (uint64_t)ret_conv;
7558 }
7559
7560 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7561         if ((_res & 1) != 0) return;
7562         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7563         FREE((void*)_res);
7564         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
7565 }
7566
7567 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7568         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
7569         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7570         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
7571         return (uint64_t)ret_conv;
7572 }
7573
7574 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
7575         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
7576         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7577         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
7578         return (uint64_t)ret_ref;
7579 }
7580
7581 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
7582         LDKSignature a_ref;
7583         CHECK(*((uint32_t*)a) == 64);
7584         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
7585         LDKCVec_SignatureZ b_constr;
7586         b_constr.datalen = *((uint32_t*)b);
7587         if (b_constr.datalen > 0)
7588                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7589         else
7590                 b_constr.data = NULL;
7591         int8_tArray* b_vals = (int8_tArray*)(b + 4);
7592         for (size_t m = 0; m < b_constr.datalen; m++) {
7593                 int8_tArray b_conv_12 = b_vals[m];
7594                 LDKSignature b_conv_12_ref;
7595                 CHECK(*((uint32_t*)b_conv_12) == 64);
7596                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
7597                 b_constr.data[m] = b_conv_12_ref;
7598         }
7599         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7600         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
7601         return (uint64_t)ret_ref;
7602 }
7603
7604 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
7605         if ((_res & 1) != 0) return;
7606         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
7607         FREE((void*)_res);
7608         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
7609 }
7610
7611 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
7612         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
7613         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7614         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
7615         return (uint64_t)ret_conv;
7616 }
7617
7618 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
7619         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7620         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
7621         return (uint64_t)ret_conv;
7622 }
7623
7624 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
7625         if ((_res & 1) != 0) return;
7626         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
7627         FREE((void*)_res);
7628         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
7629 }
7630
7631 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
7632         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
7633         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7634         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
7635         return (uint64_t)ret_conv;
7636 }
7637
7638 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
7639         LDKSignature o_ref;
7640         CHECK(*((uint32_t*)o) == 64);
7641         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
7642         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7643         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
7644         return (uint64_t)ret_conv;
7645 }
7646
7647 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
7648         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7649         *ret_conv = CResult_SignatureNoneZ_err();
7650         return (uint64_t)ret_conv;
7651 }
7652
7653 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
7654         if ((_res & 1) != 0) return;
7655         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
7656         FREE((void*)_res);
7657         CResult_SignatureNoneZ_free(_res_conv);
7658 }
7659
7660 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
7661         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
7662         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7663         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
7664         return (uint64_t)ret_conv;
7665 }
7666
7667 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
7668         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
7669         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7670         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
7671         return (uint64_t)ret_conv;
7672 }
7673
7674 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
7675         LDKDecodeError e_conv;
7676         e_conv.inner = (void*)(e & (~1));
7677         e_conv.is_owned = (e & 1) || (e == 0);
7678         e_conv = DecodeError_clone(&e_conv);
7679         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7680         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
7681         return (uint64_t)ret_conv;
7682 }
7683
7684 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
7685         if ((_res & 1) != 0) return;
7686         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
7687         FREE((void*)_res);
7688         CResult_SignDecodeErrorZ_free(_res_conv);
7689 }
7690
7691 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
7692         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
7693         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7694         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
7695         return (uint64_t)ret_conv;
7696 }
7697
7698 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
7699         LDKCVec_u8Z _res_ref;
7700         _res_ref.datalen = *((uint32_t*)_res);
7701         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
7702         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
7703         CVec_u8Z_free(_res_ref);
7704 }
7705
7706 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray arg) {
7707         LDKRecoverableSignature arg_ref;
7708         CHECK(*((uint32_t*)arg) == 68);
7709         memcpy(arg_ref.serialized_form, (uint8_t*)(arg + 4), 68);
7710         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7711         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
7712         return (uint64_t)ret_conv;
7713 }
7714
7715 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_err() {
7716         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7717         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
7718         return (uint64_t)ret_conv;
7719 }
7720
7721 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
7722         if ((_res & 1) != 0) return;
7723         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
7724         FREE((void*)_res);
7725         CResult_RecoverableSignatureNoneZ_free(_res_conv);
7726 }
7727
7728 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
7729         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
7730         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7731         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
7732         return (uint64_t)ret_conv;
7733 }
7734
7735 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
7736         LDKCVec_CVec_u8ZZ _res_constr;
7737         _res_constr.datalen = *((uint32_t*)_res);
7738         if (_res_constr.datalen > 0)
7739                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7740         else
7741                 _res_constr.data = NULL;
7742         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7743         for (size_t m = 0; m < _res_constr.datalen; m++) {
7744                 int8_tArray _res_conv_12 = _res_vals[m];
7745                 LDKCVec_u8Z _res_conv_12_ref;
7746                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
7747                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7748                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
7749                 _res_constr.data[m] = _res_conv_12_ref;
7750         }
7751         CVec_CVec_u8ZZ_free(_res_constr);
7752 }
7753
7754 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
7755         LDKCVec_CVec_u8ZZ o_constr;
7756         o_constr.datalen = *((uint32_t*)o);
7757         if (o_constr.datalen > 0)
7758                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7759         else
7760                 o_constr.data = NULL;
7761         int8_tArray* o_vals = (int8_tArray*)(o + 4);
7762         for (size_t m = 0; m < o_constr.datalen; m++) {
7763                 int8_tArray o_conv_12 = o_vals[m];
7764                 LDKCVec_u8Z o_conv_12_ref;
7765                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
7766                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7767                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
7768                 o_constr.data[m] = o_conv_12_ref;
7769         }
7770         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7771         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
7772         return (uint64_t)ret_conv;
7773 }
7774
7775 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
7776         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7777         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
7778         return (uint64_t)ret_conv;
7779 }
7780
7781 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
7782         if ((_res & 1) != 0) return;
7783         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
7784         FREE((void*)_res);
7785         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
7786 }
7787
7788 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
7789         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
7790         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7791         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
7792         return (uint64_t)ret_conv;
7793 }
7794
7795 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
7796         LDKInMemorySigner o_conv;
7797         o_conv.inner = (void*)(o & (~1));
7798         o_conv.is_owned = (o & 1) || (o == 0);
7799         o_conv = InMemorySigner_clone(&o_conv);
7800         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7801         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
7802         return (uint64_t)ret_conv;
7803 }
7804
7805 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
7806         LDKDecodeError e_conv;
7807         e_conv.inner = (void*)(e & (~1));
7808         e_conv.is_owned = (e & 1) || (e == 0);
7809         e_conv = DecodeError_clone(&e_conv);
7810         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7811         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
7812         return (uint64_t)ret_conv;
7813 }
7814
7815 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
7816         if ((_res & 1) != 0) return;
7817         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
7818         FREE((void*)_res);
7819         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
7820 }
7821
7822 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
7823         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
7824         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7825         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
7826         return (uint64_t)ret_conv;
7827 }
7828
7829 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
7830         LDKCVec_TxOutZ _res_constr;
7831         _res_constr.datalen = *((uint32_t*)_res);
7832         if (_res_constr.datalen > 0)
7833                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
7834         else
7835                 _res_constr.data = NULL;
7836         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7837         for (size_t h = 0; h < _res_constr.datalen; h++) {
7838                 uint32_t _res_conv_7 = _res_vals[h];
7839                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
7840                 FREE((void*)_res_conv_7);
7841                 _res_constr.data[h] = _res_conv_7_conv;
7842         }
7843         CVec_TxOutZ_free(_res_constr);
7844 }
7845
7846 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
7847         LDKTransaction o_ref;
7848         o_ref.datalen = *((uint32_t*)o);
7849         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
7850         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
7851         o_ref.data_is_owned = true;
7852         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7853         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
7854         return (uint64_t)ret_conv;
7855 }
7856
7857 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
7858         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7859         *ret_conv = CResult_TransactionNoneZ_err();
7860         return (uint64_t)ret_conv;
7861 }
7862
7863 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
7864         if ((_res & 1) != 0) return;
7865         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
7866         FREE((void*)_res);
7867         CResult_TransactionNoneZ_free(_res_conv);
7868 }
7869
7870 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
7871         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
7872         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7873         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
7874         return (uint64_t)ret_conv;
7875 }
7876
7877 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
7878         LDKThirtyTwoBytes a_ref;
7879         CHECK(*((uint32_t*)a) == 32);
7880         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
7881         LDKChannelMonitor b_conv;
7882         b_conv.inner = (void*)(b & (~1));
7883         b_conv.is_owned = (b & 1) || (b == 0);
7884         b_conv = ChannelMonitor_clone(&b_conv);
7885         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7886         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
7887         return (uint64_t)ret_ref;
7888 }
7889
7890 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
7891         if ((_res & 1) != 0) return;
7892         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
7893         FREE((void*)_res);
7894         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
7895 }
7896
7897 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMonitorZZ_free(uint32_tArray _res) {
7898         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
7899         _res_constr.datalen = *((uint32_t*)_res);
7900         if (_res_constr.datalen > 0)
7901                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
7902         else
7903                 _res_constr.data = NULL;
7904         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7905         for (size_t m = 0; m < _res_constr.datalen; m++) {
7906                 uint32_t _res_conv_38 = _res_vals[m];
7907                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_38) & ~1);
7908                 FREE((void*)_res_conv_38);
7909                 _res_constr.data[m] = _res_conv_38_conv;
7910         }
7911         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
7912 }
7913
7914 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(uint32_tArray o) {
7915         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
7916         o_constr.datalen = *((uint32_t*)o);
7917         if (o_constr.datalen > 0)
7918                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
7919         else
7920                 o_constr.data = NULL;
7921         uint32_t* o_vals = (uint32_t*)(o + 4);
7922         for (size_t m = 0; m < o_constr.datalen; m++) {
7923                 uint32_t o_conv_38 = o_vals[m];
7924                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_38) & ~1);
7925                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
7926                 o_constr.data[m] = o_conv_38_conv;
7927         }
7928         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
7929         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
7930         return (uint64_t)ret_conv;
7931 }
7932
7933 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(uint32_t e) {
7934         LDKIOError e_conv = LDKIOError_from_js(e);
7935         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
7936         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
7937         return (uint64_t)ret_conv;
7938 }
7939
7940 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
7941         if ((_res & 1) != 0) return;
7942         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
7943         FREE((void*)_res);
7944         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
7945 }
7946
7947 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) {
7948         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
7949         *ret_copy = COption_u16Z_some(o);
7950         uint64_t ret_ref = (uint64_t)ret_copy;
7951         return ret_ref;
7952 }
7953
7954 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_none() {
7955         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
7956         *ret_copy = COption_u16Z_none();
7957         uint64_t ret_ref = (uint64_t)ret_copy;
7958         return ret_ref;
7959 }
7960
7961 void  __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) {
7962         if ((_res & 1) != 0) return;
7963         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
7964         FREE((void*)_res);
7965         COption_u16Z_free(_res_conv);
7966 }
7967
7968 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_clone(uint32_t orig) {
7969         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
7970         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
7971         *ret_copy = COption_u16Z_clone(orig_conv);
7972         uint64_t ret_ref = (uint64_t)ret_copy;
7973         return ret_ref;
7974 }
7975
7976 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
7977         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7978         *ret_conv = CResult_NoneAPIErrorZ_ok();
7979         return (uint64_t)ret_conv;
7980 }
7981
7982 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
7983         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
7984         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7985         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
7986         return (uint64_t)ret_conv;
7987 }
7988
7989 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
7990         if ((_res & 1) != 0) return;
7991         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
7992         FREE((void*)_res);
7993         CResult_NoneAPIErrorZ_free(_res_conv);
7994 }
7995
7996 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
7997         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
7998         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7999         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
8000         return (uint64_t)ret_conv;
8001 }
8002
8003 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
8004         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
8005         _res_constr.datalen = *((uint32_t*)_res);
8006         if (_res_constr.datalen > 0)
8007                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
8008         else
8009                 _res_constr.data = NULL;
8010         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8011         for (size_t w = 0; w < _res_constr.datalen; w++) {
8012                 uint32_t _res_conv_22 = _res_vals[w];
8013                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
8014                 FREE((void*)_res_conv_22);
8015                 _res_constr.data[w] = _res_conv_22_conv;
8016         }
8017         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
8018 }
8019
8020 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
8021         LDKCVec_APIErrorZ _res_constr;
8022         _res_constr.datalen = *((uint32_t*)_res);
8023         if (_res_constr.datalen > 0)
8024                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
8025         else
8026                 _res_constr.data = NULL;
8027         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8028         for (size_t k = 0; k < _res_constr.datalen; k++) {
8029                 uint32_t _res_conv_10 = _res_vals[k];
8030                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
8031                 FREE((void*)_res_conv_10);
8032                 _res_constr.data[k] = _res_conv_10_conv;
8033         }
8034         CVec_APIErrorZ_free(_res_constr);
8035 }
8036
8037 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
8038         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8039         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
8040         return (uint64_t)ret_conv;
8041 }
8042
8043 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
8044         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
8045         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8046         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
8047         return (uint64_t)ret_conv;
8048 }
8049
8050 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
8051         if ((_res & 1) != 0) return;
8052         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
8053         FREE((void*)_res);
8054         CResult_NonePaymentSendFailureZ_free(_res_conv);
8055 }
8056
8057 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
8058         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
8059         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8060         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
8061         return (uint64_t)ret_conv;
8062 }
8063
8064 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
8065         LDKCVec_NetAddressZ _res_constr;
8066         _res_constr.datalen = *((uint32_t*)_res);
8067         if (_res_constr.datalen > 0)
8068                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
8069         else
8070                 _res_constr.data = NULL;
8071         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8072         for (size_t m = 0; m < _res_constr.datalen; m++) {
8073                 uint32_t _res_conv_12 = _res_vals[m];
8074                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
8075                 FREE((void*)_res_conv_12);
8076                 _res_constr.data[m] = _res_conv_12_conv;
8077         }
8078         CVec_NetAddressZ_free(_res_constr);
8079 }
8080
8081 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
8082         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
8083         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
8084         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
8085         return (uint64_t)ret_ref;
8086 }
8087
8088 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
8089         LDKThirtyTwoBytes a_ref;
8090         CHECK(*((uint32_t*)a) == 32);
8091         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8092         LDKThirtyTwoBytes b_ref;
8093         CHECK(*((uint32_t*)b) == 32);
8094         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
8095         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
8096         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
8097         return (uint64_t)ret_ref;
8098 }
8099
8100 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
8101         if ((_res & 1) != 0) return;
8102         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
8103         FREE((void*)_res);
8104         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
8105 }
8106
8107 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
8108         LDKThirtyTwoBytes o_ref;
8109         CHECK(*((uint32_t*)o) == 32);
8110         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
8111         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8112         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
8113         return (uint64_t)ret_conv;
8114 }
8115
8116 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
8117         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
8118         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8119         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
8120         return (uint64_t)ret_conv;
8121 }
8122
8123 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
8124         if ((_res & 1) != 0) return;
8125         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
8126         FREE((void*)_res);
8127         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
8128 }
8129
8130 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
8131         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
8132         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8133         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
8134         return (uint64_t)ret_conv;
8135 }
8136
8137 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
8138         LDKCVec_ChannelMonitorZ _res_constr;
8139         _res_constr.datalen = *((uint32_t*)_res);
8140         if (_res_constr.datalen > 0)
8141                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
8142         else
8143                 _res_constr.data = NULL;
8144         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8145         for (size_t q = 0; q < _res_constr.datalen; q++) {
8146                 uint32_t _res_conv_16 = _res_vals[q];
8147                 LDKChannelMonitor _res_conv_16_conv;
8148                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8149                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8150                 _res_constr.data[q] = _res_conv_16_conv;
8151         }
8152         CVec_ChannelMonitorZ_free(_res_constr);
8153 }
8154
8155 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
8156         LDKThirtyTwoBytes a_ref;
8157         CHECK(*((uint32_t*)a) == 32);
8158         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8159         LDKChannelManager b_conv;
8160         b_conv.inner = (void*)(b & (~1));
8161         b_conv.is_owned = (b & 1) || (b == 0);
8162         // Warning: we need a move here but no clone is available for LDKChannelManager
8163         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
8164         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
8165         return (uint64_t)ret_ref;
8166 }
8167
8168 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
8169         if ((_res & 1) != 0) return;
8170         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
8171         FREE((void*)_res);
8172         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
8173 }
8174
8175 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
8176         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
8177         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8178         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
8179         return (uint64_t)ret_conv;
8180 }
8181
8182 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
8183         LDKDecodeError e_conv;
8184         e_conv.inner = (void*)(e & (~1));
8185         e_conv.is_owned = (e & 1) || (e == 0);
8186         e_conv = DecodeError_clone(&e_conv);
8187         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8188         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
8189         return (uint64_t)ret_conv;
8190 }
8191
8192 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
8193         if ((_res & 1) != 0) return;
8194         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8195         FREE((void*)_res);
8196         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
8197 }
8198
8199 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
8200         LDKChannelConfig o_conv;
8201         o_conv.inner = (void*)(o & (~1));
8202         o_conv.is_owned = (o & 1) || (o == 0);
8203         o_conv = ChannelConfig_clone(&o_conv);
8204         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8205         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
8206         return (uint64_t)ret_conv;
8207 }
8208
8209 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
8210         LDKDecodeError e_conv;
8211         e_conv.inner = (void*)(e & (~1));
8212         e_conv.is_owned = (e & 1) || (e == 0);
8213         e_conv = DecodeError_clone(&e_conv);
8214         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8215         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
8216         return (uint64_t)ret_conv;
8217 }
8218
8219 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
8220         if ((_res & 1) != 0) return;
8221         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
8222         FREE((void*)_res);
8223         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
8224 }
8225
8226 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
8227         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
8228         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8229         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
8230         return (uint64_t)ret_conv;
8231 }
8232
8233 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
8234         LDKOutPoint o_conv;
8235         o_conv.inner = (void*)(o & (~1));
8236         o_conv.is_owned = (o & 1) || (o == 0);
8237         o_conv = OutPoint_clone(&o_conv);
8238         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8239         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
8240         return (uint64_t)ret_conv;
8241 }
8242
8243 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
8244         LDKDecodeError e_conv;
8245         e_conv.inner = (void*)(e & (~1));
8246         e_conv.is_owned = (e & 1) || (e == 0);
8247         e_conv = DecodeError_clone(&e_conv);
8248         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8249         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
8250         return (uint64_t)ret_conv;
8251 }
8252
8253 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
8254         if ((_res & 1) != 0) return;
8255         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
8256         FREE((void*)_res);
8257         CResult_OutPointDecodeErrorZ_free(_res_conv);
8258 }
8259
8260 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
8261         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
8262         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8263         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
8264         return (uint64_t)ret_conv;
8265 }
8266
8267 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
8268         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
8269         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8270         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
8271         return (uint64_t)ret_conv;
8272 }
8273
8274 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err() {
8275         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8276         *ret_conv = CResult_SiPrefixNoneZ_err();
8277         return (uint64_t)ret_conv;
8278 }
8279
8280 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
8281         if ((_res & 1) != 0) return;
8282         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
8283         FREE((void*)_res);
8284         CResult_SiPrefixNoneZ_free(_res_conv);
8285 }
8286
8287 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
8288         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
8289         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8290         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
8291         return (uint64_t)ret_conv;
8292 }
8293
8294 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
8295         LDKInvoice o_conv;
8296         o_conv.inner = (void*)(o & (~1));
8297         o_conv.is_owned = (o & 1) || (o == 0);
8298         o_conv = Invoice_clone(&o_conv);
8299         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8300         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
8301         return (uint64_t)ret_conv;
8302 }
8303
8304 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
8305         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8306         *ret_conv = CResult_InvoiceNoneZ_err();
8307         return (uint64_t)ret_conv;
8308 }
8309
8310 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
8311         if ((_res & 1) != 0) return;
8312         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
8313         FREE((void*)_res);
8314         CResult_InvoiceNoneZ_free(_res_conv);
8315 }
8316
8317 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
8318         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
8319         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8320         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
8321         return (uint64_t)ret_conv;
8322 }
8323
8324 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
8325         LDKSignedRawInvoice o_conv;
8326         o_conv.inner = (void*)(o & (~1));
8327         o_conv.is_owned = (o & 1) || (o == 0);
8328         o_conv = SignedRawInvoice_clone(&o_conv);
8329         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8330         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
8331         return (uint64_t)ret_conv;
8332 }
8333
8334 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
8335         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8336         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
8337         return (uint64_t)ret_conv;
8338 }
8339
8340 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
8341         if ((_res & 1) != 0) return;
8342         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
8343         FREE((void*)_res);
8344         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
8345 }
8346
8347 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
8348         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
8349         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8350         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
8351         return (uint64_t)ret_conv;
8352 }
8353
8354 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
8355         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
8356         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
8357         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
8358         return (uint64_t)ret_ref;
8359 }
8360
8361 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
8362         LDKRawInvoice a_conv;
8363         a_conv.inner = (void*)(a & (~1));
8364         a_conv.is_owned = (a & 1) || (a == 0);
8365         a_conv = RawInvoice_clone(&a_conv);
8366         LDKThirtyTwoBytes b_ref;
8367         CHECK(*((uint32_t*)b) == 32);
8368         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
8369         LDKInvoiceSignature c_conv;
8370         c_conv.inner = (void*)(c & (~1));
8371         c_conv.is_owned = (c & 1) || (c == 0);
8372         c_conv = InvoiceSignature_clone(&c_conv);
8373         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
8374         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
8375         return (uint64_t)ret_ref;
8376 }
8377
8378 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
8379         if ((_res & 1) != 0) return;
8380         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
8381         FREE((void*)_res);
8382         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
8383 }
8384
8385 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
8386         LDKPayeePubKey o_conv;
8387         o_conv.inner = (void*)(o & (~1));
8388         o_conv.is_owned = (o & 1) || (o == 0);
8389         o_conv = PayeePubKey_clone(&o_conv);
8390         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8391         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
8392         return (uint64_t)ret_conv;
8393 }
8394
8395 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
8396         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8397         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8398         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
8399         return (uint64_t)ret_conv;
8400 }
8401
8402 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
8403         if ((_res & 1) != 0) return;
8404         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
8405         FREE((void*)_res);
8406         CResult_PayeePubKeyErrorZ_free(_res_conv);
8407 }
8408
8409 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
8410         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
8411         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8412         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
8413         return (uint64_t)ret_conv;
8414 }
8415
8416 void  __attribute__((visibility("default"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
8417         LDKCVec_PrivateRouteZ _res_constr;
8418         _res_constr.datalen = *((uint32_t*)_res);
8419         if (_res_constr.datalen > 0)
8420                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
8421         else
8422                 _res_constr.data = NULL;
8423         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8424         for (size_t o = 0; o < _res_constr.datalen; o++) {
8425                 uint32_t _res_conv_14 = _res_vals[o];
8426                 LDKPrivateRoute _res_conv_14_conv;
8427                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
8428                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
8429                 _res_constr.data[o] = _res_conv_14_conv;
8430         }
8431         CVec_PrivateRouteZ_free(_res_constr);
8432 }
8433
8434 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
8435         LDKPositiveTimestamp o_conv;
8436         o_conv.inner = (void*)(o & (~1));
8437         o_conv.is_owned = (o & 1) || (o == 0);
8438         o_conv = PositiveTimestamp_clone(&o_conv);
8439         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8440         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
8441         return (uint64_t)ret_conv;
8442 }
8443
8444 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
8445         LDKCreationError e_conv = LDKCreationError_from_js(e);
8446         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8447         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
8448         return (uint64_t)ret_conv;
8449 }
8450
8451 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
8452         if ((_res & 1) != 0) return;
8453         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
8454         FREE((void*)_res);
8455         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
8456 }
8457
8458 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
8459         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
8460         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8461         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
8462         return (uint64_t)ret_conv;
8463 }
8464
8465 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_ok() {
8466         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8467         *ret_conv = CResult_NoneSemanticErrorZ_ok();
8468         return (uint64_t)ret_conv;
8469 }
8470
8471 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
8472         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
8473         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8474         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
8475         return (uint64_t)ret_conv;
8476 }
8477
8478 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
8479         if ((_res & 1) != 0) return;
8480         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
8481         FREE((void*)_res);
8482         CResult_NoneSemanticErrorZ_free(_res_conv);
8483 }
8484
8485 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
8486         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
8487         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8488         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
8489         return (uint64_t)ret_conv;
8490 }
8491
8492 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
8493         LDKInvoice o_conv;
8494         o_conv.inner = (void*)(o & (~1));
8495         o_conv.is_owned = (o & 1) || (o == 0);
8496         o_conv = Invoice_clone(&o_conv);
8497         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8498         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
8499         return (uint64_t)ret_conv;
8500 }
8501
8502 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
8503         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
8504         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8505         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
8506         return (uint64_t)ret_conv;
8507 }
8508
8509 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
8510         if ((_res & 1) != 0) return;
8511         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
8512         FREE((void*)_res);
8513         CResult_InvoiceSemanticErrorZ_free(_res_conv);
8514 }
8515
8516 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
8517         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
8518         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8519         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
8520         return (uint64_t)ret_conv;
8521 }
8522
8523 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
8524         LDKDescription o_conv;
8525         o_conv.inner = (void*)(o & (~1));
8526         o_conv.is_owned = (o & 1) || (o == 0);
8527         o_conv = Description_clone(&o_conv);
8528         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8529         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
8530         return (uint64_t)ret_conv;
8531 }
8532
8533 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
8534         LDKCreationError e_conv = LDKCreationError_from_js(e);
8535         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8536         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
8537         return (uint64_t)ret_conv;
8538 }
8539
8540 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
8541         if ((_res & 1) != 0) return;
8542         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
8543         FREE((void*)_res);
8544         CResult_DescriptionCreationErrorZ_free(_res_conv);
8545 }
8546
8547 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
8548         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
8549         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8550         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
8551         return (uint64_t)ret_conv;
8552 }
8553
8554 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_ok(uint32_t o) {
8555         LDKExpiryTime o_conv;
8556         o_conv.inner = (void*)(o & (~1));
8557         o_conv.is_owned = (o & 1) || (o == 0);
8558         o_conv = ExpiryTime_clone(&o_conv);
8559         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8560         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
8561         return (uint64_t)ret_conv;
8562 }
8563
8564 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_err(uint32_t e) {
8565         LDKCreationError e_conv = LDKCreationError_from_js(e);
8566         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8567         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
8568         return (uint64_t)ret_conv;
8569 }
8570
8571 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
8572         if ((_res & 1) != 0) return;
8573         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
8574         FREE((void*)_res);
8575         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
8576 }
8577
8578 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone(uint32_t orig) {
8579         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
8580         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8581         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
8582         return (uint64_t)ret_conv;
8583 }
8584
8585 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
8586         LDKPrivateRoute o_conv;
8587         o_conv.inner = (void*)(o & (~1));
8588         o_conv.is_owned = (o & 1) || (o == 0);
8589         o_conv = PrivateRoute_clone(&o_conv);
8590         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8591         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
8592         return (uint64_t)ret_conv;
8593 }
8594
8595 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
8596         LDKCreationError e_conv = LDKCreationError_from_js(e);
8597         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8598         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
8599         return (uint64_t)ret_conv;
8600 }
8601
8602 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
8603         if ((_res & 1) != 0) return;
8604         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
8605         FREE((void*)_res);
8606         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
8607 }
8608
8609 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
8610         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
8611         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8612         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
8613         return (uint64_t)ret_conv;
8614 }
8615
8616 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_ok(jstring o) {
8617         LDKStr o_conv = str_ref_to_owned_c(o);
8618         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
8619         *ret_conv = CResult_StringErrorZ_ok(o_conv);
8620         return (uint64_t)ret_conv;
8621 }
8622
8623 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uint32_t e) {
8624         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8625         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
8626         *ret_conv = CResult_StringErrorZ_err(e_conv);
8627         return (uint64_t)ret_conv;
8628 }
8629
8630 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
8631         if ((_res & 1) != 0) return;
8632         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
8633         FREE((void*)_res);
8634         CResult_StringErrorZ_free(_res_conv);
8635 }
8636
8637 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
8638         LDKChannelMonitorUpdate o_conv;
8639         o_conv.inner = (void*)(o & (~1));
8640         o_conv.is_owned = (o & 1) || (o == 0);
8641         o_conv = ChannelMonitorUpdate_clone(&o_conv);
8642         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8643         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
8644         return (uint64_t)ret_conv;
8645 }
8646
8647 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
8648         LDKDecodeError e_conv;
8649         e_conv.inner = (void*)(e & (~1));
8650         e_conv.is_owned = (e & 1) || (e == 0);
8651         e_conv = DecodeError_clone(&e_conv);
8652         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8653         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
8654         return (uint64_t)ret_conv;
8655 }
8656
8657 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
8658         if ((_res & 1) != 0) return;
8659         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8660         FREE((void*)_res);
8661         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
8662 }
8663
8664 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
8665         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
8666         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8667         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
8668         return (uint64_t)ret_conv;
8669 }
8670
8671 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
8672         LDKHTLCUpdate o_conv;
8673         o_conv.inner = (void*)(o & (~1));
8674         o_conv.is_owned = (o & 1) || (o == 0);
8675         o_conv = HTLCUpdate_clone(&o_conv);
8676         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8677         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
8678         return (uint64_t)ret_conv;
8679 }
8680
8681 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
8682         LDKDecodeError e_conv;
8683         e_conv.inner = (void*)(e & (~1));
8684         e_conv.is_owned = (e & 1) || (e == 0);
8685         e_conv = DecodeError_clone(&e_conv);
8686         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8687         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
8688         return (uint64_t)ret_conv;
8689 }
8690
8691 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
8692         if ((_res & 1) != 0) return;
8693         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8694         FREE((void*)_res);
8695         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
8696 }
8697
8698 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
8699         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
8700         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8701         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
8702         return (uint64_t)ret_conv;
8703 }
8704
8705 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
8706         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8707         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
8708         return (uint64_t)ret_conv;
8709 }
8710
8711 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
8712         LDKMonitorUpdateError e_conv;
8713         e_conv.inner = (void*)(e & (~1));
8714         e_conv.is_owned = (e & 1) || (e == 0);
8715         e_conv = MonitorUpdateError_clone(&e_conv);
8716         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8717         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
8718         return (uint64_t)ret_conv;
8719 }
8720
8721 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
8722         if ((_res & 1) != 0) return;
8723         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
8724         FREE((void*)_res);
8725         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
8726 }
8727
8728 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
8729         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
8730         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8731         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
8732         return (uint64_t)ret_conv;
8733 }
8734
8735 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
8736         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
8737         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
8738         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
8739         return (uint64_t)ret_ref;
8740 }
8741
8742 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
8743         LDKOutPoint a_conv;
8744         a_conv.inner = (void*)(a & (~1));
8745         a_conv.is_owned = (a & 1) || (a == 0);
8746         a_conv = OutPoint_clone(&a_conv);
8747         LDKCVec_u8Z b_ref;
8748         b_ref.datalen = *((uint32_t*)b);
8749         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
8750         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
8751         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
8752         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
8753         return (uint64_t)ret_ref;
8754 }
8755
8756 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
8757         if ((_res & 1) != 0) return;
8758         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
8759         FREE((void*)_res);
8760         C2Tuple_OutPointScriptZ_free(_res_conv);
8761 }
8762
8763 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
8764         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
8765         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8766         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
8767         return (uint64_t)ret_ref;
8768 }
8769
8770 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
8771         LDKCVec_u8Z b_ref;
8772         b_ref.datalen = *((uint32_t*)b);
8773         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
8774         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
8775         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8776         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
8777         return (uint64_t)ret_ref;
8778 }
8779
8780 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
8781         if ((_res & 1) != 0) return;
8782         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
8783         FREE((void*)_res);
8784         C2Tuple_u32ScriptZ_free(_res_conv);
8785 }
8786
8787 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
8788         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
8789         _res_constr.datalen = *((uint32_t*)_res);
8790         if (_res_constr.datalen > 0)
8791                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
8792         else
8793                 _res_constr.data = NULL;
8794         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8795         for (size_t e = 0; e < _res_constr.datalen; e++) {
8796                 uint32_t _res_conv_30 = _res_vals[e];
8797                 LDKC2Tuple_u32ScriptZ _res_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_30) & ~1);
8798                 FREE((void*)_res_conv_30);
8799                 _res_constr.data[e] = _res_conv_30_conv;
8800         }
8801         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
8802 }
8803
8804 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
8805         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
8806         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
8807         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
8808         return (uint64_t)ret_ref;
8809 }
8810
8811 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
8812         LDKThirtyTwoBytes a_ref;
8813         CHECK(*((uint32_t*)a) == 32);
8814         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8815         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
8816         b_constr.datalen = *((uint32_t*)b);
8817         if (b_constr.datalen > 0)
8818                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
8819         else
8820                 b_constr.data = NULL;
8821         uint32_t* b_vals = (uint32_t*)(b + 4);
8822         for (size_t e = 0; e < b_constr.datalen; e++) {
8823                 uint32_t b_conv_30 = b_vals[e];
8824                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
8825                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
8826                 b_constr.data[e] = b_conv_30_conv;
8827         }
8828         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
8829         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
8830         return (uint64_t)ret_ref;
8831 }
8832
8833 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
8834         if ((_res & 1) != 0) return;
8835         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
8836         FREE((void*)_res);
8837         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
8838 }
8839
8840 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
8841         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
8842         _res_constr.datalen = *((uint32_t*)_res);
8843         if (_res_constr.datalen > 0)
8844                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
8845         else
8846                 _res_constr.data = NULL;
8847         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8848         for (size_t c = 0; c < _res_constr.datalen; c++) {
8849                 uint32_t _res_conv_54 = _res_vals[c];
8850                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_54_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_54) & ~1);
8851                 FREE((void*)_res_conv_54);
8852                 _res_constr.data[c] = _res_conv_54_conv;
8853         }
8854         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
8855 }
8856
8857 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
8858         LDKCVec_EventZ _res_constr;
8859         _res_constr.datalen = *((uint32_t*)_res);
8860         if (_res_constr.datalen > 0)
8861                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
8862         else
8863                 _res_constr.data = NULL;
8864         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8865         for (size_t h = 0; h < _res_constr.datalen; h++) {
8866                 uint32_t _res_conv_7 = _res_vals[h];
8867                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
8868                 FREE((void*)_res_conv_7);
8869                 _res_constr.data[h] = _res_conv_7_conv;
8870         }
8871         CVec_EventZ_free(_res_constr);
8872 }
8873
8874 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
8875         LDKCVec_TransactionZ _res_constr;
8876         _res_constr.datalen = *((uint32_t*)_res);
8877         if (_res_constr.datalen > 0)
8878                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
8879         else
8880                 _res_constr.data = NULL;
8881         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8882         for (size_t m = 0; m < _res_constr.datalen; m++) {
8883                 int8_tArray _res_conv_12 = _res_vals[m];
8884                 LDKTransaction _res_conv_12_ref;
8885                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
8886                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
8887                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
8888                 _res_conv_12_ref.data_is_owned = true;
8889                 _res_constr.data[m] = _res_conv_12_ref;
8890         }
8891         CVec_TransactionZ_free(_res_constr);
8892 }
8893
8894 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
8895         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
8896         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8897         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
8898         return (uint64_t)ret_ref;
8899 }
8900
8901 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
8902         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
8903         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8904         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
8905         return (uint64_t)ret_ref;
8906 }
8907
8908 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
8909         if ((_res & 1) != 0) return;
8910         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
8911         FREE((void*)_res);
8912         C2Tuple_u32TxOutZ_free(_res_conv);
8913 }
8914
8915 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
8916         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
8917         _res_constr.datalen = *((uint32_t*)_res);
8918         if (_res_constr.datalen > 0)
8919                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
8920         else
8921                 _res_constr.data = NULL;
8922         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8923         for (size_t z = 0; z < _res_constr.datalen; z++) {
8924                 uint32_t _res_conv_25 = _res_vals[z];
8925                 LDKC2Tuple_u32TxOutZ _res_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_25) & ~1);
8926                 FREE((void*)_res_conv_25);
8927                 _res_constr.data[z] = _res_conv_25_conv;
8928         }
8929         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
8930 }
8931
8932 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
8933         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
8934         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
8935         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
8936         return (uint64_t)ret_ref;
8937 }
8938
8939 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
8940         LDKThirtyTwoBytes a_ref;
8941         CHECK(*((uint32_t*)a) == 32);
8942         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8943         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
8944         b_constr.datalen = *((uint32_t*)b);
8945         if (b_constr.datalen > 0)
8946                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
8947         else
8948                 b_constr.data = NULL;
8949         uint32_t* b_vals = (uint32_t*)(b + 4);
8950         for (size_t z = 0; z < b_constr.datalen; z++) {
8951                 uint32_t b_conv_25 = b_vals[z];
8952                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
8953                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
8954                 b_constr.data[z] = b_conv_25_conv;
8955         }
8956         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
8957         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
8958         return (uint64_t)ret_ref;
8959 }
8960
8961 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
8962         if ((_res & 1) != 0) return;
8963         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
8964         FREE((void*)_res);
8965         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
8966 }
8967
8968 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
8969         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
8970         _res_constr.datalen = *((uint32_t*)_res);
8971         if (_res_constr.datalen > 0)
8972                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
8973         else
8974                 _res_constr.data = NULL;
8975         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8976         for (size_t x = 0; x < _res_constr.datalen; x++) {
8977                 uint32_t _res_conv_49 = _res_vals[x];
8978                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_49) & ~1);
8979                 FREE((void*)_res_conv_49);
8980                 _res_constr.data[x] = _res_conv_49_conv;
8981         }
8982         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
8983 }
8984
8985 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
8986         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
8987         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
8988         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
8989         return (uint64_t)ret_conv;
8990 }
8991
8992 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
8993         LDKDecodeError e_conv;
8994         e_conv.inner = (void*)(e & (~1));
8995         e_conv.is_owned = (e & 1) || (e == 0);
8996         e_conv = DecodeError_clone(&e_conv);
8997         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
8998         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
8999         return (uint64_t)ret_conv;
9000 }
9001
9002 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
9003         if ((_res & 1) != 0) return;
9004         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9005         FREE((void*)_res);
9006         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
9007 }
9008
9009 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
9010         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9011         *ret_conv = CResult_boolLightningErrorZ_ok(o);
9012         return (uint64_t)ret_conv;
9013 }
9014
9015 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
9016         LDKLightningError e_conv;
9017         e_conv.inner = (void*)(e & (~1));
9018         e_conv.is_owned = (e & 1) || (e == 0);
9019         e_conv = LightningError_clone(&e_conv);
9020         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9021         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
9022         return (uint64_t)ret_conv;
9023 }
9024
9025 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
9026         if ((_res & 1) != 0) return;
9027         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
9028         FREE((void*)_res);
9029         CResult_boolLightningErrorZ_free(_res_conv);
9030 }
9031
9032 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
9033         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
9034         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9035         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
9036         return (uint64_t)ret_conv;
9037 }
9038
9039 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
9040         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
9041         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9042         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
9043         return (uint64_t)ret_ref;
9044 }
9045
9046 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
9047         LDKChannelAnnouncement a_conv;
9048         a_conv.inner = (void*)(a & (~1));
9049         a_conv.is_owned = (a & 1) || (a == 0);
9050         a_conv = ChannelAnnouncement_clone(&a_conv);
9051         LDKChannelUpdate b_conv;
9052         b_conv.inner = (void*)(b & (~1));
9053         b_conv.is_owned = (b & 1) || (b == 0);
9054         b_conv = ChannelUpdate_clone(&b_conv);
9055         LDKChannelUpdate c_conv;
9056         c_conv.inner = (void*)(c & (~1));
9057         c_conv.is_owned = (c & 1) || (c == 0);
9058         c_conv = ChannelUpdate_clone(&c_conv);
9059         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9060         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
9061         return (uint64_t)ret_ref;
9062 }
9063
9064 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
9065         if ((_res & 1) != 0) return;
9066         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
9067         FREE((void*)_res);
9068         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
9069 }
9070
9071 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
9072         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
9073         _res_constr.datalen = *((uint32_t*)_res);
9074         if (_res_constr.datalen > 0)
9075                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9076         else
9077                 _res_constr.data = NULL;
9078         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9079         for (size_t l = 0; l < _res_constr.datalen; l++) {
9080                 uint32_t _res_conv_63 = _res_vals[l];
9081                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
9082                 FREE((void*)_res_conv_63);
9083                 _res_constr.data[l] = _res_conv_63_conv;
9084         }
9085         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
9086 }
9087
9088 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
9089         LDKCVec_NodeAnnouncementZ _res_constr;
9090         _res_constr.datalen = *((uint32_t*)_res);
9091         if (_res_constr.datalen > 0)
9092                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9093         else
9094                 _res_constr.data = NULL;
9095         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9096         for (size_t s = 0; s < _res_constr.datalen; s++) {
9097                 uint32_t _res_conv_18 = _res_vals[s];
9098                 LDKNodeAnnouncement _res_conv_18_conv;
9099                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
9100                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
9101                 _res_constr.data[s] = _res_conv_18_conv;
9102         }
9103         CVec_NodeAnnouncementZ_free(_res_constr);
9104 }
9105
9106 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
9107         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9108         *ret_conv = CResult_NoneLightningErrorZ_ok();
9109         return (uint64_t)ret_conv;
9110 }
9111
9112 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
9113         LDKLightningError e_conv;
9114         e_conv.inner = (void*)(e & (~1));
9115         e_conv.is_owned = (e & 1) || (e == 0);
9116         e_conv = LightningError_clone(&e_conv);
9117         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9118         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
9119         return (uint64_t)ret_conv;
9120 }
9121
9122 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
9123         if ((_res & 1) != 0) return;
9124         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
9125         FREE((void*)_res);
9126         CResult_NoneLightningErrorZ_free(_res_conv);
9127 }
9128
9129 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
9130         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
9131         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9132         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
9133         return (uint64_t)ret_conv;
9134 }
9135
9136 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
9137         LDKCVec_PublicKeyZ _res_constr;
9138         _res_constr.datalen = *((uint32_t*)_res);
9139         if (_res_constr.datalen > 0)
9140                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
9141         else
9142                 _res_constr.data = NULL;
9143         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
9144         for (size_t m = 0; m < _res_constr.datalen; m++) {
9145                 int8_tArray _res_conv_12 = _res_vals[m];
9146                 LDKPublicKey _res_conv_12_ref;
9147                 CHECK(*((uint32_t*)_res_conv_12) == 33);
9148                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
9149                 _res_constr.data[m] = _res_conv_12_ref;
9150         }
9151         CVec_PublicKeyZ_free(_res_constr);
9152 }
9153
9154 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
9155         LDKCVec_u8Z o_ref;
9156         o_ref.datalen = *((uint32_t*)o);
9157         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
9158         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
9159         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9160         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
9161         return (uint64_t)ret_conv;
9162 }
9163
9164 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
9165         LDKPeerHandleError e_conv;
9166         e_conv.inner = (void*)(e & (~1));
9167         e_conv.is_owned = (e & 1) || (e == 0);
9168         e_conv = PeerHandleError_clone(&e_conv);
9169         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9170         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
9171         return (uint64_t)ret_conv;
9172 }
9173
9174 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
9175         if ((_res & 1) != 0) return;
9176         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9177         FREE((void*)_res);
9178         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
9179 }
9180
9181 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
9182         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
9183         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9184         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
9185         return (uint64_t)ret_conv;
9186 }
9187
9188 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
9189         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9190         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
9191         return (uint64_t)ret_conv;
9192 }
9193
9194 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
9195         LDKPeerHandleError e_conv;
9196         e_conv.inner = (void*)(e & (~1));
9197         e_conv.is_owned = (e & 1) || (e == 0);
9198         e_conv = PeerHandleError_clone(&e_conv);
9199         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9200         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
9201         return (uint64_t)ret_conv;
9202 }
9203
9204 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
9205         if ((_res & 1) != 0) return;
9206         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9207         FREE((void*)_res);
9208         CResult_NonePeerHandleErrorZ_free(_res_conv);
9209 }
9210
9211 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
9212         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
9213         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9214         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
9215         return (uint64_t)ret_conv;
9216 }
9217
9218 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
9219         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9220         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
9221         return (uint64_t)ret_conv;
9222 }
9223
9224 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
9225         LDKPeerHandleError e_conv;
9226         e_conv.inner = (void*)(e & (~1));
9227         e_conv.is_owned = (e & 1) || (e == 0);
9228         e_conv = PeerHandleError_clone(&e_conv);
9229         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9230         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
9231         return (uint64_t)ret_conv;
9232 }
9233
9234 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
9235         if ((_res & 1) != 0) return;
9236         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9237         FREE((void*)_res);
9238         CResult_boolPeerHandleErrorZ_free(_res_conv);
9239 }
9240
9241 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
9242         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
9243         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9244         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
9245         return (uint64_t)ret_conv;
9246 }
9247
9248 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
9249         LDKDirectionalChannelInfo o_conv;
9250         o_conv.inner = (void*)(o & (~1));
9251         o_conv.is_owned = (o & 1) || (o == 0);
9252         o_conv = DirectionalChannelInfo_clone(&o_conv);
9253         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9254         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
9255         return (uint64_t)ret_conv;
9256 }
9257
9258 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
9259         LDKDecodeError e_conv;
9260         e_conv.inner = (void*)(e & (~1));
9261         e_conv.is_owned = (e & 1) || (e == 0);
9262         e_conv = DecodeError_clone(&e_conv);
9263         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9264         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
9265         return (uint64_t)ret_conv;
9266 }
9267
9268 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
9269         if ((_res & 1) != 0) return;
9270         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9271         FREE((void*)_res);
9272         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
9273 }
9274
9275 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
9276         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
9277         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9278         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
9279         return (uint64_t)ret_conv;
9280 }
9281
9282 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
9283         LDKChannelInfo o_conv;
9284         o_conv.inner = (void*)(o & (~1));
9285         o_conv.is_owned = (o & 1) || (o == 0);
9286         o_conv = ChannelInfo_clone(&o_conv);
9287         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9288         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
9289         return (uint64_t)ret_conv;
9290 }
9291
9292 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
9293         LDKDecodeError e_conv;
9294         e_conv.inner = (void*)(e & (~1));
9295         e_conv.is_owned = (e & 1) || (e == 0);
9296         e_conv = DecodeError_clone(&e_conv);
9297         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9298         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
9299         return (uint64_t)ret_conv;
9300 }
9301
9302 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
9303         if ((_res & 1) != 0) return;
9304         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9305         FREE((void*)_res);
9306         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
9307 }
9308
9309 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
9310         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
9311         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9312         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
9313         return (uint64_t)ret_conv;
9314 }
9315
9316 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
9317         LDKRoutingFees o_conv;
9318         o_conv.inner = (void*)(o & (~1));
9319         o_conv.is_owned = (o & 1) || (o == 0);
9320         o_conv = RoutingFees_clone(&o_conv);
9321         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9322         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
9323         return (uint64_t)ret_conv;
9324 }
9325
9326 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
9327         LDKDecodeError e_conv;
9328         e_conv.inner = (void*)(e & (~1));
9329         e_conv.is_owned = (e & 1) || (e == 0);
9330         e_conv = DecodeError_clone(&e_conv);
9331         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9332         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
9333         return (uint64_t)ret_conv;
9334 }
9335
9336 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
9337         if ((_res & 1) != 0) return;
9338         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9339         FREE((void*)_res);
9340         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
9341 }
9342
9343 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
9344         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
9345         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9346         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
9347         return (uint64_t)ret_conv;
9348 }
9349
9350 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
9351         LDKNodeAnnouncementInfo o_conv;
9352         o_conv.inner = (void*)(o & (~1));
9353         o_conv.is_owned = (o & 1) || (o == 0);
9354         o_conv = NodeAnnouncementInfo_clone(&o_conv);
9355         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9356         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
9357         return (uint64_t)ret_conv;
9358 }
9359
9360 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
9361         LDKDecodeError e_conv;
9362         e_conv.inner = (void*)(e & (~1));
9363         e_conv.is_owned = (e & 1) || (e == 0);
9364         e_conv = DecodeError_clone(&e_conv);
9365         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9366         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
9367         return (uint64_t)ret_conv;
9368 }
9369
9370 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
9371         if ((_res & 1) != 0) return;
9372         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9373         FREE((void*)_res);
9374         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
9375 }
9376
9377 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
9378         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
9379         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9380         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
9381         return (uint64_t)ret_conv;
9382 }
9383
9384 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
9385         LDKCVec_u64Z _res_constr;
9386         _res_constr.datalen = *((uint32_t*)_res);
9387         if (_res_constr.datalen > 0)
9388                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
9389         else
9390                 _res_constr.data = NULL;
9391         int64_t* _res_vals = (int64_t*)(_res + 4);
9392         for (size_t i = 0; i < _res_constr.datalen; i++) {
9393                 int64_t _res_conv_8 = _res_vals[i];
9394                 _res_constr.data[i] = _res_conv_8;
9395         }
9396         CVec_u64Z_free(_res_constr);
9397 }
9398
9399 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
9400         LDKNodeInfo o_conv;
9401         o_conv.inner = (void*)(o & (~1));
9402         o_conv.is_owned = (o & 1) || (o == 0);
9403         o_conv = NodeInfo_clone(&o_conv);
9404         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9405         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
9406         return (uint64_t)ret_conv;
9407 }
9408
9409 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
9410         LDKDecodeError e_conv;
9411         e_conv.inner = (void*)(e & (~1));
9412         e_conv.is_owned = (e & 1) || (e == 0);
9413         e_conv = DecodeError_clone(&e_conv);
9414         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9415         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
9416         return (uint64_t)ret_conv;
9417 }
9418
9419 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
9420         if ((_res & 1) != 0) return;
9421         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9422         FREE((void*)_res);
9423         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
9424 }
9425
9426 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
9427         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
9428         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9429         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
9430         return (uint64_t)ret_conv;
9431 }
9432
9433 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
9434         LDKNetworkGraph o_conv;
9435         o_conv.inner = (void*)(o & (~1));
9436         o_conv.is_owned = (o & 1) || (o == 0);
9437         o_conv = NetworkGraph_clone(&o_conv);
9438         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9439         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
9440         return (uint64_t)ret_conv;
9441 }
9442
9443 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
9444         LDKDecodeError e_conv;
9445         e_conv.inner = (void*)(e & (~1));
9446         e_conv.is_owned = (e & 1) || (e == 0);
9447         e_conv = DecodeError_clone(&e_conv);
9448         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9449         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
9450         return (uint64_t)ret_conv;
9451 }
9452
9453 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
9454         if ((_res & 1) != 0) return;
9455         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
9456         FREE((void*)_res);
9457         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
9458 }
9459
9460 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
9461         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
9462         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9463         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
9464         return (uint64_t)ret_conv;
9465 }
9466
9467 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
9468         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
9469         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9470         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
9471         return (uint64_t)ret_conv;
9472 }
9473
9474 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
9475         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9476         *ret_conv = CResult_NetAddressu8Z_err(e);
9477         return (uint64_t)ret_conv;
9478 }
9479
9480 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
9481         if ((_res & 1) != 0) return;
9482         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
9483         FREE((void*)_res);
9484         CResult_NetAddressu8Z_free(_res_conv);
9485 }
9486
9487 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
9488         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
9489         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9490         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
9491         return (uint64_t)ret_conv;
9492 }
9493
9494 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
9495         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
9496         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9497         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
9498         return (uint64_t)ret_conv;
9499 }
9500
9501 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
9502         LDKDecodeError e_conv;
9503         e_conv.inner = (void*)(e & (~1));
9504         e_conv.is_owned = (e & 1) || (e == 0);
9505         e_conv = DecodeError_clone(&e_conv);
9506         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9507         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
9508         return (uint64_t)ret_conv;
9509 }
9510
9511 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
9512         if ((_res & 1) != 0) return;
9513         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9514         FREE((void*)_res);
9515         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
9516 }
9517
9518 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
9519         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
9520         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9521         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
9522         return (uint64_t)ret_conv;
9523 }
9524
9525 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
9526         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
9527         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9528         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
9529         return (uint64_t)ret_conv;
9530 }
9531
9532 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
9533         LDKDecodeError e_conv;
9534         e_conv.inner = (void*)(e & (~1));
9535         e_conv.is_owned = (e & 1) || (e == 0);
9536         e_conv = DecodeError_clone(&e_conv);
9537         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9538         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
9539         return (uint64_t)ret_conv;
9540 }
9541
9542 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
9543         if ((_res & 1) != 0) return;
9544         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
9545         FREE((void*)_res);
9546         CResult_NetAddressDecodeErrorZ_free(_res_conv);
9547 }
9548
9549 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
9550         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
9551         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9552         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
9553         return (uint64_t)ret_conv;
9554 }
9555
9556 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
9557         LDKCVec_UpdateAddHTLCZ _res_constr;
9558         _res_constr.datalen = *((uint32_t*)_res);
9559         if (_res_constr.datalen > 0)
9560                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
9561         else
9562                 _res_constr.data = NULL;
9563         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9564         for (size_t p = 0; p < _res_constr.datalen; p++) {
9565                 uint32_t _res_conv_15 = _res_vals[p];
9566                 LDKUpdateAddHTLC _res_conv_15_conv;
9567                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
9568                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
9569                 _res_constr.data[p] = _res_conv_15_conv;
9570         }
9571         CVec_UpdateAddHTLCZ_free(_res_constr);
9572 }
9573
9574 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
9575         LDKCVec_UpdateFulfillHTLCZ _res_constr;
9576         _res_constr.datalen = *((uint32_t*)_res);
9577         if (_res_constr.datalen > 0)
9578                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
9579         else
9580                 _res_constr.data = NULL;
9581         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9582         for (size_t t = 0; t < _res_constr.datalen; t++) {
9583                 uint32_t _res_conv_19 = _res_vals[t];
9584                 LDKUpdateFulfillHTLC _res_conv_19_conv;
9585                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
9586                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
9587                 _res_constr.data[t] = _res_conv_19_conv;
9588         }
9589         CVec_UpdateFulfillHTLCZ_free(_res_constr);
9590 }
9591
9592 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
9593         LDKCVec_UpdateFailHTLCZ _res_constr;
9594         _res_constr.datalen = *((uint32_t*)_res);
9595         if (_res_constr.datalen > 0)
9596                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
9597         else
9598                 _res_constr.data = NULL;
9599         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9600         for (size_t q = 0; q < _res_constr.datalen; q++) {
9601                 uint32_t _res_conv_16 = _res_vals[q];
9602                 LDKUpdateFailHTLC _res_conv_16_conv;
9603                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9604                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9605                 _res_constr.data[q] = _res_conv_16_conv;
9606         }
9607         CVec_UpdateFailHTLCZ_free(_res_constr);
9608 }
9609
9610 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
9611         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
9612         _res_constr.datalen = *((uint32_t*)_res);
9613         if (_res_constr.datalen > 0)
9614                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
9615         else
9616                 _res_constr.data = NULL;
9617         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9618         for (size_t z = 0; z < _res_constr.datalen; z++) {
9619                 uint32_t _res_conv_25 = _res_vals[z];
9620                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
9621                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
9622                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
9623                 _res_constr.data[z] = _res_conv_25_conv;
9624         }
9625         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
9626 }
9627
9628 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
9629         LDKAcceptChannel o_conv;
9630         o_conv.inner = (void*)(o & (~1));
9631         o_conv.is_owned = (o & 1) || (o == 0);
9632         o_conv = AcceptChannel_clone(&o_conv);
9633         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9634         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
9635         return (uint64_t)ret_conv;
9636 }
9637
9638 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
9639         LDKDecodeError e_conv;
9640         e_conv.inner = (void*)(e & (~1));
9641         e_conv.is_owned = (e & 1) || (e == 0);
9642         e_conv = DecodeError_clone(&e_conv);
9643         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9644         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
9645         return (uint64_t)ret_conv;
9646 }
9647
9648 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
9649         if ((_res & 1) != 0) return;
9650         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9651         FREE((void*)_res);
9652         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
9653 }
9654
9655 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
9656         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
9657         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9658         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
9659         return (uint64_t)ret_conv;
9660 }
9661
9662 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
9663         LDKAnnouncementSignatures o_conv;
9664         o_conv.inner = (void*)(o & (~1));
9665         o_conv.is_owned = (o & 1) || (o == 0);
9666         o_conv = AnnouncementSignatures_clone(&o_conv);
9667         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9668         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
9669         return (uint64_t)ret_conv;
9670 }
9671
9672 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
9673         LDKDecodeError e_conv;
9674         e_conv.inner = (void*)(e & (~1));
9675         e_conv.is_owned = (e & 1) || (e == 0);
9676         e_conv = DecodeError_clone(&e_conv);
9677         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9678         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
9679         return (uint64_t)ret_conv;
9680 }
9681
9682 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
9683         if ((_res & 1) != 0) return;
9684         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9685         FREE((void*)_res);
9686         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
9687 }
9688
9689 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
9690         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
9691         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9692         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
9693         return (uint64_t)ret_conv;
9694 }
9695
9696 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
9697         LDKChannelReestablish o_conv;
9698         o_conv.inner = (void*)(o & (~1));
9699         o_conv.is_owned = (o & 1) || (o == 0);
9700         o_conv = ChannelReestablish_clone(&o_conv);
9701         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9702         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
9703         return (uint64_t)ret_conv;
9704 }
9705
9706 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
9707         LDKDecodeError e_conv;
9708         e_conv.inner = (void*)(e & (~1));
9709         e_conv.is_owned = (e & 1) || (e == 0);
9710         e_conv = DecodeError_clone(&e_conv);
9711         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9712         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
9713         return (uint64_t)ret_conv;
9714 }
9715
9716 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
9717         if ((_res & 1) != 0) return;
9718         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
9719         FREE((void*)_res);
9720         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
9721 }
9722
9723 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
9724         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
9725         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9726         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
9727         return (uint64_t)ret_conv;
9728 }
9729
9730 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
9731         LDKClosingSigned o_conv;
9732         o_conv.inner = (void*)(o & (~1));
9733         o_conv.is_owned = (o & 1) || (o == 0);
9734         o_conv = ClosingSigned_clone(&o_conv);
9735         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9736         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
9737         return (uint64_t)ret_conv;
9738 }
9739
9740 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
9741         LDKDecodeError e_conv;
9742         e_conv.inner = (void*)(e & (~1));
9743         e_conv.is_owned = (e & 1) || (e == 0);
9744         e_conv = DecodeError_clone(&e_conv);
9745         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9746         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
9747         return (uint64_t)ret_conv;
9748 }
9749
9750 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
9751         if ((_res & 1) != 0) return;
9752         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9753         FREE((void*)_res);
9754         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
9755 }
9756
9757 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
9758         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
9759         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9760         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
9761         return (uint64_t)ret_conv;
9762 }
9763
9764 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
9765         LDKCommitmentSigned o_conv;
9766         o_conv.inner = (void*)(o & (~1));
9767         o_conv.is_owned = (o & 1) || (o == 0);
9768         o_conv = CommitmentSigned_clone(&o_conv);
9769         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9770         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
9771         return (uint64_t)ret_conv;
9772 }
9773
9774 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
9775         LDKDecodeError e_conv;
9776         e_conv.inner = (void*)(e & (~1));
9777         e_conv.is_owned = (e & 1) || (e == 0);
9778         e_conv = DecodeError_clone(&e_conv);
9779         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9780         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
9781         return (uint64_t)ret_conv;
9782 }
9783
9784 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
9785         if ((_res & 1) != 0) return;
9786         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9787         FREE((void*)_res);
9788         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
9789 }
9790
9791 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
9792         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
9793         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9794         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
9795         return (uint64_t)ret_conv;
9796 }
9797
9798 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
9799         LDKFundingCreated o_conv;
9800         o_conv.inner = (void*)(o & (~1));
9801         o_conv.is_owned = (o & 1) || (o == 0);
9802         o_conv = FundingCreated_clone(&o_conv);
9803         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9804         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
9805         return (uint64_t)ret_conv;
9806 }
9807
9808 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
9809         LDKDecodeError e_conv;
9810         e_conv.inner = (void*)(e & (~1));
9811         e_conv.is_owned = (e & 1) || (e == 0);
9812         e_conv = DecodeError_clone(&e_conv);
9813         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9814         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
9815         return (uint64_t)ret_conv;
9816 }
9817
9818 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
9819         if ((_res & 1) != 0) return;
9820         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9821         FREE((void*)_res);
9822         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
9823 }
9824
9825 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
9826         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
9827         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9828         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
9829         return (uint64_t)ret_conv;
9830 }
9831
9832 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
9833         LDKFundingSigned o_conv;
9834         o_conv.inner = (void*)(o & (~1));
9835         o_conv.is_owned = (o & 1) || (o == 0);
9836         o_conv = FundingSigned_clone(&o_conv);
9837         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9838         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
9839         return (uint64_t)ret_conv;
9840 }
9841
9842 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
9843         LDKDecodeError e_conv;
9844         e_conv.inner = (void*)(e & (~1));
9845         e_conv.is_owned = (e & 1) || (e == 0);
9846         e_conv = DecodeError_clone(&e_conv);
9847         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9848         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
9849         return (uint64_t)ret_conv;
9850 }
9851
9852 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
9853         if ((_res & 1) != 0) return;
9854         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9855         FREE((void*)_res);
9856         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
9857 }
9858
9859 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
9860         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
9861         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9862         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
9863         return (uint64_t)ret_conv;
9864 }
9865
9866 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
9867         LDKFundingLocked o_conv;
9868         o_conv.inner = (void*)(o & (~1));
9869         o_conv.is_owned = (o & 1) || (o == 0);
9870         o_conv = FundingLocked_clone(&o_conv);
9871         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9872         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
9873         return (uint64_t)ret_conv;
9874 }
9875
9876 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
9877         LDKDecodeError e_conv;
9878         e_conv.inner = (void*)(e & (~1));
9879         e_conv.is_owned = (e & 1) || (e == 0);
9880         e_conv = DecodeError_clone(&e_conv);
9881         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9882         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
9883         return (uint64_t)ret_conv;
9884 }
9885
9886 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
9887         if ((_res & 1) != 0) return;
9888         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9889         FREE((void*)_res);
9890         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
9891 }
9892
9893 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
9894         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
9895         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9896         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
9897         return (uint64_t)ret_conv;
9898 }
9899
9900 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
9901         LDKInit o_conv;
9902         o_conv.inner = (void*)(o & (~1));
9903         o_conv.is_owned = (o & 1) || (o == 0);
9904         o_conv = Init_clone(&o_conv);
9905         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9906         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
9907         return (uint64_t)ret_conv;
9908 }
9909
9910 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
9911         LDKDecodeError e_conv;
9912         e_conv.inner = (void*)(e & (~1));
9913         e_conv.is_owned = (e & 1) || (e == 0);
9914         e_conv = DecodeError_clone(&e_conv);
9915         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9916         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
9917         return (uint64_t)ret_conv;
9918 }
9919
9920 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
9921         if ((_res & 1) != 0) return;
9922         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
9923         FREE((void*)_res);
9924         CResult_InitDecodeErrorZ_free(_res_conv);
9925 }
9926
9927 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
9928         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
9929         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9930         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
9931         return (uint64_t)ret_conv;
9932 }
9933
9934 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
9935         LDKOpenChannel o_conv;
9936         o_conv.inner = (void*)(o & (~1));
9937         o_conv.is_owned = (o & 1) || (o == 0);
9938         o_conv = OpenChannel_clone(&o_conv);
9939         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9940         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
9941         return (uint64_t)ret_conv;
9942 }
9943
9944 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
9945         LDKDecodeError e_conv;
9946         e_conv.inner = (void*)(e & (~1));
9947         e_conv.is_owned = (e & 1) || (e == 0);
9948         e_conv = DecodeError_clone(&e_conv);
9949         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9950         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
9951         return (uint64_t)ret_conv;
9952 }
9953
9954 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
9955         if ((_res & 1) != 0) return;
9956         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9957         FREE((void*)_res);
9958         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
9959 }
9960
9961 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
9962         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
9963         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9964         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
9965         return (uint64_t)ret_conv;
9966 }
9967
9968 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
9969         LDKRevokeAndACK o_conv;
9970         o_conv.inner = (void*)(o & (~1));
9971         o_conv.is_owned = (o & 1) || (o == 0);
9972         o_conv = RevokeAndACK_clone(&o_conv);
9973         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9974         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
9975         return (uint64_t)ret_conv;
9976 }
9977
9978 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
9979         LDKDecodeError e_conv;
9980         e_conv.inner = (void*)(e & (~1));
9981         e_conv.is_owned = (e & 1) || (e == 0);
9982         e_conv = DecodeError_clone(&e_conv);
9983         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9984         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
9985         return (uint64_t)ret_conv;
9986 }
9987
9988 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
9989         if ((_res & 1) != 0) return;
9990         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
9991         FREE((void*)_res);
9992         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
9993 }
9994
9995 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
9996         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
9997         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9998         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
9999         return (uint64_t)ret_conv;
10000 }
10001
10002 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
10003         LDKShutdown o_conv;
10004         o_conv.inner = (void*)(o & (~1));
10005         o_conv.is_owned = (o & 1) || (o == 0);
10006         o_conv = Shutdown_clone(&o_conv);
10007         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
10008         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
10009         return (uint64_t)ret_conv;
10010 }
10011
10012 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
10013         LDKDecodeError e_conv;
10014         e_conv.inner = (void*)(e & (~1));
10015         e_conv.is_owned = (e & 1) || (e == 0);
10016         e_conv = DecodeError_clone(&e_conv);
10017         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
10018         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
10019         return (uint64_t)ret_conv;
10020 }
10021
10022 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
10023         if ((_res & 1) != 0) return;
10024         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
10025         FREE((void*)_res);
10026         CResult_ShutdownDecodeErrorZ_free(_res_conv);
10027 }
10028
10029 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
10030         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
10031         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
10032         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
10033         return (uint64_t)ret_conv;
10034 }
10035
10036 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
10037         LDKUpdateFailHTLC o_conv;
10038         o_conv.inner = (void*)(o & (~1));
10039         o_conv.is_owned = (o & 1) || (o == 0);
10040         o_conv = UpdateFailHTLC_clone(&o_conv);
10041         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
10042         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
10043         return (uint64_t)ret_conv;
10044 }
10045
10046 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
10047         LDKDecodeError e_conv;
10048         e_conv.inner = (void*)(e & (~1));
10049         e_conv.is_owned = (e & 1) || (e == 0);
10050         e_conv = DecodeError_clone(&e_conv);
10051         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
10052         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
10053         return (uint64_t)ret_conv;
10054 }
10055
10056 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
10057         if ((_res & 1) != 0) return;
10058         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10059         FREE((void*)_res);
10060         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
10061 }
10062
10063 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
10064         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
10065         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
10066         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
10067         return (uint64_t)ret_conv;
10068 }
10069
10070 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
10071         LDKUpdateFailMalformedHTLC o_conv;
10072         o_conv.inner = (void*)(o & (~1));
10073         o_conv.is_owned = (o & 1) || (o == 0);
10074         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
10075         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10076         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
10077         return (uint64_t)ret_conv;
10078 }
10079
10080 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
10081         LDKDecodeError e_conv;
10082         e_conv.inner = (void*)(e & (~1));
10083         e_conv.is_owned = (e & 1) || (e == 0);
10084         e_conv = DecodeError_clone(&e_conv);
10085         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10086         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
10087         return (uint64_t)ret_conv;
10088 }
10089
10090 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
10091         if ((_res & 1) != 0) return;
10092         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10093         FREE((void*)_res);
10094         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
10095 }
10096
10097 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
10098         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
10099         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10100         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
10101         return (uint64_t)ret_conv;
10102 }
10103
10104 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
10105         LDKUpdateFee o_conv;
10106         o_conv.inner = (void*)(o & (~1));
10107         o_conv.is_owned = (o & 1) || (o == 0);
10108         o_conv = UpdateFee_clone(&o_conv);
10109         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10110         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
10111         return (uint64_t)ret_conv;
10112 }
10113
10114 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
10115         LDKDecodeError e_conv;
10116         e_conv.inner = (void*)(e & (~1));
10117         e_conv.is_owned = (e & 1) || (e == 0);
10118         e_conv = DecodeError_clone(&e_conv);
10119         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10120         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
10121         return (uint64_t)ret_conv;
10122 }
10123
10124 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
10125         if ((_res & 1) != 0) return;
10126         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10127         FREE((void*)_res);
10128         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
10129 }
10130
10131 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
10132         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
10133         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10134         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
10135         return (uint64_t)ret_conv;
10136 }
10137
10138 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
10139         LDKUpdateFulfillHTLC o_conv;
10140         o_conv.inner = (void*)(o & (~1));
10141         o_conv.is_owned = (o & 1) || (o == 0);
10142         o_conv = UpdateFulfillHTLC_clone(&o_conv);
10143         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10144         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
10145         return (uint64_t)ret_conv;
10146 }
10147
10148 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
10149         LDKDecodeError e_conv;
10150         e_conv.inner = (void*)(e & (~1));
10151         e_conv.is_owned = (e & 1) || (e == 0);
10152         e_conv = DecodeError_clone(&e_conv);
10153         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10154         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
10155         return (uint64_t)ret_conv;
10156 }
10157
10158 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
10159         if ((_res & 1) != 0) return;
10160         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10161         FREE((void*)_res);
10162         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
10163 }
10164
10165 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
10166         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
10167         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10168         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
10169         return (uint64_t)ret_conv;
10170 }
10171
10172 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
10173         LDKUpdateAddHTLC o_conv;
10174         o_conv.inner = (void*)(o & (~1));
10175         o_conv.is_owned = (o & 1) || (o == 0);
10176         o_conv = UpdateAddHTLC_clone(&o_conv);
10177         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10178         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
10179         return (uint64_t)ret_conv;
10180 }
10181
10182 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
10183         LDKDecodeError e_conv;
10184         e_conv.inner = (void*)(e & (~1));
10185         e_conv.is_owned = (e & 1) || (e == 0);
10186         e_conv = DecodeError_clone(&e_conv);
10187         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10188         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
10189         return (uint64_t)ret_conv;
10190 }
10191
10192 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
10193         if ((_res & 1) != 0) return;
10194         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10195         FREE((void*)_res);
10196         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
10197 }
10198
10199 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
10200         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
10201         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10202         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
10203         return (uint64_t)ret_conv;
10204 }
10205
10206 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
10207         LDKPing o_conv;
10208         o_conv.inner = (void*)(o & (~1));
10209         o_conv.is_owned = (o & 1) || (o == 0);
10210         o_conv = Ping_clone(&o_conv);
10211         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10212         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
10213         return (uint64_t)ret_conv;
10214 }
10215
10216 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
10217         LDKDecodeError e_conv;
10218         e_conv.inner = (void*)(e & (~1));
10219         e_conv.is_owned = (e & 1) || (e == 0);
10220         e_conv = DecodeError_clone(&e_conv);
10221         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10222         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
10223         return (uint64_t)ret_conv;
10224 }
10225
10226 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
10227         if ((_res & 1) != 0) return;
10228         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
10229         FREE((void*)_res);
10230         CResult_PingDecodeErrorZ_free(_res_conv);
10231 }
10232
10233 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
10234         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
10235         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10236         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
10237         return (uint64_t)ret_conv;
10238 }
10239
10240 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
10241         LDKPong o_conv;
10242         o_conv.inner = (void*)(o & (~1));
10243         o_conv.is_owned = (o & 1) || (o == 0);
10244         o_conv = Pong_clone(&o_conv);
10245         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10246         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
10247         return (uint64_t)ret_conv;
10248 }
10249
10250 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
10251         LDKDecodeError e_conv;
10252         e_conv.inner = (void*)(e & (~1));
10253         e_conv.is_owned = (e & 1) || (e == 0);
10254         e_conv = DecodeError_clone(&e_conv);
10255         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10256         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
10257         return (uint64_t)ret_conv;
10258 }
10259
10260 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
10261         if ((_res & 1) != 0) return;
10262         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
10263         FREE((void*)_res);
10264         CResult_PongDecodeErrorZ_free(_res_conv);
10265 }
10266
10267 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
10268         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
10269         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10270         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
10271         return (uint64_t)ret_conv;
10272 }
10273
10274 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
10275         LDKUnsignedChannelAnnouncement o_conv;
10276         o_conv.inner = (void*)(o & (~1));
10277         o_conv.is_owned = (o & 1) || (o == 0);
10278         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
10279         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10280         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
10281         return (uint64_t)ret_conv;
10282 }
10283
10284 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
10285         LDKDecodeError e_conv;
10286         e_conv.inner = (void*)(e & (~1));
10287         e_conv.is_owned = (e & 1) || (e == 0);
10288         e_conv = DecodeError_clone(&e_conv);
10289         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10290         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
10291         return (uint64_t)ret_conv;
10292 }
10293
10294 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
10295         if ((_res & 1) != 0) return;
10296         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10297         FREE((void*)_res);
10298         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
10299 }
10300
10301 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10302         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
10303         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10304         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
10305         return (uint64_t)ret_conv;
10306 }
10307
10308 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
10309         LDKChannelAnnouncement o_conv;
10310         o_conv.inner = (void*)(o & (~1));
10311         o_conv.is_owned = (o & 1) || (o == 0);
10312         o_conv = ChannelAnnouncement_clone(&o_conv);
10313         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10314         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
10315         return (uint64_t)ret_conv;
10316 }
10317
10318 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
10319         LDKDecodeError e_conv;
10320         e_conv.inner = (void*)(e & (~1));
10321         e_conv.is_owned = (e & 1) || (e == 0);
10322         e_conv = DecodeError_clone(&e_conv);
10323         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10324         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
10325         return (uint64_t)ret_conv;
10326 }
10327
10328 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
10329         if ((_res & 1) != 0) return;
10330         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10331         FREE((void*)_res);
10332         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
10333 }
10334
10335 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10336         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
10337         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10338         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
10339         return (uint64_t)ret_conv;
10340 }
10341
10342 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
10343         LDKUnsignedChannelUpdate o_conv;
10344         o_conv.inner = (void*)(o & (~1));
10345         o_conv.is_owned = (o & 1) || (o == 0);
10346         o_conv = UnsignedChannelUpdate_clone(&o_conv);
10347         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10348         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
10349         return (uint64_t)ret_conv;
10350 }
10351
10352 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
10353         LDKDecodeError e_conv;
10354         e_conv.inner = (void*)(e & (~1));
10355         e_conv.is_owned = (e & 1) || (e == 0);
10356         e_conv = DecodeError_clone(&e_conv);
10357         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10358         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
10359         return (uint64_t)ret_conv;
10360 }
10361
10362 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
10363         if ((_res & 1) != 0) return;
10364         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10365         FREE((void*)_res);
10366         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
10367 }
10368
10369 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
10370         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
10371         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10372         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
10373         return (uint64_t)ret_conv;
10374 }
10375
10376 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
10377         LDKChannelUpdate o_conv;
10378         o_conv.inner = (void*)(o & (~1));
10379         o_conv.is_owned = (o & 1) || (o == 0);
10380         o_conv = ChannelUpdate_clone(&o_conv);
10381         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10382         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
10383         return (uint64_t)ret_conv;
10384 }
10385
10386 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
10387         LDKDecodeError e_conv;
10388         e_conv.inner = (void*)(e & (~1));
10389         e_conv.is_owned = (e & 1) || (e == 0);
10390         e_conv = DecodeError_clone(&e_conv);
10391         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10392         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
10393         return (uint64_t)ret_conv;
10394 }
10395
10396 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
10397         if ((_res & 1) != 0) return;
10398         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10399         FREE((void*)_res);
10400         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
10401 }
10402
10403 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
10404         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
10405         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10406         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
10407         return (uint64_t)ret_conv;
10408 }
10409
10410 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
10411         LDKErrorMessage o_conv;
10412         o_conv.inner = (void*)(o & (~1));
10413         o_conv.is_owned = (o & 1) || (o == 0);
10414         o_conv = ErrorMessage_clone(&o_conv);
10415         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10416         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
10417         return (uint64_t)ret_conv;
10418 }
10419
10420 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
10421         LDKDecodeError e_conv;
10422         e_conv.inner = (void*)(e & (~1));
10423         e_conv.is_owned = (e & 1) || (e == 0);
10424         e_conv = DecodeError_clone(&e_conv);
10425         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10426         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
10427         return (uint64_t)ret_conv;
10428 }
10429
10430 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
10431         if ((_res & 1) != 0) return;
10432         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
10433         FREE((void*)_res);
10434         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
10435 }
10436
10437 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
10438         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
10439         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10440         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
10441         return (uint64_t)ret_conv;
10442 }
10443
10444 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
10445         LDKUnsignedNodeAnnouncement o_conv;
10446         o_conv.inner = (void*)(o & (~1));
10447         o_conv.is_owned = (o & 1) || (o == 0);
10448         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
10449         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10450         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
10451         return (uint64_t)ret_conv;
10452 }
10453
10454 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
10455         LDKDecodeError e_conv;
10456         e_conv.inner = (void*)(e & (~1));
10457         e_conv.is_owned = (e & 1) || (e == 0);
10458         e_conv = DecodeError_clone(&e_conv);
10459         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10460         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
10461         return (uint64_t)ret_conv;
10462 }
10463
10464 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
10465         if ((_res & 1) != 0) return;
10466         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10467         FREE((void*)_res);
10468         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
10469 }
10470
10471 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10472         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
10473         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10474         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
10475         return (uint64_t)ret_conv;
10476 }
10477
10478 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
10479         LDKNodeAnnouncement o_conv;
10480         o_conv.inner = (void*)(o & (~1));
10481         o_conv.is_owned = (o & 1) || (o == 0);
10482         o_conv = NodeAnnouncement_clone(&o_conv);
10483         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10484         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
10485         return (uint64_t)ret_conv;
10486 }
10487
10488 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
10489         LDKDecodeError e_conv;
10490         e_conv.inner = (void*)(e & (~1));
10491         e_conv.is_owned = (e & 1) || (e == 0);
10492         e_conv = DecodeError_clone(&e_conv);
10493         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10494         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
10495         return (uint64_t)ret_conv;
10496 }
10497
10498 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
10499         if ((_res & 1) != 0) return;
10500         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10501         FREE((void*)_res);
10502         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
10503 }
10504
10505 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10506         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
10507         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10508         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
10509         return (uint64_t)ret_conv;
10510 }
10511
10512 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
10513         LDKQueryShortChannelIds o_conv;
10514         o_conv.inner = (void*)(o & (~1));
10515         o_conv.is_owned = (o & 1) || (o == 0);
10516         o_conv = QueryShortChannelIds_clone(&o_conv);
10517         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10518         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
10519         return (uint64_t)ret_conv;
10520 }
10521
10522 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
10523         LDKDecodeError e_conv;
10524         e_conv.inner = (void*)(e & (~1));
10525         e_conv.is_owned = (e & 1) || (e == 0);
10526         e_conv = DecodeError_clone(&e_conv);
10527         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10528         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
10529         return (uint64_t)ret_conv;
10530 }
10531
10532 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
10533         if ((_res & 1) != 0) return;
10534         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
10535         FREE((void*)_res);
10536         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
10537 }
10538
10539 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
10540         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
10541         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10542         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
10543         return (uint64_t)ret_conv;
10544 }
10545
10546 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
10547         LDKReplyShortChannelIdsEnd o_conv;
10548         o_conv.inner = (void*)(o & (~1));
10549         o_conv.is_owned = (o & 1) || (o == 0);
10550         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
10551         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10552         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
10553         return (uint64_t)ret_conv;
10554 }
10555
10556 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
10557         LDKDecodeError e_conv;
10558         e_conv.inner = (void*)(e & (~1));
10559         e_conv.is_owned = (e & 1) || (e == 0);
10560         e_conv = DecodeError_clone(&e_conv);
10561         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10562         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
10563         return (uint64_t)ret_conv;
10564 }
10565
10566 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
10567         if ((_res & 1) != 0) return;
10568         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
10569         FREE((void*)_res);
10570         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
10571 }
10572
10573 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
10574         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
10575         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10576         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
10577         return (uint64_t)ret_conv;
10578 }
10579
10580 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
10581         LDKQueryChannelRange o_conv;
10582         o_conv.inner = (void*)(o & (~1));
10583         o_conv.is_owned = (o & 1) || (o == 0);
10584         o_conv = QueryChannelRange_clone(&o_conv);
10585         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10586         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
10587         return (uint64_t)ret_conv;
10588 }
10589
10590 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
10591         LDKDecodeError e_conv;
10592         e_conv.inner = (void*)(e & (~1));
10593         e_conv.is_owned = (e & 1) || (e == 0);
10594         e_conv = DecodeError_clone(&e_conv);
10595         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10596         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
10597         return (uint64_t)ret_conv;
10598 }
10599
10600 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
10601         if ((_res & 1) != 0) return;
10602         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10603         FREE((void*)_res);
10604         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
10605 }
10606
10607 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
10608         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
10609         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10610         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
10611         return (uint64_t)ret_conv;
10612 }
10613
10614 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
10615         LDKReplyChannelRange o_conv;
10616         o_conv.inner = (void*)(o & (~1));
10617         o_conv.is_owned = (o & 1) || (o == 0);
10618         o_conv = ReplyChannelRange_clone(&o_conv);
10619         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10620         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
10621         return (uint64_t)ret_conv;
10622 }
10623
10624 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
10625         LDKDecodeError e_conv;
10626         e_conv.inner = (void*)(e & (~1));
10627         e_conv.is_owned = (e & 1) || (e == 0);
10628         e_conv = DecodeError_clone(&e_conv);
10629         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10630         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
10631         return (uint64_t)ret_conv;
10632 }
10633
10634 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
10635         if ((_res & 1) != 0) return;
10636         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10637         FREE((void*)_res);
10638         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
10639 }
10640
10641 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
10642         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
10643         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10644         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
10645         return (uint64_t)ret_conv;
10646 }
10647
10648 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
10649         LDKGossipTimestampFilter o_conv;
10650         o_conv.inner = (void*)(o & (~1));
10651         o_conv.is_owned = (o & 1) || (o == 0);
10652         o_conv = GossipTimestampFilter_clone(&o_conv);
10653         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10654         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
10655         return (uint64_t)ret_conv;
10656 }
10657
10658 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
10659         LDKDecodeError e_conv;
10660         e_conv.inner = (void*)(e & (~1));
10661         e_conv.is_owned = (e & 1) || (e == 0);
10662         e_conv = DecodeError_clone(&e_conv);
10663         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10664         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
10665         return (uint64_t)ret_conv;
10666 }
10667
10668 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
10669         if ((_res & 1) != 0) return;
10670         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
10671         FREE((void*)_res);
10672         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
10673 }
10674
10675 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
10676         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
10677         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10678         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
10679         return (uint64_t)ret_conv;
10680 }
10681
10682 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
10683         LDKInvoice o_conv;
10684         o_conv.inner = (void*)(o & (~1));
10685         o_conv.is_owned = (o & 1) || (o == 0);
10686         o_conv = Invoice_clone(&o_conv);
10687         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10688         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
10689         return (uint64_t)ret_conv;
10690 }
10691
10692 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
10693         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
10694         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10695         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
10696         return (uint64_t)ret_conv;
10697 }
10698
10699 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
10700         if ((_res & 1) != 0) return;
10701         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
10702         FREE((void*)_res);
10703         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
10704 }
10705
10706 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
10707         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
10708         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10709         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
10710         return (uint64_t)ret_conv;
10711 }
10712
10713 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
10714         if ((this_ptr & 1) != 0) return;
10715         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
10716         FREE((void*)this_ptr);
10717         Event_free(this_ptr_conv);
10718 }
10719
10720 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
10721         LDKEvent* orig_conv = (LDKEvent*)orig;
10722         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
10723         *ret_copy = Event_clone(orig_conv);
10724         uint64_t ret_ref = (uint64_t)ret_copy;
10725         return ret_ref;
10726 }
10727
10728 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
10729         LDKEvent* obj_conv = (LDKEvent*)obj;
10730         LDKCVec_u8Z ret_var = Event_write(obj_conv);
10731         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10732         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10733         CVec_u8Z_free(ret_var);
10734         return ret_arr;
10735 }
10736
10737 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
10738         if ((this_ptr & 1) != 0) return;
10739         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
10740         FREE((void*)this_ptr);
10741         MessageSendEvent_free(this_ptr_conv);
10742 }
10743
10744 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
10745         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
10746         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10747         *ret_copy = MessageSendEvent_clone(orig_conv);
10748         uint64_t ret_ref = (uint64_t)ret_copy;
10749         return ret_ref;
10750 }
10751
10752 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
10753         if ((this_ptr & 1) != 0) return;
10754         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
10755         FREE((void*)this_ptr);
10756         MessageSendEventsProvider_free(this_ptr_conv);
10757 }
10758
10759 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
10760         if ((this_ptr & 1) != 0) return;
10761         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
10762         FREE((void*)this_ptr);
10763         EventsProvider_free(this_ptr_conv);
10764 }
10765
10766 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
10767         if ((this_ptr & 1) != 0) return;
10768         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
10769         FREE((void*)this_ptr);
10770         EventHandler_free(this_ptr_conv);
10771 }
10772
10773 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
10774         if ((this_ptr & 1) != 0) return;
10775         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
10776         FREE((void*)this_ptr);
10777         APIError_free(this_ptr_conv);
10778 }
10779
10780 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
10781         LDKAPIError* orig_conv = (LDKAPIError*)orig;
10782         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
10783         *ret_copy = APIError_clone(orig_conv);
10784         uint64_t ret_ref = (uint64_t)ret_copy;
10785         return ret_ref;
10786 }
10787
10788 uint32_t  __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_tArray sk) {
10789         LDKu8slice msg_ref;
10790         msg_ref.datalen = *((uint32_t*)msg);
10791         msg_ref.data = (int8_t*)(msg + 4);
10792         unsigned char sk_arr[32];
10793         CHECK(*((uint32_t*)sk) == 32);
10794         memcpy(sk_arr, (uint8_t*)(sk + 4), 32);
10795         unsigned char (*sk_ref)[32] = &sk_arr;
10796         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10797         *ret_conv = sign(msg_ref, sk_ref);
10798         return (uint64_t)ret_conv;
10799 }
10800
10801 uint32_t  __attribute__((visibility("default"))) TS_recover_pk(int8_tArray msg, jstring sig) {
10802         LDKu8slice msg_ref;
10803         msg_ref.datalen = *((uint32_t*)msg);
10804         msg_ref.data = (int8_t*)(msg + 4);
10805         LDKStr sig_conv = str_ref_to_owned_c(sig);
10806         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10807         *ret_conv = recover_pk(msg_ref, sig_conv);
10808         return (uint64_t)ret_conv;
10809 }
10810
10811 jboolean  __attribute__((visibility("default"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
10812         LDKu8slice msg_ref;
10813         msg_ref.datalen = *((uint32_t*)msg);
10814         msg_ref.data = (int8_t*)(msg + 4);
10815         LDKStr sig_conv = str_ref_to_owned_c(sig);
10816         LDKPublicKey pk_ref;
10817         CHECK(*((uint32_t*)pk) == 33);
10818         memcpy(pk_ref.compressed_form, (uint8_t*)(pk + 4), 33);
10819         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
10820         return ret_val;
10821 }
10822
10823 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
10824         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
10825         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
10826         return ret_conv;
10827 }
10828
10829 jboolean  __attribute__((visibility("default"))) TS_Level_eq(uint32_t a, uint32_t b) {
10830         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
10831         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
10832         jboolean ret_val = Level_eq(a_conv, b_conv);
10833         return ret_val;
10834 }
10835
10836 int64_t  __attribute__((visibility("default"))) TS_Level_hash(uint32_t o) {
10837         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
10838         int64_t ret_val = Level_hash(o_conv);
10839         return ret_val;
10840 }
10841
10842 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
10843         uint32_t ret_conv = LDKLevel_to_js(Level_max());
10844         return ret_conv;
10845 }
10846
10847 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
10848         if ((this_ptr & 1) != 0) return;
10849         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
10850         FREE((void*)this_ptr);
10851         Logger_free(this_ptr_conv);
10852 }
10853
10854 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
10855         LDKChannelHandshakeConfig this_obj_conv;
10856         this_obj_conv.inner = (void*)(this_obj & (~1));
10857         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10858         ChannelHandshakeConfig_free(this_obj_conv);
10859 }
10860
10861 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
10862         LDKChannelHandshakeConfig this_ptr_conv;
10863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10864         this_ptr_conv.is_owned = false;
10865         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
10866         return ret_val;
10867 }
10868
10869 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
10870         LDKChannelHandshakeConfig this_ptr_conv;
10871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10872         this_ptr_conv.is_owned = false;
10873         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
10874 }
10875
10876 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
10877         LDKChannelHandshakeConfig this_ptr_conv;
10878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10879         this_ptr_conv.is_owned = false;
10880         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
10881         return ret_val;
10882 }
10883
10884 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
10885         LDKChannelHandshakeConfig this_ptr_conv;
10886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10887         this_ptr_conv.is_owned = false;
10888         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
10889 }
10890
10891 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
10892         LDKChannelHandshakeConfig this_ptr_conv;
10893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10894         this_ptr_conv.is_owned = false;
10895         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
10896         return ret_val;
10897 }
10898
10899 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
10900         LDKChannelHandshakeConfig this_ptr_conv;
10901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10902         this_ptr_conv.is_owned = false;
10903         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
10904 }
10905
10906 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) {
10907         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
10908         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10909         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10910         uint64_t ret_ref = (uint64_t)ret_var.inner;
10911         if (ret_var.is_owned) {
10912                 ret_ref |= 1;
10913         }
10914         return ret_ref;
10915 }
10916
10917 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
10918         LDKChannelHandshakeConfig orig_conv;
10919         orig_conv.inner = (void*)(orig & (~1));
10920         orig_conv.is_owned = false;
10921         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
10922         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10923         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10924         uint64_t ret_ref = (uint64_t)ret_var.inner;
10925         if (ret_var.is_owned) {
10926                 ret_ref |= 1;
10927         }
10928         return ret_ref;
10929 }
10930
10931 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
10932         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
10933         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10934         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10935         uint64_t ret_ref = (uint64_t)ret_var.inner;
10936         if (ret_var.is_owned) {
10937                 ret_ref |= 1;
10938         }
10939         return ret_ref;
10940 }
10941
10942 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
10943         LDKChannelHandshakeLimits this_obj_conv;
10944         this_obj_conv.inner = (void*)(this_obj & (~1));
10945         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10946         ChannelHandshakeLimits_free(this_obj_conv);
10947 }
10948
10949 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
10950         LDKChannelHandshakeLimits this_ptr_conv;
10951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10952         this_ptr_conv.is_owned = false;
10953         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
10954         return ret_val;
10955 }
10956
10957 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
10958         LDKChannelHandshakeLimits this_ptr_conv;
10959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10960         this_ptr_conv.is_owned = false;
10961         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
10962 }
10963
10964 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
10965         LDKChannelHandshakeLimits this_ptr_conv;
10966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10967         this_ptr_conv.is_owned = false;
10968         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
10969         return ret_val;
10970 }
10971
10972 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
10973         LDKChannelHandshakeLimits this_ptr_conv;
10974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10975         this_ptr_conv.is_owned = false;
10976         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
10977 }
10978
10979 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
10980         LDKChannelHandshakeLimits this_ptr_conv;
10981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10982         this_ptr_conv.is_owned = false;
10983         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
10984         return ret_val;
10985 }
10986
10987 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
10988         LDKChannelHandshakeLimits this_ptr_conv;
10989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10990         this_ptr_conv.is_owned = false;
10991         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
10992 }
10993
10994 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
10995         LDKChannelHandshakeLimits this_ptr_conv;
10996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10997         this_ptr_conv.is_owned = false;
10998         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
10999         return ret_val;
11000 }
11001
11002 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
11003         LDKChannelHandshakeLimits this_ptr_conv;
11004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11005         this_ptr_conv.is_owned = false;
11006         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
11007 }
11008
11009 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
11010         LDKChannelHandshakeLimits this_ptr_conv;
11011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11012         this_ptr_conv.is_owned = false;
11013         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
11014         return ret_val;
11015 }
11016
11017 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
11018         LDKChannelHandshakeLimits this_ptr_conv;
11019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11020         this_ptr_conv.is_owned = false;
11021         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
11022 }
11023
11024 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
11025         LDKChannelHandshakeLimits this_ptr_conv;
11026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11027         this_ptr_conv.is_owned = false;
11028         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
11029         return ret_val;
11030 }
11031
11032 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
11033         LDKChannelHandshakeLimits this_ptr_conv;
11034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11035         this_ptr_conv.is_owned = false;
11036         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
11037 }
11038
11039 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
11040         LDKChannelHandshakeLimits this_ptr_conv;
11041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11042         this_ptr_conv.is_owned = false;
11043         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
11044         return ret_val;
11045 }
11046
11047 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
11048         LDKChannelHandshakeLimits this_ptr_conv;
11049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11050         this_ptr_conv.is_owned = false;
11051         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
11052 }
11053
11054 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
11055         LDKChannelHandshakeLimits this_ptr_conv;
11056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11057         this_ptr_conv.is_owned = false;
11058         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
11059         return ret_val;
11060 }
11061
11062 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
11063         LDKChannelHandshakeLimits this_ptr_conv;
11064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11065         this_ptr_conv.is_owned = false;
11066         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
11067 }
11068
11069 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) {
11070         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);
11071         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11072         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11073         uint64_t ret_ref = (uint64_t)ret_var.inner;
11074         if (ret_var.is_owned) {
11075                 ret_ref |= 1;
11076         }
11077         return ret_ref;
11078 }
11079
11080 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
11081         LDKChannelHandshakeLimits orig_conv;
11082         orig_conv.inner = (void*)(orig & (~1));
11083         orig_conv.is_owned = false;
11084         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
11085         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11086         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11087         uint64_t ret_ref = (uint64_t)ret_var.inner;
11088         if (ret_var.is_owned) {
11089                 ret_ref |= 1;
11090         }
11091         return ret_ref;
11092 }
11093
11094 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
11095         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
11096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11098         uint64_t ret_ref = (uint64_t)ret_var.inner;
11099         if (ret_var.is_owned) {
11100                 ret_ref |= 1;
11101         }
11102         return ret_ref;
11103 }
11104
11105 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
11106         LDKChannelConfig this_obj_conv;
11107         this_obj_conv.inner = (void*)(this_obj & (~1));
11108         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11109         ChannelConfig_free(this_obj_conv);
11110 }
11111
11112 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
11113         LDKChannelConfig this_ptr_conv;
11114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11115         this_ptr_conv.is_owned = false;
11116         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
11117         return ret_val;
11118 }
11119
11120 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
11121         LDKChannelConfig this_ptr_conv;
11122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11123         this_ptr_conv.is_owned = false;
11124         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
11125 }
11126
11127 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
11128         LDKChannelConfig this_ptr_conv;
11129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11130         this_ptr_conv.is_owned = false;
11131         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
11132         return ret_val;
11133 }
11134
11135 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint32_t this_ptr, int32_t val) {
11136         LDKChannelConfig this_ptr_conv;
11137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11138         this_ptr_conv.is_owned = false;
11139         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
11140 }
11141
11142 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
11143         LDKChannelConfig this_ptr_conv;
11144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11145         this_ptr_conv.is_owned = false;
11146         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
11147         return ret_val;
11148 }
11149
11150 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
11151         LDKChannelConfig this_ptr_conv;
11152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11153         this_ptr_conv.is_owned = false;
11154         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
11155 }
11156
11157 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
11158         LDKChannelConfig this_ptr_conv;
11159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11160         this_ptr_conv.is_owned = false;
11161         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
11162         return ret_val;
11163 }
11164
11165 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
11166         LDKChannelConfig this_ptr_conv;
11167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11168         this_ptr_conv.is_owned = false;
11169         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
11170 }
11171
11172 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
11173         LDKChannelConfig this_ptr_conv;
11174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11175         this_ptr_conv.is_owned = false;
11176         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
11177         return ret_val;
11178 }
11179
11180 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
11181         LDKChannelConfig this_ptr_conv;
11182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11183         this_ptr_conv.is_owned = false;
11184         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
11185 }
11186
11187 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) {
11188         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);
11189         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11190         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11191         uint64_t ret_ref = (uint64_t)ret_var.inner;
11192         if (ret_var.is_owned) {
11193                 ret_ref |= 1;
11194         }
11195         return ret_ref;
11196 }
11197
11198 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
11199         LDKChannelConfig orig_conv;
11200         orig_conv.inner = (void*)(orig & (~1));
11201         orig_conv.is_owned = false;
11202         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
11203         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11204         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11205         uint64_t ret_ref = (uint64_t)ret_var.inner;
11206         if (ret_var.is_owned) {
11207                 ret_ref |= 1;
11208         }
11209         return ret_ref;
11210 }
11211
11212 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
11213         LDKChannelConfig ret_var = ChannelConfig_default();
11214         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11215         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11216         uint64_t ret_ref = (uint64_t)ret_var.inner;
11217         if (ret_var.is_owned) {
11218                 ret_ref |= 1;
11219         }
11220         return ret_ref;
11221 }
11222
11223 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
11224         LDKChannelConfig obj_conv;
11225         obj_conv.inner = (void*)(obj & (~1));
11226         obj_conv.is_owned = false;
11227         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
11228         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11229         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11230         CVec_u8Z_free(ret_var);
11231         return ret_arr;
11232 }
11233
11234 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
11235         LDKu8slice ser_ref;
11236         ser_ref.datalen = *((uint32_t*)ser);
11237         ser_ref.data = (int8_t*)(ser + 4);
11238         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
11239         *ret_conv = ChannelConfig_read(ser_ref);
11240         return (uint64_t)ret_conv;
11241 }
11242
11243 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
11244         LDKUserConfig this_obj_conv;
11245         this_obj_conv.inner = (void*)(this_obj & (~1));
11246         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11247         UserConfig_free(this_obj_conv);
11248 }
11249
11250 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
11251         LDKUserConfig this_ptr_conv;
11252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11253         this_ptr_conv.is_owned = false;
11254         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
11255         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11256         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11257         uint64_t ret_ref = (uint64_t)ret_var.inner;
11258         if (ret_var.is_owned) {
11259                 ret_ref |= 1;
11260         }
11261         return ret_ref;
11262 }
11263
11264 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
11265         LDKUserConfig this_ptr_conv;
11266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11267         this_ptr_conv.is_owned = false;
11268         LDKChannelHandshakeConfig val_conv;
11269         val_conv.inner = (void*)(val & (~1));
11270         val_conv.is_owned = (val & 1) || (val == 0);
11271         val_conv = ChannelHandshakeConfig_clone(&val_conv);
11272         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
11273 }
11274
11275 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
11276         LDKUserConfig this_ptr_conv;
11277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11278         this_ptr_conv.is_owned = false;
11279         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
11280         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11281         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11282         uint64_t ret_ref = (uint64_t)ret_var.inner;
11283         if (ret_var.is_owned) {
11284                 ret_ref |= 1;
11285         }
11286         return ret_ref;
11287 }
11288
11289 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
11290         LDKUserConfig this_ptr_conv;
11291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11292         this_ptr_conv.is_owned = false;
11293         LDKChannelHandshakeLimits val_conv;
11294         val_conv.inner = (void*)(val & (~1));
11295         val_conv.is_owned = (val & 1) || (val == 0);
11296         val_conv = ChannelHandshakeLimits_clone(&val_conv);
11297         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
11298 }
11299
11300 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
11301         LDKUserConfig this_ptr_conv;
11302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11303         this_ptr_conv.is_owned = false;
11304         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
11305         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11306         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11307         uint64_t ret_ref = (uint64_t)ret_var.inner;
11308         if (ret_var.is_owned) {
11309                 ret_ref |= 1;
11310         }
11311         return ret_ref;
11312 }
11313
11314 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
11315         LDKUserConfig this_ptr_conv;
11316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11317         this_ptr_conv.is_owned = false;
11318         LDKChannelConfig val_conv;
11319         val_conv.inner = (void*)(val & (~1));
11320         val_conv.is_owned = (val & 1) || (val == 0);
11321         val_conv = ChannelConfig_clone(&val_conv);
11322         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
11323 }
11324
11325 jboolean  __attribute__((visibility("default"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
11326         LDKUserConfig this_ptr_conv;
11327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11328         this_ptr_conv.is_owned = false;
11329         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
11330         return ret_val;
11331 }
11332
11333 void  __attribute__((visibility("default"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint32_t this_ptr, jboolean val) {
11334         LDKUserConfig this_ptr_conv;
11335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11336         this_ptr_conv.is_owned = false;
11337         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
11338 }
11339
11340 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) {
11341         LDKChannelHandshakeConfig own_channel_config_arg_conv;
11342         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
11343         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
11344         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
11345         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
11346         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
11347         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
11348         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
11349         LDKChannelConfig channel_options_arg_conv;
11350         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
11351         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
11352         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
11353         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);
11354         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11355         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11356         uint64_t ret_ref = (uint64_t)ret_var.inner;
11357         if (ret_var.is_owned) {
11358                 ret_ref |= 1;
11359         }
11360         return ret_ref;
11361 }
11362
11363 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
11364         LDKUserConfig orig_conv;
11365         orig_conv.inner = (void*)(orig & (~1));
11366         orig_conv.is_owned = false;
11367         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
11368         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11369         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11370         uint64_t ret_ref = (uint64_t)ret_var.inner;
11371         if (ret_var.is_owned) {
11372                 ret_ref |= 1;
11373         }
11374         return ret_ref;
11375 }
11376
11377 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
11378         LDKUserConfig ret_var = UserConfig_default();
11379         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11380         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11381         uint64_t ret_ref = (uint64_t)ret_var.inner;
11382         if (ret_var.is_owned) {
11383                 ret_ref |= 1;
11384         }
11385         return ret_ref;
11386 }
11387
11388 void  __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) {
11389         LDKBestBlock this_obj_conv;
11390         this_obj_conv.inner = (void*)(this_obj & (~1));
11391         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11392         BestBlock_free(this_obj_conv);
11393 }
11394
11395 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) {
11396         LDKBestBlock orig_conv;
11397         orig_conv.inner = (void*)(orig & (~1));
11398         orig_conv.is_owned = false;
11399         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
11400         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11401         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11402         uint64_t ret_ref = (uint64_t)ret_var.inner;
11403         if (ret_var.is_owned) {
11404                 ret_ref |= 1;
11405         }
11406         return ret_ref;
11407 }
11408
11409 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
11410         LDKNetwork network_conv = LDKNetwork_from_js(network);
11411         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
11412         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11413         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11414         uint64_t ret_ref = (uint64_t)ret_var.inner;
11415         if (ret_var.is_owned) {
11416                 ret_ref |= 1;
11417         }
11418         return ret_ref;
11419 }
11420
11421 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
11422         LDKThirtyTwoBytes block_hash_ref;
11423         CHECK(*((uint32_t*)block_hash) == 32);
11424         memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
11425         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
11426         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11427         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11428         uint64_t ret_ref = (uint64_t)ret_var.inner;
11429         if (ret_var.is_owned) {
11430                 ret_ref |= 1;
11431         }
11432         return ret_ref;
11433 }
11434
11435 int8_tArray  __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) {
11436         LDKBestBlock this_arg_conv;
11437         this_arg_conv.inner = (void*)(this_arg & (~1));
11438         this_arg_conv.is_owned = false;
11439         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11440         memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32);
11441         return ret_arr;
11442 }
11443
11444 int32_t  __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) {
11445         LDKBestBlock this_arg_conv;
11446         this_arg_conv.inner = (void*)(this_arg & (~1));
11447         this_arg_conv.is_owned = false;
11448         int32_t ret_val = BestBlock_height(&this_arg_conv);
11449         return ret_val;
11450 }
11451
11452 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
11453         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
11454         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
11455         return ret_conv;
11456 }
11457
11458 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
11459         if ((this_ptr & 1) != 0) return;
11460         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
11461         FREE((void*)this_ptr);
11462         Access_free(this_ptr_conv);
11463 }
11464
11465 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
11466         if ((this_ptr & 1) != 0) return;
11467         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
11468         FREE((void*)this_ptr);
11469         Listen_free(this_ptr_conv);
11470 }
11471
11472 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
11473         if ((this_ptr & 1) != 0) return;
11474         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
11475         FREE((void*)this_ptr);
11476         Confirm_free(this_ptr_conv);
11477 }
11478
11479 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
11480         if ((this_ptr & 1) != 0) return;
11481         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
11482         FREE((void*)this_ptr);
11483         Watch_free(this_ptr_conv);
11484 }
11485
11486 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
11487         if ((this_ptr & 1) != 0) return;
11488         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
11489         FREE((void*)this_ptr);
11490         Filter_free(this_ptr_conv);
11491 }
11492
11493 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
11494         LDKWatchedOutput this_obj_conv;
11495         this_obj_conv.inner = (void*)(this_obj & (~1));
11496         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11497         WatchedOutput_free(this_obj_conv);
11498 }
11499
11500 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
11501         LDKWatchedOutput this_ptr_conv;
11502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11503         this_ptr_conv.is_owned = false;
11504         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11505         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
11506         return ret_arr;
11507 }
11508
11509 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
11510         LDKWatchedOutput this_ptr_conv;
11511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11512         this_ptr_conv.is_owned = false;
11513         LDKThirtyTwoBytes val_ref;
11514         CHECK(*((uint32_t*)val) == 32);
11515         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11516         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
11517 }
11518
11519 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
11520         LDKWatchedOutput this_ptr_conv;
11521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11522         this_ptr_conv.is_owned = false;
11523         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
11524         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11525         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11526         uint64_t ret_ref = (uint64_t)ret_var.inner;
11527         if (ret_var.is_owned) {
11528                 ret_ref |= 1;
11529         }
11530         return ret_ref;
11531 }
11532
11533 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
11534         LDKWatchedOutput this_ptr_conv;
11535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11536         this_ptr_conv.is_owned = false;
11537         LDKOutPoint val_conv;
11538         val_conv.inner = (void*)(val & (~1));
11539         val_conv.is_owned = (val & 1) || (val == 0);
11540         val_conv = OutPoint_clone(&val_conv);
11541         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
11542 }
11543
11544 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
11545         LDKWatchedOutput this_ptr_conv;
11546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11547         this_ptr_conv.is_owned = false;
11548         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
11549         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11550         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11551         return ret_arr;
11552 }
11553
11554 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
11555         LDKWatchedOutput this_ptr_conv;
11556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11557         this_ptr_conv.is_owned = false;
11558         LDKCVec_u8Z val_ref;
11559         val_ref.datalen = *((uint32_t*)val);
11560         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11561         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
11562         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
11563 }
11564
11565 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
11566         LDKThirtyTwoBytes block_hash_arg_ref;
11567         CHECK(*((uint32_t*)block_hash_arg) == 32);
11568         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
11569         LDKOutPoint outpoint_arg_conv;
11570         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
11571         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
11572         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
11573         LDKCVec_u8Z script_pubkey_arg_ref;
11574         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
11575         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11576         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
11577         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
11578         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11579         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11580         uint64_t ret_ref = (uint64_t)ret_var.inner;
11581         if (ret_var.is_owned) {
11582                 ret_ref |= 1;
11583         }
11584         return ret_ref;
11585 }
11586
11587 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t orig) {
11588         LDKWatchedOutput orig_conv;
11589         orig_conv.inner = (void*)(orig & (~1));
11590         orig_conv.is_owned = false;
11591         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
11592         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11593         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11594         uint64_t ret_ref = (uint64_t)ret_var.inner;
11595         if (ret_var.is_owned) {
11596                 ret_ref |= 1;
11597         }
11598         return ret_ref;
11599 }
11600
11601 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o) {
11602         LDKWatchedOutput o_conv;
11603         o_conv.inner = (void*)(o & (~1));
11604         o_conv.is_owned = false;
11605         int64_t ret_val = WatchedOutput_hash(&o_conv);
11606         return ret_val;
11607 }
11608
11609 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
11610         if ((this_ptr & 1) != 0) return;
11611         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
11612         FREE((void*)this_ptr);
11613         BroadcasterInterface_free(this_ptr_conv);
11614 }
11615
11616 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
11617         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
11618         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
11619         return ret_conv;
11620 }
11621
11622 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
11623         if ((this_ptr & 1) != 0) return;
11624         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
11625         FREE((void*)this_ptr);
11626         FeeEstimator_free(this_ptr_conv);
11627 }
11628
11629 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
11630         LDKChainMonitor this_obj_conv;
11631         this_obj_conv.inner = (void*)(this_obj & (~1));
11632         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11633         ChainMonitor_free(this_obj_conv);
11634 }
11635
11636 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
11637         LDKFilter *chain_source_conv_ptr = NULL;
11638         if (chain_source != 0) {
11639                 LDKFilter chain_source_conv;
11640                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
11641                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
11642                 *chain_source_conv_ptr = chain_source_conv;
11643         }
11644         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11645         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11646         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
11647         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
11648         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
11649         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11650         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11651         uint64_t ret_ref = (uint64_t)ret_var.inner;
11652         if (ret_var.is_owned) {
11653                 ret_ref |= 1;
11654         }
11655         return ret_ref;
11656 }
11657
11658 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
11659         LDKChainMonitor this_arg_conv;
11660         this_arg_conv.inner = (void*)(this_arg & (~1));
11661         this_arg_conv.is_owned = false;
11662         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
11663         *ret = ChainMonitor_as_Listen(&this_arg_conv);
11664         return (uint64_t)ret;
11665 }
11666
11667 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
11668         LDKChainMonitor this_arg_conv;
11669         this_arg_conv.inner = (void*)(this_arg & (~1));
11670         this_arg_conv.is_owned = false;
11671         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11672         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
11673         return (uint64_t)ret;
11674 }
11675
11676 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
11677         LDKChainMonitor this_arg_conv;
11678         this_arg_conv.inner = (void*)(this_arg & (~1));
11679         this_arg_conv.is_owned = false;
11680         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
11681         *ret = ChainMonitor_as_Watch(&this_arg_conv);
11682         return (uint64_t)ret;
11683 }
11684
11685 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
11686         LDKChainMonitor this_arg_conv;
11687         this_arg_conv.inner = (void*)(this_arg & (~1));
11688         this_arg_conv.is_owned = false;
11689         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11690         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
11691         return (uint64_t)ret;
11692 }
11693
11694 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
11695         LDKChannelMonitorUpdate this_obj_conv;
11696         this_obj_conv.inner = (void*)(this_obj & (~1));
11697         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11698         ChannelMonitorUpdate_free(this_obj_conv);
11699 }
11700
11701 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
11702         LDKChannelMonitorUpdate this_ptr_conv;
11703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11704         this_ptr_conv.is_owned = false;
11705         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
11706         return ret_val;
11707 }
11708
11709 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
11710         LDKChannelMonitorUpdate this_ptr_conv;
11711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11712         this_ptr_conv.is_owned = false;
11713         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
11714 }
11715
11716 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
11717         LDKChannelMonitorUpdate orig_conv;
11718         orig_conv.inner = (void*)(orig & (~1));
11719         orig_conv.is_owned = false;
11720         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
11721         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11722         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11723         uint64_t ret_ref = (uint64_t)ret_var.inner;
11724         if (ret_var.is_owned) {
11725                 ret_ref |= 1;
11726         }
11727         return ret_ref;
11728 }
11729
11730 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
11731         LDKChannelMonitorUpdate obj_conv;
11732         obj_conv.inner = (void*)(obj & (~1));
11733         obj_conv.is_owned = false;
11734         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
11735         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11736         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11737         CVec_u8Z_free(ret_var);
11738         return ret_arr;
11739 }
11740
11741 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
11742         LDKu8slice ser_ref;
11743         ser_ref.datalen = *((uint32_t*)ser);
11744         ser_ref.data = (int8_t*)(ser + 4);
11745         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11746         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
11747         return (uint64_t)ret_conv;
11748 }
11749
11750 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
11751         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
11752         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
11753         return ret_conv;
11754 }
11755
11756 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
11757         LDKMonitorUpdateError this_obj_conv;
11758         this_obj_conv.inner = (void*)(this_obj & (~1));
11759         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11760         MonitorUpdateError_free(this_obj_conv);
11761 }
11762
11763 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
11764         LDKMonitorUpdateError orig_conv;
11765         orig_conv.inner = (void*)(orig & (~1));
11766         orig_conv.is_owned = false;
11767         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
11768         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11769         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11770         uint64_t ret_ref = (uint64_t)ret_var.inner;
11771         if (ret_var.is_owned) {
11772                 ret_ref |= 1;
11773         }
11774         return ret_ref;
11775 }
11776
11777 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
11778         if ((this_ptr & 1) != 0) return;
11779         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
11780         FREE((void*)this_ptr);
11781         MonitorEvent_free(this_ptr_conv);
11782 }
11783
11784 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
11785         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
11786         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11787         *ret_copy = MonitorEvent_clone(orig_conv);
11788         uint64_t ret_ref = (uint64_t)ret_copy;
11789         return ret_ref;
11790 }
11791
11792 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
11793         LDKHTLCUpdate this_obj_conv;
11794         this_obj_conv.inner = (void*)(this_obj & (~1));
11795         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11796         HTLCUpdate_free(this_obj_conv);
11797 }
11798
11799 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
11800         LDKHTLCUpdate orig_conv;
11801         orig_conv.inner = (void*)(orig & (~1));
11802         orig_conv.is_owned = false;
11803         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
11804         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11805         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11806         uint64_t ret_ref = (uint64_t)ret_var.inner;
11807         if (ret_var.is_owned) {
11808                 ret_ref |= 1;
11809         }
11810         return ret_ref;
11811 }
11812
11813 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
11814         LDKHTLCUpdate obj_conv;
11815         obj_conv.inner = (void*)(obj & (~1));
11816         obj_conv.is_owned = false;
11817         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
11818         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11819         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11820         CVec_u8Z_free(ret_var);
11821         return ret_arr;
11822 }
11823
11824 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
11825         LDKu8slice ser_ref;
11826         ser_ref.datalen = *((uint32_t*)ser);
11827         ser_ref.data = (int8_t*)(ser + 4);
11828         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11829         *ret_conv = HTLCUpdate_read(ser_ref);
11830         return (uint64_t)ret_conv;
11831 }
11832
11833 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
11834         LDKChannelMonitor this_obj_conv;
11835         this_obj_conv.inner = (void*)(this_obj & (~1));
11836         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11837         ChannelMonitor_free(this_obj_conv);
11838 }
11839
11840 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
11841         LDKChannelMonitor orig_conv;
11842         orig_conv.inner = (void*)(orig & (~1));
11843         orig_conv.is_owned = false;
11844         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
11845         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11846         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11847         uint64_t ret_ref = (uint64_t)ret_var.inner;
11848         if (ret_var.is_owned) {
11849                 ret_ref |= 1;
11850         }
11851         return ret_ref;
11852 }
11853
11854 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
11855         LDKChannelMonitor obj_conv;
11856         obj_conv.inner = (void*)(obj & (~1));
11857         obj_conv.is_owned = false;
11858         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
11859         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11860         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11861         CVec_u8Z_free(ret_var);
11862         return ret_arr;
11863 }
11864
11865 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) {
11866         LDKChannelMonitor this_arg_conv;
11867         this_arg_conv.inner = (void*)(this_arg & (~1));
11868         this_arg_conv.is_owned = false;
11869         LDKChannelMonitorUpdate updates_conv;
11870         updates_conv.inner = (void*)(updates & (~1));
11871         updates_conv.is_owned = false;
11872         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11873         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11874         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11875         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11876         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
11877         return (uint64_t)ret_conv;
11878 }
11879
11880 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
11881         LDKChannelMonitor this_arg_conv;
11882         this_arg_conv.inner = (void*)(this_arg & (~1));
11883         this_arg_conv.is_owned = false;
11884         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
11885         return ret_val;
11886 }
11887
11888 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
11889         LDKChannelMonitor this_arg_conv;
11890         this_arg_conv.inner = (void*)(this_arg & (~1));
11891         this_arg_conv.is_owned = false;
11892         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11893         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
11894         return (uint64_t)ret_ref;
11895 }
11896
11897 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
11898         LDKChannelMonitor this_arg_conv;
11899         this_arg_conv.inner = (void*)(this_arg & (~1));
11900         this_arg_conv.is_owned = false;
11901         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
11902         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11903         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11904         for (size_t c = 0; c < ret_var.datalen; c++) {
11905                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_54_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11906                 *ret_conv_54_ref = ret_var.data[c];
11907                 ret_arr_ptr[c] = (uint64_t)ret_conv_54_ref;
11908         }
11909         FREE(ret_var.data);
11910         return ret_arr;
11911 }
11912
11913 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
11914         LDKChannelMonitor this_arg_conv;
11915         this_arg_conv.inner = (void*)(this_arg & (~1));
11916         this_arg_conv.is_owned = false;
11917         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
11918         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
11919 }
11920
11921 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
11922         LDKChannelMonitor this_arg_conv;
11923         this_arg_conv.inner = (void*)(this_arg & (~1));
11924         this_arg_conv.is_owned = false;
11925         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
11926         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11927         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11928         for (size_t o = 0; o < ret_var.datalen; o++) {
11929                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11930                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
11931                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
11932                 ret_arr_ptr[o] = ret_conv_14_ref;
11933         }
11934         FREE(ret_var.data);
11935         return ret_arr;
11936 }
11937
11938 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
11939         LDKChannelMonitor this_arg_conv;
11940         this_arg_conv.inner = (void*)(this_arg & (~1));
11941         this_arg_conv.is_owned = false;
11942         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
11943         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11944         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11945         for (size_t h = 0; h < ret_var.datalen; h++) {
11946                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11947                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
11948                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
11949                 ret_arr_ptr[h] = ret_conv_7_ref;
11950         }
11951         FREE(ret_var.data);
11952         return ret_arr;
11953 }
11954
11955 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
11956         LDKChannelMonitor this_arg_conv;
11957         this_arg_conv.inner = (void*)(this_arg & (~1));
11958         this_arg_conv.is_owned = false;
11959         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11960         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
11961         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
11962         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
11963         for (size_t m = 0; m < ret_var.datalen; m++) {
11964                 LDKTransaction ret_conv_12_var = ret_var.data[m];
11965                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11966                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
11967                 Transaction_free(ret_conv_12_var);
11968                 ret_arr_ptr[m] = ret_conv_12_arr;
11969         }
11970         FREE(ret_var.data);
11971         return ret_arr;
11972 }
11973
11974 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) {
11975         LDKChannelMonitor this_arg_conv;
11976         this_arg_conv.inner = (void*)(this_arg & (~1));
11977         this_arg_conv.is_owned = false;
11978         unsigned char header_arr[80];
11979         CHECK(*((uint32_t*)header) == 80);
11980         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11981         unsigned char (*header_ref)[80] = &header_arr;
11982         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11983         txdata_constr.datalen = *((uint32_t*)txdata);
11984         if (txdata_constr.datalen > 0)
11985                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11986         else
11987                 txdata_constr.data = NULL;
11988         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
11989         for (size_t e = 0; e < txdata_constr.datalen; e++) {
11990                 uint32_t txdata_conv_30 = txdata_vals[e];
11991                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
11992                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
11993                 txdata_constr.data[e] = txdata_conv_30_conv;
11994         }
11995         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11996         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11997         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11998         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);
11999         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
12000         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
12001         for (size_t x = 0; x < ret_var.datalen; x++) {
12002                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12003                 *ret_conv_49_ref = ret_var.data[x];
12004                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
12005         }
12006         FREE(ret_var.data);
12007         return ret_arr;
12008 }
12009
12010 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) {
12011         LDKChannelMonitor this_arg_conv;
12012         this_arg_conv.inner = (void*)(this_arg & (~1));
12013         this_arg_conv.is_owned = false;
12014         unsigned char header_arr[80];
12015         CHECK(*((uint32_t*)header) == 80);
12016         memcpy(header_arr, (uint8_t*)(header + 4), 80);
12017         unsigned char (*header_ref)[80] = &header_arr;
12018         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12019         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12020         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12021         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
12022 }
12023
12024 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) {
12025         LDKChannelMonitor this_arg_conv;
12026         this_arg_conv.inner = (void*)(this_arg & (~1));
12027         this_arg_conv.is_owned = false;
12028         unsigned char header_arr[80];
12029         CHECK(*((uint32_t*)header) == 80);
12030         memcpy(header_arr, (uint8_t*)(header + 4), 80);
12031         unsigned char (*header_ref)[80] = &header_arr;
12032         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12033         txdata_constr.datalen = *((uint32_t*)txdata);
12034         if (txdata_constr.datalen > 0)
12035                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12036         else
12037                 txdata_constr.data = NULL;
12038         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
12039         for (size_t e = 0; e < txdata_constr.datalen; e++) {
12040                 uint32_t txdata_conv_30 = txdata_vals[e];
12041                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
12042                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
12043                 txdata_constr.data[e] = txdata_conv_30_conv;
12044         }
12045         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12046         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12047         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12048         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);
12049         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
12050         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
12051         for (size_t x = 0; x < ret_var.datalen; x++) {
12052                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12053                 *ret_conv_49_ref = ret_var.data[x];
12054                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
12055         }
12056         FREE(ret_var.data);
12057         return ret_arr;
12058 }
12059
12060 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) {
12061         LDKChannelMonitor this_arg_conv;
12062         this_arg_conv.inner = (void*)(this_arg & (~1));
12063         this_arg_conv.is_owned = false;
12064         unsigned char txid_arr[32];
12065         CHECK(*((uint32_t*)txid) == 32);
12066         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
12067         unsigned char (*txid_ref)[32] = &txid_arr;
12068         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12069         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12070         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12071         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
12072 }
12073
12074 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) {
12075         LDKChannelMonitor this_arg_conv;
12076         this_arg_conv.inner = (void*)(this_arg & (~1));
12077         this_arg_conv.is_owned = false;
12078         unsigned char header_arr[80];
12079         CHECK(*((uint32_t*)header) == 80);
12080         memcpy(header_arr, (uint8_t*)(header + 4), 80);
12081         unsigned char (*header_ref)[80] = &header_arr;
12082         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12083         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12084         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12085         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
12086         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
12087         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
12088         for (size_t x = 0; x < ret_var.datalen; x++) {
12089                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12090                 *ret_conv_49_ref = ret_var.data[x];
12091                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
12092         }
12093         FREE(ret_var.data);
12094         return ret_arr;
12095 }
12096
12097 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
12098         LDKChannelMonitor this_arg_conv;
12099         this_arg_conv.inner = (void*)(this_arg & (~1));
12100         this_arg_conv.is_owned = false;
12101         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
12102         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
12103         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
12104         for (size_t m = 0; m < ret_var.datalen; m++) {
12105                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12106                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
12107                 ret_arr_ptr[m] = ret_conv_12_arr;
12108         }
12109         FREE(ret_var.data);
12110         return ret_arr;
12111 }
12112
12113 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
12114         LDKChannelMonitor this_arg_conv;
12115         this_arg_conv.inner = (void*)(this_arg & (~1));
12116         this_arg_conv.is_owned = false;
12117         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
12118         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12119         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12120         uint64_t ret_ref = (uint64_t)ret_var.inner;
12121         if (ret_var.is_owned) {
12122                 ret_ref |= 1;
12123         }
12124         return ret_ref;
12125 }
12126
12127 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
12128         if ((this_ptr & 1) != 0) return;
12129         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
12130         FREE((void*)this_ptr);
12131         Persist_free(this_ptr_conv);
12132 }
12133
12134 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
12135         LDKu8slice ser_ref;
12136         ser_ref.datalen = *((uint32_t*)ser);
12137         ser_ref.data = (int8_t*)(ser + 4);
12138         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
12139         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
12140         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
12141         return (uint64_t)ret_conv;
12142 }
12143
12144 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
12145         LDKOutPoint this_obj_conv;
12146         this_obj_conv.inner = (void*)(this_obj & (~1));
12147         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12148         OutPoint_free(this_obj_conv);
12149 }
12150
12151 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
12152         LDKOutPoint this_ptr_conv;
12153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12154         this_ptr_conv.is_owned = false;
12155         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12156         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
12157         return ret_arr;
12158 }
12159
12160 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
12161         LDKOutPoint this_ptr_conv;
12162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12163         this_ptr_conv.is_owned = false;
12164         LDKThirtyTwoBytes val_ref;
12165         CHECK(*((uint32_t*)val) == 32);
12166         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12167         OutPoint_set_txid(&this_ptr_conv, val_ref);
12168 }
12169
12170 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
12171         LDKOutPoint this_ptr_conv;
12172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12173         this_ptr_conv.is_owned = false;
12174         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
12175         return ret_val;
12176 }
12177
12178 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
12179         LDKOutPoint this_ptr_conv;
12180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12181         this_ptr_conv.is_owned = false;
12182         OutPoint_set_index(&this_ptr_conv, val);
12183 }
12184
12185 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
12186         LDKThirtyTwoBytes txid_arg_ref;
12187         CHECK(*((uint32_t*)txid_arg) == 32);
12188         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
12189         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
12190         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12191         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12192         uint64_t ret_ref = (uint64_t)ret_var.inner;
12193         if (ret_var.is_owned) {
12194                 ret_ref |= 1;
12195         }
12196         return ret_ref;
12197 }
12198
12199 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
12200         LDKOutPoint orig_conv;
12201         orig_conv.inner = (void*)(orig & (~1));
12202         orig_conv.is_owned = false;
12203         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
12204         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12205         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12206         uint64_t ret_ref = (uint64_t)ret_var.inner;
12207         if (ret_var.is_owned) {
12208                 ret_ref |= 1;
12209         }
12210         return ret_ref;
12211 }
12212
12213 jboolean  __attribute__((visibility("default"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
12214         LDKOutPoint a_conv;
12215         a_conv.inner = (void*)(a & (~1));
12216         a_conv.is_owned = false;
12217         LDKOutPoint b_conv;
12218         b_conv.inner = (void*)(b & (~1));
12219         b_conv.is_owned = false;
12220         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
12221         return ret_val;
12222 }
12223
12224 int64_t  __attribute__((visibility("default"))) TS_OutPoint_hash(uint32_t o) {
12225         LDKOutPoint o_conv;
12226         o_conv.inner = (void*)(o & (~1));
12227         o_conv.is_owned = false;
12228         int64_t ret_val = OutPoint_hash(&o_conv);
12229         return ret_val;
12230 }
12231
12232 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
12233         LDKOutPoint this_arg_conv;
12234         this_arg_conv.inner = (void*)(this_arg & (~1));
12235         this_arg_conv.is_owned = false;
12236         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12237         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
12238         return ret_arr;
12239 }
12240
12241 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
12242         LDKOutPoint obj_conv;
12243         obj_conv.inner = (void*)(obj & (~1));
12244         obj_conv.is_owned = false;
12245         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
12246         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12247         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12248         CVec_u8Z_free(ret_var);
12249         return ret_arr;
12250 }
12251
12252 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
12253         LDKu8slice ser_ref;
12254         ser_ref.datalen = *((uint32_t*)ser);
12255         ser_ref.data = (int8_t*)(ser + 4);
12256         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12257         *ret_conv = OutPoint_read(ser_ref);
12258         return (uint64_t)ret_conv;
12259 }
12260
12261 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
12262         LDKDelayedPaymentOutputDescriptor this_obj_conv;
12263         this_obj_conv.inner = (void*)(this_obj & (~1));
12264         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12265         DelayedPaymentOutputDescriptor_free(this_obj_conv);
12266 }
12267
12268 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
12269         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12271         this_ptr_conv.is_owned = false;
12272         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
12273         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12274         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12275         uint64_t ret_ref = (uint64_t)ret_var.inner;
12276         if (ret_var.is_owned) {
12277                 ret_ref |= 1;
12278         }
12279         return ret_ref;
12280 }
12281
12282 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
12283         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12285         this_ptr_conv.is_owned = false;
12286         LDKOutPoint val_conv;
12287         val_conv.inner = (void*)(val & (~1));
12288         val_conv.is_owned = (val & 1) || (val == 0);
12289         val_conv = OutPoint_clone(&val_conv);
12290         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
12291 }
12292
12293 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
12294         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12296         this_ptr_conv.is_owned = false;
12297         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12298         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12299         return ret_arr;
12300 }
12301
12302 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12303         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12305         this_ptr_conv.is_owned = false;
12306         LDKPublicKey val_ref;
12307         CHECK(*((uint32_t*)val) == 33);
12308         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12309         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
12310 }
12311
12312 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
12313         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12315         this_ptr_conv.is_owned = false;
12316         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
12317         return ret_val;
12318 }
12319
12320 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
12321         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12323         this_ptr_conv.is_owned = false;
12324         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
12325 }
12326
12327 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
12328         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12330         this_ptr_conv.is_owned = false;
12331         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
12332         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
12333 }
12334
12335 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
12336         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12338         this_ptr_conv.is_owned = false;
12339         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12340         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
12341         return ret_arr;
12342 }
12343
12344 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
12345         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12347         this_ptr_conv.is_owned = false;
12348         LDKPublicKey val_ref;
12349         CHECK(*((uint32_t*)val) == 33);
12350         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12351         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
12352 }
12353
12354 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
12355         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12357         this_ptr_conv.is_owned = false;
12358         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12359         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
12360         return ret_arr;
12361 }
12362
12363 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
12364         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12366         this_ptr_conv.is_owned = false;
12367         LDKThirtyTwoBytes val_ref;
12368         CHECK(*((uint32_t*)val) == 32);
12369         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12370         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
12371 }
12372
12373 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
12374         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12376         this_ptr_conv.is_owned = false;
12377         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
12378         return ret_val;
12379 }
12380
12381 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
12382         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12384         this_ptr_conv.is_owned = false;
12385         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
12386 }
12387
12388 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) {
12389         LDKOutPoint outpoint_arg_conv;
12390         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12391         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12392         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12393         LDKPublicKey per_commitment_point_arg_ref;
12394         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
12395         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
12396         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
12397         LDKPublicKey revocation_pubkey_arg_ref;
12398         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
12399         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
12400         LDKThirtyTwoBytes channel_keys_id_arg_ref;
12401         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
12402         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
12403         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);
12404         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12405         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12406         uint64_t ret_ref = (uint64_t)ret_var.inner;
12407         if (ret_var.is_owned) {
12408                 ret_ref |= 1;
12409         }
12410         return ret_ref;
12411 }
12412
12413 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
12414         LDKDelayedPaymentOutputDescriptor orig_conv;
12415         orig_conv.inner = (void*)(orig & (~1));
12416         orig_conv.is_owned = false;
12417         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
12418         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12419         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12420         uint64_t ret_ref = (uint64_t)ret_var.inner;
12421         if (ret_var.is_owned) {
12422                 ret_ref |= 1;
12423         }
12424         return ret_ref;
12425 }
12426
12427 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
12428         LDKDelayedPaymentOutputDescriptor obj_conv;
12429         obj_conv.inner = (void*)(obj & (~1));
12430         obj_conv.is_owned = false;
12431         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
12432         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12433         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12434         CVec_u8Z_free(ret_var);
12435         return ret_arr;
12436 }
12437
12438 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
12439         LDKu8slice ser_ref;
12440         ser_ref.datalen = *((uint32_t*)ser);
12441         ser_ref.data = (int8_t*)(ser + 4);
12442         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12443         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
12444         return (uint64_t)ret_conv;
12445 }
12446
12447 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
12448         LDKStaticPaymentOutputDescriptor this_obj_conv;
12449         this_obj_conv.inner = (void*)(this_obj & (~1));
12450         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12451         StaticPaymentOutputDescriptor_free(this_obj_conv);
12452 }
12453
12454 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
12455         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12457         this_ptr_conv.is_owned = false;
12458         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
12459         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12460         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12461         uint64_t ret_ref = (uint64_t)ret_var.inner;
12462         if (ret_var.is_owned) {
12463                 ret_ref |= 1;
12464         }
12465         return ret_ref;
12466 }
12467
12468 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
12469         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12471         this_ptr_conv.is_owned = false;
12472         LDKOutPoint val_conv;
12473         val_conv.inner = (void*)(val & (~1));
12474         val_conv.is_owned = (val & 1) || (val == 0);
12475         val_conv = OutPoint_clone(&val_conv);
12476         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
12477 }
12478
12479 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
12480         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12482         this_ptr_conv.is_owned = false;
12483         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
12484         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
12485 }
12486
12487 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
12488         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12490         this_ptr_conv.is_owned = false;
12491         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12492         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
12493         return ret_arr;
12494 }
12495
12496 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
12497         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12499         this_ptr_conv.is_owned = false;
12500         LDKThirtyTwoBytes val_ref;
12501         CHECK(*((uint32_t*)val) == 32);
12502         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12503         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
12504 }
12505
12506 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
12507         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12509         this_ptr_conv.is_owned = false;
12510         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
12511         return ret_val;
12512 }
12513
12514 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
12515         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12517         this_ptr_conv.is_owned = false;
12518         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
12519 }
12520
12521 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) {
12522         LDKOutPoint outpoint_arg_conv;
12523         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12524         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12525         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12526         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
12527         LDKThirtyTwoBytes channel_keys_id_arg_ref;
12528         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
12529         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
12530         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
12531         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12532         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12533         uint64_t ret_ref = (uint64_t)ret_var.inner;
12534         if (ret_var.is_owned) {
12535                 ret_ref |= 1;
12536         }
12537         return ret_ref;
12538 }
12539
12540 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
12541         LDKStaticPaymentOutputDescriptor orig_conv;
12542         orig_conv.inner = (void*)(orig & (~1));
12543         orig_conv.is_owned = false;
12544         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
12545         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12546         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12547         uint64_t ret_ref = (uint64_t)ret_var.inner;
12548         if (ret_var.is_owned) {
12549                 ret_ref |= 1;
12550         }
12551         return ret_ref;
12552 }
12553
12554 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
12555         LDKStaticPaymentOutputDescriptor obj_conv;
12556         obj_conv.inner = (void*)(obj & (~1));
12557         obj_conv.is_owned = false;
12558         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
12559         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12560         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12561         CVec_u8Z_free(ret_var);
12562         return ret_arr;
12563 }
12564
12565 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
12566         LDKu8slice ser_ref;
12567         ser_ref.datalen = *((uint32_t*)ser);
12568         ser_ref.data = (int8_t*)(ser + 4);
12569         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
12570         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
12571         return (uint64_t)ret_conv;
12572 }
12573
12574 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
12575         if ((this_ptr & 1) != 0) return;
12576         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
12577         FREE((void*)this_ptr);
12578         SpendableOutputDescriptor_free(this_ptr_conv);
12579 }
12580
12581 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
12582         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
12583         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
12584         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
12585         uint64_t ret_ref = (uint64_t)ret_copy;
12586         return ret_ref;
12587 }
12588
12589 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
12590         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
12591         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
12592         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12593         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12594         CVec_u8Z_free(ret_var);
12595         return ret_arr;
12596 }
12597
12598 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
12599         LDKu8slice ser_ref;
12600         ser_ref.datalen = *((uint32_t*)ser);
12601         ser_ref.data = (int8_t*)(ser + 4);
12602         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
12603         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
12604         return (uint64_t)ret_conv;
12605 }
12606
12607 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
12608         if ((this_ptr & 1) != 0) return;
12609         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
12610         FREE((void*)this_ptr);
12611         BaseSign_free(this_ptr_conv);
12612 }
12613
12614 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
12615         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
12616         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12617         *ret = Sign_clone(orig_conv);
12618         return (uint64_t)ret;
12619 }
12620
12621 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
12622         if ((this_ptr & 1) != 0) return;
12623         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
12624         FREE((void*)this_ptr);
12625         Sign_free(this_ptr_conv);
12626 }
12627
12628 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
12629         if ((this_ptr & 1) != 0) return;
12630         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
12631         FREE((void*)this_ptr);
12632         KeysInterface_free(this_ptr_conv);
12633 }
12634
12635 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
12636         LDKInMemorySigner this_obj_conv;
12637         this_obj_conv.inner = (void*)(this_obj & (~1));
12638         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12639         InMemorySigner_free(this_obj_conv);
12640 }
12641
12642 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
12643         LDKInMemorySigner this_ptr_conv;
12644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12645         this_ptr_conv.is_owned = false;
12646         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12647         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
12648         return ret_arr;
12649 }
12650
12651 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
12652         LDKInMemorySigner this_ptr_conv;
12653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12654         this_ptr_conv.is_owned = false;
12655         LDKSecretKey val_ref;
12656         CHECK(*((uint32_t*)val) == 32);
12657         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12658         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
12659 }
12660
12661 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
12662         LDKInMemorySigner this_ptr_conv;
12663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12664         this_ptr_conv.is_owned = false;
12665         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12666         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
12667         return ret_arr;
12668 }
12669
12670 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
12671         LDKInMemorySigner this_ptr_conv;
12672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12673         this_ptr_conv.is_owned = false;
12674         LDKSecretKey val_ref;
12675         CHECK(*((uint32_t*)val) == 32);
12676         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12677         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
12678 }
12679
12680 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
12681         LDKInMemorySigner this_ptr_conv;
12682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12683         this_ptr_conv.is_owned = false;
12684         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12685         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
12686         return ret_arr;
12687 }
12688
12689 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
12690         LDKInMemorySigner this_ptr_conv;
12691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12692         this_ptr_conv.is_owned = false;
12693         LDKSecretKey val_ref;
12694         CHECK(*((uint32_t*)val) == 32);
12695         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12696         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
12697 }
12698
12699 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
12700         LDKInMemorySigner this_ptr_conv;
12701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12702         this_ptr_conv.is_owned = false;
12703         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12704         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
12705         return ret_arr;
12706 }
12707
12708 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
12709         LDKInMemorySigner this_ptr_conv;
12710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12711         this_ptr_conv.is_owned = false;
12712         LDKSecretKey val_ref;
12713         CHECK(*((uint32_t*)val) == 32);
12714         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12715         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
12716 }
12717
12718 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
12719         LDKInMemorySigner this_ptr_conv;
12720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12721         this_ptr_conv.is_owned = false;
12722         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12723         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
12724         return ret_arr;
12725 }
12726
12727 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
12728         LDKInMemorySigner this_ptr_conv;
12729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12730         this_ptr_conv.is_owned = false;
12731         LDKSecretKey val_ref;
12732         CHECK(*((uint32_t*)val) == 32);
12733         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12734         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
12735 }
12736
12737 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
12738         LDKInMemorySigner this_ptr_conv;
12739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12740         this_ptr_conv.is_owned = false;
12741         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12742         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
12743         return ret_arr;
12744 }
12745
12746 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
12747         LDKInMemorySigner this_ptr_conv;
12748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12749         this_ptr_conv.is_owned = false;
12750         LDKThirtyTwoBytes val_ref;
12751         CHECK(*((uint32_t*)val) == 32);
12752         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12753         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
12754 }
12755
12756 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
12757         LDKInMemorySigner orig_conv;
12758         orig_conv.inner = (void*)(orig & (~1));
12759         orig_conv.is_owned = false;
12760         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
12761         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12762         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12763         uint64_t ret_ref = (uint64_t)ret_var.inner;
12764         if (ret_var.is_owned) {
12765                 ret_ref |= 1;
12766         }
12767         return ret_ref;
12768 }
12769
12770 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) {
12771         LDKSecretKey funding_key_ref;
12772         CHECK(*((uint32_t*)funding_key) == 32);
12773         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
12774         LDKSecretKey revocation_base_key_ref;
12775         CHECK(*((uint32_t*)revocation_base_key) == 32);
12776         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
12777         LDKSecretKey payment_key_ref;
12778         CHECK(*((uint32_t*)payment_key) == 32);
12779         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
12780         LDKSecretKey delayed_payment_base_key_ref;
12781         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
12782         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
12783         LDKSecretKey htlc_base_key_ref;
12784         CHECK(*((uint32_t*)htlc_base_key) == 32);
12785         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
12786         LDKThirtyTwoBytes commitment_seed_ref;
12787         CHECK(*((uint32_t*)commitment_seed) == 32);
12788         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
12789         LDKThirtyTwoBytes channel_keys_id_ref;
12790         CHECK(*((uint32_t*)channel_keys_id) == 32);
12791         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
12792         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);
12793         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12794         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12795         uint64_t ret_ref = (uint64_t)ret_var.inner;
12796         if (ret_var.is_owned) {
12797                 ret_ref |= 1;
12798         }
12799         return ret_ref;
12800 }
12801
12802 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
12803         LDKInMemorySigner this_arg_conv;
12804         this_arg_conv.inner = (void*)(this_arg & (~1));
12805         this_arg_conv.is_owned = false;
12806         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
12807         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12808         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12809         uint64_t ret_ref = (uint64_t)ret_var.inner;
12810         if (ret_var.is_owned) {
12811                 ret_ref |= 1;
12812         }
12813         return ret_ref;
12814 }
12815
12816 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
12817         LDKInMemorySigner this_arg_conv;
12818         this_arg_conv.inner = (void*)(this_arg & (~1));
12819         this_arg_conv.is_owned = false;
12820         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
12821         return ret_val;
12822 }
12823
12824 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
12825         LDKInMemorySigner this_arg_conv;
12826         this_arg_conv.inner = (void*)(this_arg & (~1));
12827         this_arg_conv.is_owned = false;
12828         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
12829         return ret_val;
12830 }
12831
12832 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
12833         LDKInMemorySigner this_arg_conv;
12834         this_arg_conv.inner = (void*)(this_arg & (~1));
12835         this_arg_conv.is_owned = false;
12836         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
12837         return ret_val;
12838 }
12839
12840 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
12841         LDKInMemorySigner this_arg_conv;
12842         this_arg_conv.inner = (void*)(this_arg & (~1));
12843         this_arg_conv.is_owned = false;
12844         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
12845         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12846         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12847         uint64_t ret_ref = (uint64_t)ret_var.inner;
12848         if (ret_var.is_owned) {
12849                 ret_ref |= 1;
12850         }
12851         return ret_ref;
12852 }
12853
12854 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
12855         LDKInMemorySigner this_arg_conv;
12856         this_arg_conv.inner = (void*)(this_arg & (~1));
12857         this_arg_conv.is_owned = false;
12858         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
12859         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12860         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12861         uint64_t ret_ref = (uint64_t)ret_var.inner;
12862         if (ret_var.is_owned) {
12863                 ret_ref |= 1;
12864         }
12865         return ret_ref;
12866 }
12867
12868 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) {
12869         LDKInMemorySigner this_arg_conv;
12870         this_arg_conv.inner = (void*)(this_arg & (~1));
12871         this_arg_conv.is_owned = false;
12872         LDKTransaction spend_tx_ref;
12873         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
12874         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12875         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
12876         spend_tx_ref.data_is_owned = true;
12877         LDKStaticPaymentOutputDescriptor descriptor_conv;
12878         descriptor_conv.inner = (void*)(descriptor & (~1));
12879         descriptor_conv.is_owned = false;
12880         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12881         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12882         return (uint64_t)ret_conv;
12883 }
12884
12885 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) {
12886         LDKInMemorySigner this_arg_conv;
12887         this_arg_conv.inner = (void*)(this_arg & (~1));
12888         this_arg_conv.is_owned = false;
12889         LDKTransaction spend_tx_ref;
12890         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
12891         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12892         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
12893         spend_tx_ref.data_is_owned = true;
12894         LDKDelayedPaymentOutputDescriptor descriptor_conv;
12895         descriptor_conv.inner = (void*)(descriptor & (~1));
12896         descriptor_conv.is_owned = false;
12897         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12898         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12899         return (uint64_t)ret_conv;
12900 }
12901
12902 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
12903         LDKInMemorySigner this_arg_conv;
12904         this_arg_conv.inner = (void*)(this_arg & (~1));
12905         this_arg_conv.is_owned = false;
12906         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
12907         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
12908         return (uint64_t)ret;
12909 }
12910
12911 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
12912         LDKInMemorySigner this_arg_conv;
12913         this_arg_conv.inner = (void*)(this_arg & (~1));
12914         this_arg_conv.is_owned = false;
12915         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12916         *ret = InMemorySigner_as_Sign(&this_arg_conv);
12917         return (uint64_t)ret;
12918 }
12919
12920 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
12921         LDKInMemorySigner obj_conv;
12922         obj_conv.inner = (void*)(obj & (~1));
12923         obj_conv.is_owned = false;
12924         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
12925         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12926         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12927         CVec_u8Z_free(ret_var);
12928         return ret_arr;
12929 }
12930
12931 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
12932         LDKu8slice ser_ref;
12933         ser_ref.datalen = *((uint32_t*)ser);
12934         ser_ref.data = (int8_t*)(ser + 4);
12935         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
12936         *ret_conv = InMemorySigner_read(ser_ref);
12937         return (uint64_t)ret_conv;
12938 }
12939
12940 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
12941         LDKKeysManager this_obj_conv;
12942         this_obj_conv.inner = (void*)(this_obj & (~1));
12943         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12944         KeysManager_free(this_obj_conv);
12945 }
12946
12947 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
12948         unsigned char seed_arr[32];
12949         CHECK(*((uint32_t*)seed) == 32);
12950         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
12951         unsigned char (*seed_ref)[32] = &seed_arr;
12952         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
12953         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12954         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12955         uint64_t ret_ref = (uint64_t)ret_var.inner;
12956         if (ret_var.is_owned) {
12957                 ret_ref |= 1;
12958         }
12959         return ret_ref;
12960 }
12961
12962 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
12963         LDKKeysManager this_arg_conv;
12964         this_arg_conv.inner = (void*)(this_arg & (~1));
12965         this_arg_conv.is_owned = false;
12966         unsigned char params_arr[32];
12967         CHECK(*((uint32_t*)params) == 32);
12968         memcpy(params_arr, (uint8_t*)(params + 4), 32);
12969         unsigned char (*params_ref)[32] = &params_arr;
12970         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
12971         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12972         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12973         uint64_t ret_ref = (uint64_t)ret_var.inner;
12974         if (ret_var.is_owned) {
12975                 ret_ref |= 1;
12976         }
12977         return ret_ref;
12978 }
12979
12980 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) {
12981         LDKKeysManager this_arg_conv;
12982         this_arg_conv.inner = (void*)(this_arg & (~1));
12983         this_arg_conv.is_owned = false;
12984         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
12985         descriptors_constr.datalen = *((uint32_t*)descriptors);
12986         if (descriptors_constr.datalen > 0)
12987                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12988         else
12989                 descriptors_constr.data = NULL;
12990         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
12991         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
12992                 uint32_t descriptors_conv_27 = descriptors_vals[b];
12993                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
12994                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
12995                 descriptors_constr.data[b] = descriptors_conv_27_conv;
12996         }
12997         LDKCVec_TxOutZ outputs_constr;
12998         outputs_constr.datalen = *((uint32_t*)outputs);
12999         if (outputs_constr.datalen > 0)
13000                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
13001         else
13002                 outputs_constr.data = NULL;
13003         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
13004         for (size_t h = 0; h < outputs_constr.datalen; h++) {
13005                 uint32_t outputs_conv_7 = outputs_vals[h];
13006                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
13007                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
13008                 outputs_constr.data[h] = outputs_conv_7_conv;
13009         }
13010         LDKCVec_u8Z change_destination_script_ref;
13011         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
13012         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
13013         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
13014         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13015         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
13016         return (uint64_t)ret_conv;
13017 }
13018
13019 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
13020         LDKKeysManager this_arg_conv;
13021         this_arg_conv.inner = (void*)(this_arg & (~1));
13022         this_arg_conv.is_owned = false;
13023         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
13024         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
13025         return (uint64_t)ret;
13026 }
13027
13028 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
13029         LDKChannelManager this_obj_conv;
13030         this_obj_conv.inner = (void*)(this_obj & (~1));
13031         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13032         ChannelManager_free(this_obj_conv);
13033 }
13034
13035 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
13036         LDKChainParameters this_obj_conv;
13037         this_obj_conv.inner = (void*)(this_obj & (~1));
13038         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13039         ChainParameters_free(this_obj_conv);
13040 }
13041
13042 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
13043         LDKChainParameters this_ptr_conv;
13044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13045         this_ptr_conv.is_owned = false;
13046         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
13047         return ret_conv;
13048 }
13049
13050 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
13051         LDKChainParameters this_ptr_conv;
13052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13053         this_ptr_conv.is_owned = false;
13054         LDKNetwork val_conv = LDKNetwork_from_js(val);
13055         ChainParameters_set_network(&this_ptr_conv, val_conv);
13056 }
13057
13058 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
13059         LDKChainParameters this_ptr_conv;
13060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13061         this_ptr_conv.is_owned = false;
13062         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
13063         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13064         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13065         uint64_t ret_ref = (uint64_t)ret_var.inner;
13066         if (ret_var.is_owned) {
13067                 ret_ref |= 1;
13068         }
13069         return ret_ref;
13070 }
13071
13072 void  __attribute__((visibility("default"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
13073         LDKChainParameters this_ptr_conv;
13074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13075         this_ptr_conv.is_owned = false;
13076         LDKBestBlock val_conv;
13077         val_conv.inner = (void*)(val & (~1));
13078         val_conv.is_owned = (val & 1) || (val == 0);
13079         val_conv = BestBlock_clone(&val_conv);
13080         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
13081 }
13082
13083 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
13084         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
13085         LDKBestBlock best_block_arg_conv;
13086         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
13087         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
13088         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
13089         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
13090         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13091         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13092         uint64_t ret_ref = (uint64_t)ret_var.inner;
13093         if (ret_var.is_owned) {
13094                 ret_ref |= 1;
13095         }
13096         return ret_ref;
13097 }
13098
13099 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32_t orig) {
13100         LDKChainParameters orig_conv;
13101         orig_conv.inner = (void*)(orig & (~1));
13102         orig_conv.is_owned = false;
13103         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
13104         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13105         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13106         uint64_t ret_ref = (uint64_t)ret_var.inner;
13107         if (ret_var.is_owned) {
13108                 ret_ref |= 1;
13109         }
13110         return ret_ref;
13111 }
13112
13113 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
13114         LDKChannelCounterparty this_obj_conv;
13115         this_obj_conv.inner = (void*)(this_obj & (~1));
13116         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13117         ChannelCounterparty_free(this_obj_conv);
13118 }
13119
13120 int8_tArray  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
13121         LDKChannelCounterparty this_ptr_conv;
13122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13123         this_ptr_conv.is_owned = false;
13124         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13125         memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
13126         return ret_arr;
13127 }
13128
13129 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
13130         LDKChannelCounterparty this_ptr_conv;
13131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13132         this_ptr_conv.is_owned = false;
13133         LDKPublicKey val_ref;
13134         CHECK(*((uint32_t*)val) == 33);
13135         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13136         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
13137 }
13138
13139 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
13140         LDKChannelCounterparty this_ptr_conv;
13141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13142         this_ptr_conv.is_owned = false;
13143         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
13144         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13145         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13146         uint64_t ret_ref = (uint64_t)ret_var.inner;
13147         if (ret_var.is_owned) {
13148                 ret_ref |= 1;
13149         }
13150         return ret_ref;
13151 }
13152
13153 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
13154         LDKChannelCounterparty this_ptr_conv;
13155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13156         this_ptr_conv.is_owned = false;
13157         LDKInitFeatures val_conv;
13158         val_conv.inner = (void*)(val & (~1));
13159         val_conv.is_owned = (val & 1) || (val == 0);
13160         val_conv = InitFeatures_clone(&val_conv);
13161         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
13162 }
13163
13164 int64_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
13165         LDKChannelCounterparty this_ptr_conv;
13166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13167         this_ptr_conv.is_owned = false;
13168         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
13169         return ret_val;
13170 }
13171
13172 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
13173         LDKChannelCounterparty this_ptr_conv;
13174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13175         this_ptr_conv.is_owned = false;
13176         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
13177 }
13178
13179 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(uint32_t orig) {
13180         LDKChannelCounterparty orig_conv;
13181         orig_conv.inner = (void*)(orig & (~1));
13182         orig_conv.is_owned = false;
13183         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
13184         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13185         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13186         uint64_t ret_ref = (uint64_t)ret_var.inner;
13187         if (ret_var.is_owned) {
13188                 ret_ref |= 1;
13189         }
13190         return ret_ref;
13191 }
13192
13193 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
13194         LDKChannelDetails this_obj_conv;
13195         this_obj_conv.inner = (void*)(this_obj & (~1));
13196         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13197         ChannelDetails_free(this_obj_conv);
13198 }
13199
13200 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
13201         LDKChannelDetails this_ptr_conv;
13202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13203         this_ptr_conv.is_owned = false;
13204         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13205         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
13206         return ret_arr;
13207 }
13208
13209 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13210         LDKChannelDetails this_ptr_conv;
13211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13212         this_ptr_conv.is_owned = false;
13213         LDKThirtyTwoBytes val_ref;
13214         CHECK(*((uint32_t*)val) == 32);
13215         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13216         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
13217 }
13218
13219 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
13220         LDKChannelDetails this_ptr_conv;
13221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13222         this_ptr_conv.is_owned = false;
13223         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
13224         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13225         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13226         uint64_t ret_ref = (uint64_t)ret_var.inner;
13227         if (ret_var.is_owned) {
13228                 ret_ref |= 1;
13229         }
13230         return ret_ref;
13231 }
13232
13233 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
13234         LDKChannelDetails this_ptr_conv;
13235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13236         this_ptr_conv.is_owned = false;
13237         LDKChannelCounterparty val_conv;
13238         val_conv.inner = (void*)(val & (~1));
13239         val_conv.is_owned = (val & 1) || (val == 0);
13240         val_conv = ChannelCounterparty_clone(&val_conv);
13241         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
13242 }
13243
13244 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
13245         LDKChannelDetails this_ptr_conv;
13246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13247         this_ptr_conv.is_owned = false;
13248         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
13249         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13250         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13251         uint64_t ret_ref = (uint64_t)ret_var.inner;
13252         if (ret_var.is_owned) {
13253                 ret_ref |= 1;
13254         }
13255         return ret_ref;
13256 }
13257
13258 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
13259         LDKChannelDetails this_ptr_conv;
13260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13261         this_ptr_conv.is_owned = false;
13262         LDKOutPoint val_conv;
13263         val_conv.inner = (void*)(val & (~1));
13264         val_conv.is_owned = (val & 1) || (val == 0);
13265         val_conv = OutPoint_clone(&val_conv);
13266         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
13267 }
13268
13269 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
13270         LDKChannelDetails this_ptr_conv;
13271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13272         this_ptr_conv.is_owned = false;
13273         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
13274         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
13275         uint64_t ret_ref = (uint64_t)ret_copy;
13276         return ret_ref;
13277 }
13278
13279 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
13280         LDKChannelDetails this_ptr_conv;
13281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13282         this_ptr_conv.is_owned = false;
13283         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
13284         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
13285 }
13286
13287 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
13288         LDKChannelDetails this_ptr_conv;
13289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13290         this_ptr_conv.is_owned = false;
13291         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
13292         return ret_val;
13293 }
13294
13295 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
13296         LDKChannelDetails this_ptr_conv;
13297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13298         this_ptr_conv.is_owned = false;
13299         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
13300 }
13301
13302 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
13303         LDKChannelDetails this_ptr_conv;
13304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13305         this_ptr_conv.is_owned = false;
13306         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
13307         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
13308         uint64_t ret_ref = (uint64_t)ret_copy;
13309         return ret_ref;
13310 }
13311
13312 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
13313         LDKChannelDetails this_ptr_conv;
13314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13315         this_ptr_conv.is_owned = false;
13316         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
13317         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
13318 }
13319
13320 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
13321         LDKChannelDetails this_ptr_conv;
13322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13323         this_ptr_conv.is_owned = false;
13324         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
13325         return ret_val;
13326 }
13327
13328 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
13329         LDKChannelDetails this_ptr_conv;
13330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13331         this_ptr_conv.is_owned = false;
13332         ChannelDetails_set_user_id(&this_ptr_conv, val);
13333 }
13334
13335 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
13336         LDKChannelDetails this_ptr_conv;
13337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13338         this_ptr_conv.is_owned = false;
13339         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
13340         return ret_val;
13341 }
13342
13343 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
13344         LDKChannelDetails this_ptr_conv;
13345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13346         this_ptr_conv.is_owned = false;
13347         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
13348 }
13349
13350 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
13351         LDKChannelDetails this_ptr_conv;
13352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13353         this_ptr_conv.is_owned = false;
13354         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
13355         return ret_val;
13356 }
13357
13358 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
13359         LDKChannelDetails this_ptr_conv;
13360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13361         this_ptr_conv.is_owned = false;
13362         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
13363 }
13364
13365 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
13366         LDKChannelDetails this_ptr_conv;
13367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13368         this_ptr_conv.is_owned = false;
13369         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
13370         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
13371         uint64_t ret_ref = (uint64_t)ret_copy;
13372         return ret_ref;
13373 }
13374
13375 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
13376         LDKChannelDetails this_ptr_conv;
13377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13378         this_ptr_conv.is_owned = false;
13379         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
13380         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
13381 }
13382
13383 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
13384         LDKChannelDetails this_ptr_conv;
13385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13386         this_ptr_conv.is_owned = false;
13387         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13388         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
13389         uint64_t ret_ref = (uint64_t)ret_copy;
13390         return ret_ref;
13391 }
13392
13393 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_spend_delay(uint32_t this_ptr, uint32_t val) {
13394         LDKChannelDetails this_ptr_conv;
13395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13396         this_ptr_conv.is_owned = false;
13397         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
13398         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
13399 }
13400
13401 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
13402         LDKChannelDetails this_ptr_conv;
13403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13404         this_ptr_conv.is_owned = false;
13405         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
13406         return ret_val;
13407 }
13408
13409 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
13410         LDKChannelDetails this_ptr_conv;
13411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13412         this_ptr_conv.is_owned = false;
13413         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
13414 }
13415
13416 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
13417         LDKChannelDetails this_ptr_conv;
13418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13419         this_ptr_conv.is_owned = false;
13420         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
13421         return ret_val;
13422 }
13423
13424 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
13425         LDKChannelDetails this_ptr_conv;
13426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13427         this_ptr_conv.is_owned = false;
13428         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
13429 }
13430
13431 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
13432         LDKChannelDetails this_ptr_conv;
13433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13434         this_ptr_conv.is_owned = false;
13435         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
13436         return ret_val;
13437 }
13438
13439 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
13440         LDKChannelDetails this_ptr_conv;
13441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13442         this_ptr_conv.is_owned = false;
13443         ChannelDetails_set_is_usable(&this_ptr_conv, val);
13444 }
13445
13446 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
13447         LDKChannelDetails this_ptr_conv;
13448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13449         this_ptr_conv.is_owned = false;
13450         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
13451         return ret_val;
13452 }
13453
13454 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
13455         LDKChannelDetails this_ptr_conv;
13456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13457         this_ptr_conv.is_owned = false;
13458         ChannelDetails_set_is_public(&this_ptr_conv, val);
13459 }
13460
13461 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) {
13462         LDKThirtyTwoBytes channel_id_arg_ref;
13463         CHECK(*((uint32_t*)channel_id_arg) == 32);
13464         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13465         LDKChannelCounterparty counterparty_arg_conv;
13466         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
13467         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
13468         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
13469         LDKOutPoint funding_txo_arg_conv;
13470         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
13471         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
13472         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
13473         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
13474         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
13475         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
13476         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
13477         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);
13478         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13479         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13480         uint64_t ret_ref = (uint64_t)ret_var.inner;
13481         if (ret_var.is_owned) {
13482                 ret_ref |= 1;
13483         }
13484         return ret_ref;
13485 }
13486
13487 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
13488         LDKChannelDetails orig_conv;
13489         orig_conv.inner = (void*)(orig & (~1));
13490         orig_conv.is_owned = false;
13491         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
13492         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13493         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13494         uint64_t ret_ref = (uint64_t)ret_var.inner;
13495         if (ret_var.is_owned) {
13496                 ret_ref |= 1;
13497         }
13498         return ret_ref;
13499 }
13500
13501 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
13502         if ((this_ptr & 1) != 0) return;
13503         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
13504         FREE((void*)this_ptr);
13505         PaymentSendFailure_free(this_ptr_conv);
13506 }
13507
13508 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
13509         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
13510         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
13511         *ret_copy = PaymentSendFailure_clone(orig_conv);
13512         uint64_t ret_ref = (uint64_t)ret_copy;
13513         return ret_ref;
13514 }
13515
13516 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) {
13517         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
13518         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
13519         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
13520         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13521         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
13522         LDKUserConfig config_conv;
13523         config_conv.inner = (void*)(config & (~1));
13524         config_conv.is_owned = (config & 1) || (config == 0);
13525         config_conv = UserConfig_clone(&config_conv);
13526         LDKChainParameters params_conv;
13527         params_conv.inner = (void*)(params & (~1));
13528         params_conv.is_owned = (params & 1) || (params == 0);
13529         params_conv = ChainParameters_clone(&params_conv);
13530         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
13531         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13532         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13533         uint64_t ret_ref = (uint64_t)ret_var.inner;
13534         if (ret_var.is_owned) {
13535                 ret_ref |= 1;
13536         }
13537         return ret_ref;
13538 }
13539
13540 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
13541         LDKChannelManager this_arg_conv;
13542         this_arg_conv.inner = (void*)(this_arg & (~1));
13543         this_arg_conv.is_owned = false;
13544         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
13545         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13546         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13547         uint64_t ret_ref = (uint64_t)ret_var.inner;
13548         if (ret_var.is_owned) {
13549                 ret_ref |= 1;
13550         }
13551         return ret_ref;
13552 }
13553
13554 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) {
13555         LDKChannelManager this_arg_conv;
13556         this_arg_conv.inner = (void*)(this_arg & (~1));
13557         this_arg_conv.is_owned = false;
13558         LDKPublicKey their_network_key_ref;
13559         CHECK(*((uint32_t*)their_network_key) == 33);
13560         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
13561         LDKUserConfig override_config_conv;
13562         override_config_conv.inner = (void*)(override_config & (~1));
13563         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
13564         override_config_conv = UserConfig_clone(&override_config_conv);
13565         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13566         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
13567         return (uint64_t)ret_conv;
13568 }
13569
13570 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
13571         LDKChannelManager this_arg_conv;
13572         this_arg_conv.inner = (void*)(this_arg & (~1));
13573         this_arg_conv.is_owned = false;
13574         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
13575         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13576         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13577         for (size_t q = 0; q < ret_var.datalen; q++) {
13578                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13579                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13580                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13581                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
13582                 if (ret_conv_16_var.is_owned) {
13583                         ret_conv_16_ref |= 1;
13584                 }
13585                 ret_arr_ptr[q] = ret_conv_16_ref;
13586         }
13587         FREE(ret_var.data);
13588         return ret_arr;
13589 }
13590
13591 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
13592         LDKChannelManager this_arg_conv;
13593         this_arg_conv.inner = (void*)(this_arg & (~1));
13594         this_arg_conv.is_owned = false;
13595         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
13596         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13597         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13598         for (size_t q = 0; q < ret_var.datalen; q++) {
13599                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13600                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13601                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13602                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
13603                 if (ret_conv_16_var.is_owned) {
13604                         ret_conv_16_ref |= 1;
13605                 }
13606                 ret_arr_ptr[q] = ret_conv_16_ref;
13607         }
13608         FREE(ret_var.data);
13609         return ret_arr;
13610 }
13611
13612 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
13613         LDKChannelManager this_arg_conv;
13614         this_arg_conv.inner = (void*)(this_arg & (~1));
13615         this_arg_conv.is_owned = false;
13616         unsigned char channel_id_arr[32];
13617         CHECK(*((uint32_t*)channel_id) == 32);
13618         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
13619         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
13620         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13621         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
13622         return (uint64_t)ret_conv;
13623 }
13624
13625 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
13626         LDKChannelManager this_arg_conv;
13627         this_arg_conv.inner = (void*)(this_arg & (~1));
13628         this_arg_conv.is_owned = false;
13629         unsigned char channel_id_arr[32];
13630         CHECK(*((uint32_t*)channel_id) == 32);
13631         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
13632         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
13633         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13634         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
13635         return (uint64_t)ret_conv;
13636 }
13637
13638 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
13639         LDKChannelManager this_arg_conv;
13640         this_arg_conv.inner = (void*)(this_arg & (~1));
13641         this_arg_conv.is_owned = false;
13642         ChannelManager_force_close_all_channels(&this_arg_conv);
13643 }
13644
13645 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
13646         LDKChannelManager this_arg_conv;
13647         this_arg_conv.inner = (void*)(this_arg & (~1));
13648         this_arg_conv.is_owned = false;
13649         LDKRoute route_conv;
13650         route_conv.inner = (void*)(route & (~1));
13651         route_conv.is_owned = false;
13652         LDKThirtyTwoBytes payment_hash_ref;
13653         CHECK(*((uint32_t*)payment_hash) == 32);
13654         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
13655         LDKThirtyTwoBytes payment_secret_ref;
13656         CHECK(*((uint32_t*)payment_secret) == 32);
13657         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
13658         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13659         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
13660         return (uint64_t)ret_conv;
13661 }
13662
13663 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
13664         LDKChannelManager this_arg_conv;
13665         this_arg_conv.inner = (void*)(this_arg & (~1));
13666         this_arg_conv.is_owned = false;
13667         unsigned char temporary_channel_id_arr[32];
13668         CHECK(*((uint32_t*)temporary_channel_id) == 32);
13669         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
13670         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
13671         LDKTransaction funding_transaction_ref;
13672         funding_transaction_ref.datalen = *((uint32_t*)funding_transaction);
13673         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
13674         memcpy(funding_transaction_ref.data, (uint8_t*)(funding_transaction + 4), funding_transaction_ref.datalen);
13675         funding_transaction_ref.data_is_owned = true;
13676         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13677         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
13678         return (uint64_t)ret_conv;
13679 }
13680
13681 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
13682         LDKChannelManager this_arg_conv;
13683         this_arg_conv.inner = (void*)(this_arg & (~1));
13684         this_arg_conv.is_owned = false;
13685         LDKThreeBytes rgb_ref;
13686         CHECK(*((uint32_t*)rgb) == 3);
13687         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
13688         LDKThirtyTwoBytes alias_ref;
13689         CHECK(*((uint32_t*)alias) == 32);
13690         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
13691         LDKCVec_NetAddressZ addresses_constr;
13692         addresses_constr.datalen = *((uint32_t*)addresses);
13693         if (addresses_constr.datalen > 0)
13694                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13695         else
13696                 addresses_constr.data = NULL;
13697         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
13698         for (size_t m = 0; m < addresses_constr.datalen; m++) {
13699                 uint32_t addresses_conv_12 = addresses_vals[m];
13700                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
13701                 addresses_constr.data[m] = addresses_conv_12_conv;
13702         }
13703         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
13704 }
13705
13706 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
13707         LDKChannelManager this_arg_conv;
13708         this_arg_conv.inner = (void*)(this_arg & (~1));
13709         this_arg_conv.is_owned = false;
13710         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
13711 }
13712
13713 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
13714         LDKChannelManager this_arg_conv;
13715         this_arg_conv.inner = (void*)(this_arg & (~1));
13716         this_arg_conv.is_owned = false;
13717         ChannelManager_timer_tick_occurred(&this_arg_conv);
13718 }
13719
13720 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
13721         LDKChannelManager this_arg_conv;
13722         this_arg_conv.inner = (void*)(this_arg & (~1));
13723         this_arg_conv.is_owned = false;
13724         unsigned char payment_hash_arr[32];
13725         CHECK(*((uint32_t*)payment_hash) == 32);
13726         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
13727         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
13728         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
13729         return ret_val;
13730 }
13731
13732 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
13733         LDKChannelManager this_arg_conv;
13734         this_arg_conv.inner = (void*)(this_arg & (~1));
13735         this_arg_conv.is_owned = false;
13736         LDKThirtyTwoBytes payment_preimage_ref;
13737         CHECK(*((uint32_t*)payment_preimage) == 32);
13738         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
13739         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
13740         return ret_val;
13741 }
13742
13743 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
13744         LDKChannelManager this_arg_conv;
13745         this_arg_conv.inner = (void*)(this_arg & (~1));
13746         this_arg_conv.is_owned = false;
13747         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13748         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
13749         return ret_arr;
13750 }
13751
13752 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
13753         LDKChannelManager this_arg_conv;
13754         this_arg_conv.inner = (void*)(this_arg & (~1));
13755         this_arg_conv.is_owned = false;
13756         LDKOutPoint funding_txo_conv;
13757         funding_txo_conv.inner = (void*)(funding_txo & (~1));
13758         funding_txo_conv.is_owned = false;
13759         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
13760 }
13761
13762 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) {
13763         LDKChannelManager this_arg_conv;
13764         this_arg_conv.inner = (void*)(this_arg & (~1));
13765         this_arg_conv.is_owned = false;
13766         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
13767         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
13768         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
13769         return (uint64_t)ret_ref;
13770 }
13771
13772 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) {
13773         LDKChannelManager this_arg_conv;
13774         this_arg_conv.inner = (void*)(this_arg & (~1));
13775         this_arg_conv.is_owned = false;
13776         LDKThirtyTwoBytes payment_hash_ref;
13777         CHECK(*((uint32_t*)payment_hash) == 32);
13778         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
13779         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
13780         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
13781         *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);
13782         return (uint64_t)ret_conv;
13783 }
13784
13785 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
13786         LDKChannelManager this_arg_conv;
13787         this_arg_conv.inner = (void*)(this_arg & (~1));
13788         this_arg_conv.is_owned = false;
13789         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
13790         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
13791         return (uint64_t)ret;
13792 }
13793
13794 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
13795         LDKChannelManager this_arg_conv;
13796         this_arg_conv.inner = (void*)(this_arg & (~1));
13797         this_arg_conv.is_owned = false;
13798         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
13799         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
13800         return (uint64_t)ret;
13801 }
13802
13803 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
13804         LDKChannelManager this_arg_conv;
13805         this_arg_conv.inner = (void*)(this_arg & (~1));
13806         this_arg_conv.is_owned = false;
13807         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
13808         *ret = ChannelManager_as_Listen(&this_arg_conv);
13809         return (uint64_t)ret;
13810 }
13811
13812 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
13813         LDKChannelManager this_arg_conv;
13814         this_arg_conv.inner = (void*)(this_arg & (~1));
13815         this_arg_conv.is_owned = false;
13816         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
13817         *ret = ChannelManager_as_Confirm(&this_arg_conv);
13818         return (uint64_t)ret;
13819 }
13820
13821 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
13822         LDKChannelManager this_arg_conv;
13823         this_arg_conv.inner = (void*)(this_arg & (~1));
13824         this_arg_conv.is_owned = false;
13825         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
13826         return ret_val;
13827 }
13828
13829 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
13830         LDKChannelManager this_arg_conv;
13831         this_arg_conv.inner = (void*)(this_arg & (~1));
13832         this_arg_conv.is_owned = false;
13833         ChannelManager_await_persistable_update(&this_arg_conv);
13834 }
13835
13836 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
13837         LDKChannelManager this_arg_conv;
13838         this_arg_conv.inner = (void*)(this_arg & (~1));
13839         this_arg_conv.is_owned = false;
13840         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
13841         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13842         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13843         uint64_t ret_ref = (uint64_t)ret_var.inner;
13844         if (ret_var.is_owned) {
13845                 ret_ref |= 1;
13846         }
13847         return ret_ref;
13848 }
13849
13850 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
13851         LDKChannelManager this_arg_conv;
13852         this_arg_conv.inner = (void*)(this_arg & (~1));
13853         this_arg_conv.is_owned = false;
13854         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
13855         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
13856         return (uint64_t)ret;
13857 }
13858
13859 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
13860         LDKChannelManager obj_conv;
13861         obj_conv.inner = (void*)(obj & (~1));
13862         obj_conv.is_owned = false;
13863         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
13864         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13865         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13866         CVec_u8Z_free(ret_var);
13867         return ret_arr;
13868 }
13869
13870 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
13871         LDKChannelManagerReadArgs this_obj_conv;
13872         this_obj_conv.inner = (void*)(this_obj & (~1));
13873         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13874         ChannelManagerReadArgs_free(this_obj_conv);
13875 }
13876
13877 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
13878         LDKChannelManagerReadArgs this_ptr_conv;
13879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13880         this_ptr_conv.is_owned = false;
13881         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
13882         return ret_ret;
13883 }
13884
13885 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
13886         LDKChannelManagerReadArgs this_ptr_conv;
13887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13888         this_ptr_conv.is_owned = false;
13889         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
13890         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
13891 }
13892
13893 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
13894         LDKChannelManagerReadArgs this_ptr_conv;
13895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13896         this_ptr_conv.is_owned = false;
13897         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
13898         return ret_ret;
13899 }
13900
13901 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
13902         LDKChannelManagerReadArgs this_ptr_conv;
13903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13904         this_ptr_conv.is_owned = false;
13905         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
13906         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
13907 }
13908
13909 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
13910         LDKChannelManagerReadArgs this_ptr_conv;
13911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13912         this_ptr_conv.is_owned = false;
13913         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
13914         return ret_ret;
13915 }
13916
13917 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
13918         LDKChannelManagerReadArgs this_ptr_conv;
13919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13920         this_ptr_conv.is_owned = false;
13921         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
13922         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
13923 }
13924
13925 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
13926         LDKChannelManagerReadArgs this_ptr_conv;
13927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13928         this_ptr_conv.is_owned = false;
13929         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
13930         return ret_ret;
13931 }
13932
13933 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
13934         LDKChannelManagerReadArgs this_ptr_conv;
13935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13936         this_ptr_conv.is_owned = false;
13937         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
13938         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
13939 }
13940
13941 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
13942         LDKChannelManagerReadArgs this_ptr_conv;
13943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13944         this_ptr_conv.is_owned = false;
13945         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
13946         return ret_ret;
13947 }
13948
13949 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
13950         LDKChannelManagerReadArgs this_ptr_conv;
13951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13952         this_ptr_conv.is_owned = false;
13953         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
13954         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
13955 }
13956
13957 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
13958         LDKChannelManagerReadArgs this_ptr_conv;
13959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13960         this_ptr_conv.is_owned = false;
13961         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
13962         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13963         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13964         uint64_t ret_ref = (uint64_t)ret_var.inner;
13965         if (ret_var.is_owned) {
13966                 ret_ref |= 1;
13967         }
13968         return ret_ref;
13969 }
13970
13971 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
13972         LDKChannelManagerReadArgs this_ptr_conv;
13973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13974         this_ptr_conv.is_owned = false;
13975         LDKUserConfig val_conv;
13976         val_conv.inner = (void*)(val & (~1));
13977         val_conv.is_owned = (val & 1) || (val == 0);
13978         val_conv = UserConfig_clone(&val_conv);
13979         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
13980 }
13981
13982 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) {
13983         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
13984         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13985         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
13986         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
13987         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13988         LDKUserConfig default_config_conv;
13989         default_config_conv.inner = (void*)(default_config & (~1));
13990         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
13991         default_config_conv = UserConfig_clone(&default_config_conv);
13992         LDKCVec_ChannelMonitorZ channel_monitors_constr;
13993         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
13994         if (channel_monitors_constr.datalen > 0)
13995                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
13996         else
13997                 channel_monitors_constr.data = NULL;
13998         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
13999         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
14000                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
14001                 LDKChannelMonitor channel_monitors_conv_16_conv;
14002                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
14003                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
14004                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
14005         }
14006         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);
14007         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14008         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14009         uint64_t ret_ref = (uint64_t)ret_var.inner;
14010         if (ret_var.is_owned) {
14011                 ret_ref |= 1;
14012         }
14013         return ret_ref;
14014 }
14015
14016 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
14017         LDKu8slice ser_ref;
14018         ser_ref.datalen = *((uint32_t*)ser);
14019         ser_ref.data = (int8_t*)(ser + 4);
14020         LDKChannelManagerReadArgs arg_conv;
14021         arg_conv.inner = (void*)(arg & (~1));
14022         arg_conv.is_owned = (arg & 1) || (arg == 0);
14023         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
14024         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14025         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
14026         return (uint64_t)ret_conv;
14027 }
14028
14029 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
14030         LDKDecodeError this_obj_conv;
14031         this_obj_conv.inner = (void*)(this_obj & (~1));
14032         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14033         DecodeError_free(this_obj_conv);
14034 }
14035
14036 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
14037         LDKDecodeError orig_conv;
14038         orig_conv.inner = (void*)(orig & (~1));
14039         orig_conv.is_owned = false;
14040         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
14041         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14042         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14043         uint64_t ret_ref = (uint64_t)ret_var.inner;
14044         if (ret_var.is_owned) {
14045                 ret_ref |= 1;
14046         }
14047         return ret_ref;
14048 }
14049
14050 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
14051         LDKInit this_obj_conv;
14052         this_obj_conv.inner = (void*)(this_obj & (~1));
14053         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14054         Init_free(this_obj_conv);
14055 }
14056
14057 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
14058         LDKInit this_ptr_conv;
14059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14060         this_ptr_conv.is_owned = false;
14061         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
14062         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14063         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14064         uint64_t ret_ref = (uint64_t)ret_var.inner;
14065         if (ret_var.is_owned) {
14066                 ret_ref |= 1;
14067         }
14068         return ret_ref;
14069 }
14070
14071 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
14072         LDKInit this_ptr_conv;
14073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14074         this_ptr_conv.is_owned = false;
14075         LDKInitFeatures val_conv;
14076         val_conv.inner = (void*)(val & (~1));
14077         val_conv.is_owned = (val & 1) || (val == 0);
14078         val_conv = InitFeatures_clone(&val_conv);
14079         Init_set_features(&this_ptr_conv, val_conv);
14080 }
14081
14082 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
14083         LDKInitFeatures features_arg_conv;
14084         features_arg_conv.inner = (void*)(features_arg & (~1));
14085         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
14086         features_arg_conv = InitFeatures_clone(&features_arg_conv);
14087         LDKInit ret_var = Init_new(features_arg_conv);
14088         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14089         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14090         uint64_t ret_ref = (uint64_t)ret_var.inner;
14091         if (ret_var.is_owned) {
14092                 ret_ref |= 1;
14093         }
14094         return ret_ref;
14095 }
14096
14097 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
14098         LDKInit orig_conv;
14099         orig_conv.inner = (void*)(orig & (~1));
14100         orig_conv.is_owned = false;
14101         LDKInit ret_var = Init_clone(&orig_conv);
14102         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14103         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14104         uint64_t ret_ref = (uint64_t)ret_var.inner;
14105         if (ret_var.is_owned) {
14106                 ret_ref |= 1;
14107         }
14108         return ret_ref;
14109 }
14110
14111 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
14112         LDKErrorMessage this_obj_conv;
14113         this_obj_conv.inner = (void*)(this_obj & (~1));
14114         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14115         ErrorMessage_free(this_obj_conv);
14116 }
14117
14118 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
14119         LDKErrorMessage this_ptr_conv;
14120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14121         this_ptr_conv.is_owned = false;
14122         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14123         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
14124         return ret_arr;
14125 }
14126
14127 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14128         LDKErrorMessage this_ptr_conv;
14129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14130         this_ptr_conv.is_owned = false;
14131         LDKThirtyTwoBytes val_ref;
14132         CHECK(*((uint32_t*)val) == 32);
14133         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14134         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
14135 }
14136
14137 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
14138         LDKErrorMessage this_ptr_conv;
14139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14140         this_ptr_conv.is_owned = false;
14141         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
14142         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
14143         return ret_conv;
14144 }
14145
14146 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
14147         LDKErrorMessage this_ptr_conv;
14148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14149         this_ptr_conv.is_owned = false;
14150         LDKStr val_conv = str_ref_to_owned_c(val);
14151         ErrorMessage_set_data(&this_ptr_conv, val_conv);
14152 }
14153
14154 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
14155         LDKThirtyTwoBytes channel_id_arg_ref;
14156         CHECK(*((uint32_t*)channel_id_arg) == 32);
14157         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
14158         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
14159         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
14160         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14161         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14162         uint64_t ret_ref = (uint64_t)ret_var.inner;
14163         if (ret_var.is_owned) {
14164                 ret_ref |= 1;
14165         }
14166         return ret_ref;
14167 }
14168
14169 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
14170         LDKErrorMessage orig_conv;
14171         orig_conv.inner = (void*)(orig & (~1));
14172         orig_conv.is_owned = false;
14173         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
14174         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14175         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14176         uint64_t ret_ref = (uint64_t)ret_var.inner;
14177         if (ret_var.is_owned) {
14178                 ret_ref |= 1;
14179         }
14180         return ret_ref;
14181 }
14182
14183 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
14184         LDKPing this_obj_conv;
14185         this_obj_conv.inner = (void*)(this_obj & (~1));
14186         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14187         Ping_free(this_obj_conv);
14188 }
14189
14190 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
14191         LDKPing this_ptr_conv;
14192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14193         this_ptr_conv.is_owned = false;
14194         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
14195         return ret_val;
14196 }
14197
14198 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
14199         LDKPing this_ptr_conv;
14200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14201         this_ptr_conv.is_owned = false;
14202         Ping_set_ponglen(&this_ptr_conv, val);
14203 }
14204
14205 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
14206         LDKPing this_ptr_conv;
14207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14208         this_ptr_conv.is_owned = false;
14209         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
14210         return ret_val;
14211 }
14212
14213 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
14214         LDKPing this_ptr_conv;
14215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14216         this_ptr_conv.is_owned = false;
14217         Ping_set_byteslen(&this_ptr_conv, val);
14218 }
14219
14220 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
14221         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
14222         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14223         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14224         uint64_t ret_ref = (uint64_t)ret_var.inner;
14225         if (ret_var.is_owned) {
14226                 ret_ref |= 1;
14227         }
14228         return ret_ref;
14229 }
14230
14231 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
14232         LDKPing orig_conv;
14233         orig_conv.inner = (void*)(orig & (~1));
14234         orig_conv.is_owned = false;
14235         LDKPing ret_var = Ping_clone(&orig_conv);
14236         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14237         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14238         uint64_t ret_ref = (uint64_t)ret_var.inner;
14239         if (ret_var.is_owned) {
14240                 ret_ref |= 1;
14241         }
14242         return ret_ref;
14243 }
14244
14245 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
14246         LDKPong this_obj_conv;
14247         this_obj_conv.inner = (void*)(this_obj & (~1));
14248         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14249         Pong_free(this_obj_conv);
14250 }
14251
14252 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
14253         LDKPong this_ptr_conv;
14254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14255         this_ptr_conv.is_owned = false;
14256         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
14257         return ret_val;
14258 }
14259
14260 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
14261         LDKPong this_ptr_conv;
14262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14263         this_ptr_conv.is_owned = false;
14264         Pong_set_byteslen(&this_ptr_conv, val);
14265 }
14266
14267 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
14268         LDKPong ret_var = Pong_new(byteslen_arg);
14269         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14270         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14271         uint64_t ret_ref = (uint64_t)ret_var.inner;
14272         if (ret_var.is_owned) {
14273                 ret_ref |= 1;
14274         }
14275         return ret_ref;
14276 }
14277
14278 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
14279         LDKPong orig_conv;
14280         orig_conv.inner = (void*)(orig & (~1));
14281         orig_conv.is_owned = false;
14282         LDKPong ret_var = Pong_clone(&orig_conv);
14283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14285         uint64_t ret_ref = (uint64_t)ret_var.inner;
14286         if (ret_var.is_owned) {
14287                 ret_ref |= 1;
14288         }
14289         return ret_ref;
14290 }
14291
14292 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
14293         LDKOpenChannel this_obj_conv;
14294         this_obj_conv.inner = (void*)(this_obj & (~1));
14295         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14296         OpenChannel_free(this_obj_conv);
14297 }
14298
14299 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
14300         LDKOpenChannel this_ptr_conv;
14301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14302         this_ptr_conv.is_owned = false;
14303         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14304         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
14305         return ret_arr;
14306 }
14307
14308 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14309         LDKOpenChannel this_ptr_conv;
14310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14311         this_ptr_conv.is_owned = false;
14312         LDKThirtyTwoBytes val_ref;
14313         CHECK(*((uint32_t*)val) == 32);
14314         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14315         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
14316 }
14317
14318 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
14319         LDKOpenChannel this_ptr_conv;
14320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14321         this_ptr_conv.is_owned = false;
14322         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14323         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
14324         return ret_arr;
14325 }
14326
14327 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
14328         LDKOpenChannel this_ptr_conv;
14329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14330         this_ptr_conv.is_owned = false;
14331         LDKThirtyTwoBytes val_ref;
14332         CHECK(*((uint32_t*)val) == 32);
14333         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14334         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
14335 }
14336
14337 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
14338         LDKOpenChannel this_ptr_conv;
14339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14340         this_ptr_conv.is_owned = false;
14341         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
14342         return ret_val;
14343 }
14344
14345 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
14346         LDKOpenChannel this_ptr_conv;
14347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14348         this_ptr_conv.is_owned = false;
14349         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
14350 }
14351
14352 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
14353         LDKOpenChannel this_ptr_conv;
14354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14355         this_ptr_conv.is_owned = false;
14356         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
14357         return ret_val;
14358 }
14359
14360 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
14361         LDKOpenChannel this_ptr_conv;
14362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14363         this_ptr_conv.is_owned = false;
14364         OpenChannel_set_push_msat(&this_ptr_conv, val);
14365 }
14366
14367 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
14368         LDKOpenChannel this_ptr_conv;
14369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14370         this_ptr_conv.is_owned = false;
14371         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
14372         return ret_val;
14373 }
14374
14375 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
14376         LDKOpenChannel this_ptr_conv;
14377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14378         this_ptr_conv.is_owned = false;
14379         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
14380 }
14381
14382 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
14383         LDKOpenChannel this_ptr_conv;
14384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14385         this_ptr_conv.is_owned = false;
14386         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
14387         return ret_val;
14388 }
14389
14390 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
14391         LDKOpenChannel this_ptr_conv;
14392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14393         this_ptr_conv.is_owned = false;
14394         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14395 }
14396
14397 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
14398         LDKOpenChannel this_ptr_conv;
14399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14400         this_ptr_conv.is_owned = false;
14401         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
14402         return ret_val;
14403 }
14404
14405 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
14406         LDKOpenChannel this_ptr_conv;
14407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14408         this_ptr_conv.is_owned = false;
14409         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
14410 }
14411
14412 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
14413         LDKOpenChannel this_ptr_conv;
14414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14415         this_ptr_conv.is_owned = false;
14416         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
14417         return ret_val;
14418 }
14419
14420 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14421         LDKOpenChannel this_ptr_conv;
14422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14423         this_ptr_conv.is_owned = false;
14424         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
14425 }
14426
14427 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
14428         LDKOpenChannel this_ptr_conv;
14429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14430         this_ptr_conv.is_owned = false;
14431         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
14432         return ret_val;
14433 }
14434
14435 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
14436         LDKOpenChannel this_ptr_conv;
14437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14438         this_ptr_conv.is_owned = false;
14439         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
14440 }
14441
14442 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
14443         LDKOpenChannel this_ptr_conv;
14444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14445         this_ptr_conv.is_owned = false;
14446         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
14447         return ret_val;
14448 }
14449
14450 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
14451         LDKOpenChannel this_ptr_conv;
14452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14453         this_ptr_conv.is_owned = false;
14454         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
14455 }
14456
14457 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
14458         LDKOpenChannel this_ptr_conv;
14459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14460         this_ptr_conv.is_owned = false;
14461         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
14462         return ret_val;
14463 }
14464
14465 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
14466         LDKOpenChannel this_ptr_conv;
14467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14468         this_ptr_conv.is_owned = false;
14469         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
14470 }
14471
14472 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
14473         LDKOpenChannel this_ptr_conv;
14474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14475         this_ptr_conv.is_owned = false;
14476         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14477         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
14478         return ret_arr;
14479 }
14480
14481 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
14482         LDKOpenChannel this_ptr_conv;
14483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14484         this_ptr_conv.is_owned = false;
14485         LDKPublicKey val_ref;
14486         CHECK(*((uint32_t*)val) == 33);
14487         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14488         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
14489 }
14490
14491 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
14492         LDKOpenChannel this_ptr_conv;
14493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14494         this_ptr_conv.is_owned = false;
14495         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14496         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
14497         return ret_arr;
14498 }
14499
14500 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
14501         LDKOpenChannel this_ptr_conv;
14502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14503         this_ptr_conv.is_owned = false;
14504         LDKPublicKey val_ref;
14505         CHECK(*((uint32_t*)val) == 33);
14506         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14507         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
14508 }
14509
14510 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
14511         LDKOpenChannel this_ptr_conv;
14512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14513         this_ptr_conv.is_owned = false;
14514         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14515         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
14516         return ret_arr;
14517 }
14518
14519 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
14520         LDKOpenChannel this_ptr_conv;
14521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14522         this_ptr_conv.is_owned = false;
14523         LDKPublicKey val_ref;
14524         CHECK(*((uint32_t*)val) == 33);
14525         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14526         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
14527 }
14528
14529 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
14530         LDKOpenChannel this_ptr_conv;
14531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14532         this_ptr_conv.is_owned = false;
14533         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14534         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
14535         return ret_arr;
14536 }
14537
14538 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
14539         LDKOpenChannel this_ptr_conv;
14540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14541         this_ptr_conv.is_owned = false;
14542         LDKPublicKey val_ref;
14543         CHECK(*((uint32_t*)val) == 33);
14544         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14545         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
14546 }
14547
14548 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
14549         LDKOpenChannel this_ptr_conv;
14550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14551         this_ptr_conv.is_owned = false;
14552         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14553         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
14554         return ret_arr;
14555 }
14556
14557 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
14558         LDKOpenChannel this_ptr_conv;
14559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14560         this_ptr_conv.is_owned = false;
14561         LDKPublicKey val_ref;
14562         CHECK(*((uint32_t*)val) == 33);
14563         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14564         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
14565 }
14566
14567 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
14568         LDKOpenChannel this_ptr_conv;
14569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14570         this_ptr_conv.is_owned = false;
14571         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14572         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14573         return ret_arr;
14574 }
14575
14576 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14577         LDKOpenChannel this_ptr_conv;
14578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14579         this_ptr_conv.is_owned = false;
14580         LDKPublicKey val_ref;
14581         CHECK(*((uint32_t*)val) == 33);
14582         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14583         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
14584 }
14585
14586 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
14587         LDKOpenChannel this_ptr_conv;
14588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14589         this_ptr_conv.is_owned = false;
14590         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
14591         return ret_val;
14592 }
14593
14594 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
14595         LDKOpenChannel this_ptr_conv;
14596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14597         this_ptr_conv.is_owned = false;
14598         OpenChannel_set_channel_flags(&this_ptr_conv, val);
14599 }
14600
14601 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
14602         LDKOpenChannel orig_conv;
14603         orig_conv.inner = (void*)(orig & (~1));
14604         orig_conv.is_owned = false;
14605         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
14606         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14607         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14608         uint64_t ret_ref = (uint64_t)ret_var.inner;
14609         if (ret_var.is_owned) {
14610                 ret_ref |= 1;
14611         }
14612         return ret_ref;
14613 }
14614
14615 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
14616         LDKAcceptChannel this_obj_conv;
14617         this_obj_conv.inner = (void*)(this_obj & (~1));
14618         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14619         AcceptChannel_free(this_obj_conv);
14620 }
14621
14622 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
14623         LDKAcceptChannel this_ptr_conv;
14624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14625         this_ptr_conv.is_owned = false;
14626         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14627         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
14628         return ret_arr;
14629 }
14630
14631 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
14632         LDKAcceptChannel this_ptr_conv;
14633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14634         this_ptr_conv.is_owned = false;
14635         LDKThirtyTwoBytes val_ref;
14636         CHECK(*((uint32_t*)val) == 32);
14637         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14638         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
14639 }
14640
14641 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
14642         LDKAcceptChannel this_ptr_conv;
14643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14644         this_ptr_conv.is_owned = false;
14645         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
14646         return ret_val;
14647 }
14648
14649 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
14650         LDKAcceptChannel this_ptr_conv;
14651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14652         this_ptr_conv.is_owned = false;
14653         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
14654 }
14655
14656 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
14657         LDKAcceptChannel this_ptr_conv;
14658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14659         this_ptr_conv.is_owned = false;
14660         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
14661         return ret_val;
14662 }
14663
14664 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
14665         LDKAcceptChannel this_ptr_conv;
14666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14667         this_ptr_conv.is_owned = false;
14668         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14669 }
14670
14671 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
14672         LDKAcceptChannel this_ptr_conv;
14673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14674         this_ptr_conv.is_owned = false;
14675         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
14676         return ret_val;
14677 }
14678
14679 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
14680         LDKAcceptChannel this_ptr_conv;
14681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14682         this_ptr_conv.is_owned = false;
14683         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
14684 }
14685
14686 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
14687         LDKAcceptChannel this_ptr_conv;
14688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14689         this_ptr_conv.is_owned = false;
14690         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
14691         return ret_val;
14692 }
14693
14694 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14695         LDKAcceptChannel this_ptr_conv;
14696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14697         this_ptr_conv.is_owned = false;
14698         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
14699 }
14700
14701 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
14702         LDKAcceptChannel this_ptr_conv;
14703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14704         this_ptr_conv.is_owned = false;
14705         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
14706         return ret_val;
14707 }
14708
14709 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
14710         LDKAcceptChannel this_ptr_conv;
14711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14712         this_ptr_conv.is_owned = false;
14713         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
14714 }
14715
14716 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
14717         LDKAcceptChannel this_ptr_conv;
14718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14719         this_ptr_conv.is_owned = false;
14720         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
14721         return ret_val;
14722 }
14723
14724 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
14725         LDKAcceptChannel this_ptr_conv;
14726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14727         this_ptr_conv.is_owned = false;
14728         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
14729 }
14730
14731 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
14732         LDKAcceptChannel this_ptr_conv;
14733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14734         this_ptr_conv.is_owned = false;
14735         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
14736         return ret_val;
14737 }
14738
14739 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
14740         LDKAcceptChannel this_ptr_conv;
14741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14742         this_ptr_conv.is_owned = false;
14743         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
14744 }
14745
14746 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
14747         LDKAcceptChannel this_ptr_conv;
14748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14749         this_ptr_conv.is_owned = false;
14750         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14751         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
14752         return ret_arr;
14753 }
14754
14755 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
14756         LDKAcceptChannel this_ptr_conv;
14757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14758         this_ptr_conv.is_owned = false;
14759         LDKPublicKey val_ref;
14760         CHECK(*((uint32_t*)val) == 33);
14761         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14762         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
14763 }
14764
14765 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
14766         LDKAcceptChannel this_ptr_conv;
14767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14768         this_ptr_conv.is_owned = false;
14769         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14770         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
14771         return ret_arr;
14772 }
14773
14774 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
14775         LDKAcceptChannel this_ptr_conv;
14776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14777         this_ptr_conv.is_owned = false;
14778         LDKPublicKey val_ref;
14779         CHECK(*((uint32_t*)val) == 33);
14780         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14781         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
14782 }
14783
14784 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
14785         LDKAcceptChannel this_ptr_conv;
14786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14787         this_ptr_conv.is_owned = false;
14788         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14789         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
14790         return ret_arr;
14791 }
14792
14793 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
14794         LDKAcceptChannel this_ptr_conv;
14795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14796         this_ptr_conv.is_owned = false;
14797         LDKPublicKey val_ref;
14798         CHECK(*((uint32_t*)val) == 33);
14799         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14800         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
14801 }
14802
14803 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
14804         LDKAcceptChannel this_ptr_conv;
14805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14806         this_ptr_conv.is_owned = false;
14807         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14808         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
14809         return ret_arr;
14810 }
14811
14812 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
14813         LDKAcceptChannel this_ptr_conv;
14814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14815         this_ptr_conv.is_owned = false;
14816         LDKPublicKey val_ref;
14817         CHECK(*((uint32_t*)val) == 33);
14818         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14819         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
14820 }
14821
14822 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
14823         LDKAcceptChannel this_ptr_conv;
14824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14825         this_ptr_conv.is_owned = false;
14826         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14827         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
14828         return ret_arr;
14829 }
14830
14831 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
14832         LDKAcceptChannel this_ptr_conv;
14833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14834         this_ptr_conv.is_owned = false;
14835         LDKPublicKey val_ref;
14836         CHECK(*((uint32_t*)val) == 33);
14837         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14838         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
14839 }
14840
14841 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
14842         LDKAcceptChannel this_ptr_conv;
14843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14844         this_ptr_conv.is_owned = false;
14845         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14846         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14847         return ret_arr;
14848 }
14849
14850 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14851         LDKAcceptChannel this_ptr_conv;
14852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14853         this_ptr_conv.is_owned = false;
14854         LDKPublicKey val_ref;
14855         CHECK(*((uint32_t*)val) == 33);
14856         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14857         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
14858 }
14859
14860 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
14861         LDKAcceptChannel orig_conv;
14862         orig_conv.inner = (void*)(orig & (~1));
14863         orig_conv.is_owned = false;
14864         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
14865         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14866         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14867         uint64_t ret_ref = (uint64_t)ret_var.inner;
14868         if (ret_var.is_owned) {
14869                 ret_ref |= 1;
14870         }
14871         return ret_ref;
14872 }
14873
14874 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
14875         LDKFundingCreated this_obj_conv;
14876         this_obj_conv.inner = (void*)(this_obj & (~1));
14877         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14878         FundingCreated_free(this_obj_conv);
14879 }
14880
14881 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
14882         LDKFundingCreated this_ptr_conv;
14883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14884         this_ptr_conv.is_owned = false;
14885         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14886         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
14887         return ret_arr;
14888 }
14889
14890 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
14891         LDKFundingCreated this_ptr_conv;
14892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14893         this_ptr_conv.is_owned = false;
14894         LDKThirtyTwoBytes val_ref;
14895         CHECK(*((uint32_t*)val) == 32);
14896         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14897         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
14898 }
14899
14900 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
14901         LDKFundingCreated this_ptr_conv;
14902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14903         this_ptr_conv.is_owned = false;
14904         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14905         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
14906         return ret_arr;
14907 }
14908
14909 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
14910         LDKFundingCreated this_ptr_conv;
14911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14912         this_ptr_conv.is_owned = false;
14913         LDKThirtyTwoBytes val_ref;
14914         CHECK(*((uint32_t*)val) == 32);
14915         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14916         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
14917 }
14918
14919 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
14920         LDKFundingCreated this_ptr_conv;
14921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14922         this_ptr_conv.is_owned = false;
14923         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
14924         return ret_val;
14925 }
14926
14927 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
14928         LDKFundingCreated this_ptr_conv;
14929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14930         this_ptr_conv.is_owned = false;
14931         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
14932 }
14933
14934 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
14935         LDKFundingCreated this_ptr_conv;
14936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14937         this_ptr_conv.is_owned = false;
14938         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14939         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
14940         return ret_arr;
14941 }
14942
14943 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
14944         LDKFundingCreated this_ptr_conv;
14945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14946         this_ptr_conv.is_owned = false;
14947         LDKSignature val_ref;
14948         CHECK(*((uint32_t*)val) == 64);
14949         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14950         FundingCreated_set_signature(&this_ptr_conv, val_ref);
14951 }
14952
14953 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) {
14954         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
14955         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
14956         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
14957         LDKThirtyTwoBytes funding_txid_arg_ref;
14958         CHECK(*((uint32_t*)funding_txid_arg) == 32);
14959         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
14960         LDKSignature signature_arg_ref;
14961         CHECK(*((uint32_t*)signature_arg) == 64);
14962         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
14963         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
14964         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14965         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14966         uint64_t ret_ref = (uint64_t)ret_var.inner;
14967         if (ret_var.is_owned) {
14968                 ret_ref |= 1;
14969         }
14970         return ret_ref;
14971 }
14972
14973 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
14974         LDKFundingCreated orig_conv;
14975         orig_conv.inner = (void*)(orig & (~1));
14976         orig_conv.is_owned = false;
14977         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
14978         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14979         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14980         uint64_t ret_ref = (uint64_t)ret_var.inner;
14981         if (ret_var.is_owned) {
14982                 ret_ref |= 1;
14983         }
14984         return ret_ref;
14985 }
14986
14987 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
14988         LDKFundingSigned this_obj_conv;
14989         this_obj_conv.inner = (void*)(this_obj & (~1));
14990         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14991         FundingSigned_free(this_obj_conv);
14992 }
14993
14994 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
14995         LDKFundingSigned this_ptr_conv;
14996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14997         this_ptr_conv.is_owned = false;
14998         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14999         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
15000         return ret_arr;
15001 }
15002
15003 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15004         LDKFundingSigned this_ptr_conv;
15005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15006         this_ptr_conv.is_owned = false;
15007         LDKThirtyTwoBytes val_ref;
15008         CHECK(*((uint32_t*)val) == 32);
15009         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15010         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
15011 }
15012
15013 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
15014         LDKFundingSigned this_ptr_conv;
15015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15016         this_ptr_conv.is_owned = false;
15017         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15018         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
15019         return ret_arr;
15020 }
15021
15022 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
15023         LDKFundingSigned this_ptr_conv;
15024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15025         this_ptr_conv.is_owned = false;
15026         LDKSignature val_ref;
15027         CHECK(*((uint32_t*)val) == 64);
15028         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15029         FundingSigned_set_signature(&this_ptr_conv, val_ref);
15030 }
15031
15032 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
15033         LDKThirtyTwoBytes channel_id_arg_ref;
15034         CHECK(*((uint32_t*)channel_id_arg) == 32);
15035         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15036         LDKSignature signature_arg_ref;
15037         CHECK(*((uint32_t*)signature_arg) == 64);
15038         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15039         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
15040         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15041         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15042         uint64_t ret_ref = (uint64_t)ret_var.inner;
15043         if (ret_var.is_owned) {
15044                 ret_ref |= 1;
15045         }
15046         return ret_ref;
15047 }
15048
15049 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
15050         LDKFundingSigned orig_conv;
15051         orig_conv.inner = (void*)(orig & (~1));
15052         orig_conv.is_owned = false;
15053         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
15054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15056         uint64_t ret_ref = (uint64_t)ret_var.inner;
15057         if (ret_var.is_owned) {
15058                 ret_ref |= 1;
15059         }
15060         return ret_ref;
15061 }
15062
15063 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
15064         LDKFundingLocked this_obj_conv;
15065         this_obj_conv.inner = (void*)(this_obj & (~1));
15066         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15067         FundingLocked_free(this_obj_conv);
15068 }
15069
15070 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
15071         LDKFundingLocked this_ptr_conv;
15072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15073         this_ptr_conv.is_owned = false;
15074         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15075         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
15076         return ret_arr;
15077 }
15078
15079 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15080         LDKFundingLocked this_ptr_conv;
15081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15082         this_ptr_conv.is_owned = false;
15083         LDKThirtyTwoBytes val_ref;
15084         CHECK(*((uint32_t*)val) == 32);
15085         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15086         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
15087 }
15088
15089 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
15090         LDKFundingLocked this_ptr_conv;
15091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15092         this_ptr_conv.is_owned = false;
15093         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15094         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
15095         return ret_arr;
15096 }
15097
15098 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
15099         LDKFundingLocked this_ptr_conv;
15100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15101         this_ptr_conv.is_owned = false;
15102         LDKPublicKey val_ref;
15103         CHECK(*((uint32_t*)val) == 33);
15104         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15105         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
15106 }
15107
15108 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
15109         LDKThirtyTwoBytes channel_id_arg_ref;
15110         CHECK(*((uint32_t*)channel_id_arg) == 32);
15111         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15112         LDKPublicKey next_per_commitment_point_arg_ref;
15113         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
15114         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
15115         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
15116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15118         uint64_t ret_ref = (uint64_t)ret_var.inner;
15119         if (ret_var.is_owned) {
15120                 ret_ref |= 1;
15121         }
15122         return ret_ref;
15123 }
15124
15125 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
15126         LDKFundingLocked orig_conv;
15127         orig_conv.inner = (void*)(orig & (~1));
15128         orig_conv.is_owned = false;
15129         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
15130         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15131         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15132         uint64_t ret_ref = (uint64_t)ret_var.inner;
15133         if (ret_var.is_owned) {
15134                 ret_ref |= 1;
15135         }
15136         return ret_ref;
15137 }
15138
15139 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
15140         LDKShutdown this_obj_conv;
15141         this_obj_conv.inner = (void*)(this_obj & (~1));
15142         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15143         Shutdown_free(this_obj_conv);
15144 }
15145
15146 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
15147         LDKShutdown this_ptr_conv;
15148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15149         this_ptr_conv.is_owned = false;
15150         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15151         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
15152         return ret_arr;
15153 }
15154
15155 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15156         LDKShutdown this_ptr_conv;
15157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15158         this_ptr_conv.is_owned = false;
15159         LDKThirtyTwoBytes val_ref;
15160         CHECK(*((uint32_t*)val) == 32);
15161         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15162         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
15163 }
15164
15165 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
15166         LDKShutdown this_ptr_conv;
15167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15168         this_ptr_conv.is_owned = false;
15169         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
15170         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15171         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15172         return ret_arr;
15173 }
15174
15175 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
15176         LDKShutdown this_ptr_conv;
15177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15178         this_ptr_conv.is_owned = false;
15179         LDKCVec_u8Z val_ref;
15180         val_ref.datalen = *((uint32_t*)val);
15181         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
15182         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
15183         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
15184 }
15185
15186 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
15187         LDKThirtyTwoBytes channel_id_arg_ref;
15188         CHECK(*((uint32_t*)channel_id_arg) == 32);
15189         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15190         LDKCVec_u8Z scriptpubkey_arg_ref;
15191         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
15192         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
15193         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
15194         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
15195         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15196         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15197         uint64_t ret_ref = (uint64_t)ret_var.inner;
15198         if (ret_var.is_owned) {
15199                 ret_ref |= 1;
15200         }
15201         return ret_ref;
15202 }
15203
15204 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
15205         LDKShutdown orig_conv;
15206         orig_conv.inner = (void*)(orig & (~1));
15207         orig_conv.is_owned = false;
15208         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
15209         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15210         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15211         uint64_t ret_ref = (uint64_t)ret_var.inner;
15212         if (ret_var.is_owned) {
15213                 ret_ref |= 1;
15214         }
15215         return ret_ref;
15216 }
15217
15218 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
15219         LDKClosingSigned this_obj_conv;
15220         this_obj_conv.inner = (void*)(this_obj & (~1));
15221         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15222         ClosingSigned_free(this_obj_conv);
15223 }
15224
15225 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
15226         LDKClosingSigned this_ptr_conv;
15227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15228         this_ptr_conv.is_owned = false;
15229         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15230         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
15231         return ret_arr;
15232 }
15233
15234 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15235         LDKClosingSigned this_ptr_conv;
15236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15237         this_ptr_conv.is_owned = false;
15238         LDKThirtyTwoBytes val_ref;
15239         CHECK(*((uint32_t*)val) == 32);
15240         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15241         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
15242 }
15243
15244 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
15245         LDKClosingSigned this_ptr_conv;
15246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15247         this_ptr_conv.is_owned = false;
15248         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
15249         return ret_val;
15250 }
15251
15252 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
15253         LDKClosingSigned this_ptr_conv;
15254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15255         this_ptr_conv.is_owned = false;
15256         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
15257 }
15258
15259 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
15260         LDKClosingSigned this_ptr_conv;
15261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15262         this_ptr_conv.is_owned = false;
15263         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15264         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
15265         return ret_arr;
15266 }
15267
15268 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
15269         LDKClosingSigned this_ptr_conv;
15270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15271         this_ptr_conv.is_owned = false;
15272         LDKSignature val_ref;
15273         CHECK(*((uint32_t*)val) == 64);
15274         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15275         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
15276 }
15277
15278 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
15279         LDKThirtyTwoBytes channel_id_arg_ref;
15280         CHECK(*((uint32_t*)channel_id_arg) == 32);
15281         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15282         LDKSignature signature_arg_ref;
15283         CHECK(*((uint32_t*)signature_arg) == 64);
15284         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15285         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
15286         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15287         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15288         uint64_t ret_ref = (uint64_t)ret_var.inner;
15289         if (ret_var.is_owned) {
15290                 ret_ref |= 1;
15291         }
15292         return ret_ref;
15293 }
15294
15295 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
15296         LDKClosingSigned orig_conv;
15297         orig_conv.inner = (void*)(orig & (~1));
15298         orig_conv.is_owned = false;
15299         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
15300         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15301         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15302         uint64_t ret_ref = (uint64_t)ret_var.inner;
15303         if (ret_var.is_owned) {
15304                 ret_ref |= 1;
15305         }
15306         return ret_ref;
15307 }
15308
15309 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
15310         LDKUpdateAddHTLC this_obj_conv;
15311         this_obj_conv.inner = (void*)(this_obj & (~1));
15312         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15313         UpdateAddHTLC_free(this_obj_conv);
15314 }
15315
15316 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
15317         LDKUpdateAddHTLC this_ptr_conv;
15318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15319         this_ptr_conv.is_owned = false;
15320         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15321         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
15322         return ret_arr;
15323 }
15324
15325 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15326         LDKUpdateAddHTLC this_ptr_conv;
15327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15328         this_ptr_conv.is_owned = false;
15329         LDKThirtyTwoBytes val_ref;
15330         CHECK(*((uint32_t*)val) == 32);
15331         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15332         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
15333 }
15334
15335 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
15336         LDKUpdateAddHTLC this_ptr_conv;
15337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15338         this_ptr_conv.is_owned = false;
15339         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
15340         return ret_val;
15341 }
15342
15343 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15344         LDKUpdateAddHTLC this_ptr_conv;
15345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15346         this_ptr_conv.is_owned = false;
15347         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
15348 }
15349
15350 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
15351         LDKUpdateAddHTLC this_ptr_conv;
15352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15353         this_ptr_conv.is_owned = false;
15354         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
15355         return ret_val;
15356 }
15357
15358 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
15359         LDKUpdateAddHTLC this_ptr_conv;
15360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15361         this_ptr_conv.is_owned = false;
15362         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
15363 }
15364
15365 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
15366         LDKUpdateAddHTLC this_ptr_conv;
15367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15368         this_ptr_conv.is_owned = false;
15369         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15370         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
15371         return ret_arr;
15372 }
15373
15374 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
15375         LDKUpdateAddHTLC this_ptr_conv;
15376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15377         this_ptr_conv.is_owned = false;
15378         LDKThirtyTwoBytes val_ref;
15379         CHECK(*((uint32_t*)val) == 32);
15380         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15381         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
15382 }
15383
15384 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
15385         LDKUpdateAddHTLC this_ptr_conv;
15386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15387         this_ptr_conv.is_owned = false;
15388         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
15389         return ret_val;
15390 }
15391
15392 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
15393         LDKUpdateAddHTLC this_ptr_conv;
15394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15395         this_ptr_conv.is_owned = false;
15396         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
15397 }
15398
15399 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
15400         LDKUpdateAddHTLC orig_conv;
15401         orig_conv.inner = (void*)(orig & (~1));
15402         orig_conv.is_owned = false;
15403         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
15404         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15405         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15406         uint64_t ret_ref = (uint64_t)ret_var.inner;
15407         if (ret_var.is_owned) {
15408                 ret_ref |= 1;
15409         }
15410         return ret_ref;
15411 }
15412
15413 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
15414         LDKUpdateFulfillHTLC this_obj_conv;
15415         this_obj_conv.inner = (void*)(this_obj & (~1));
15416         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15417         UpdateFulfillHTLC_free(this_obj_conv);
15418 }
15419
15420 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
15421         LDKUpdateFulfillHTLC this_ptr_conv;
15422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15423         this_ptr_conv.is_owned = false;
15424         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15425         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
15426         return ret_arr;
15427 }
15428
15429 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15430         LDKUpdateFulfillHTLC this_ptr_conv;
15431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15432         this_ptr_conv.is_owned = false;
15433         LDKThirtyTwoBytes val_ref;
15434         CHECK(*((uint32_t*)val) == 32);
15435         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15436         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
15437 }
15438
15439 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
15440         LDKUpdateFulfillHTLC this_ptr_conv;
15441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15442         this_ptr_conv.is_owned = false;
15443         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
15444         return ret_val;
15445 }
15446
15447 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15448         LDKUpdateFulfillHTLC this_ptr_conv;
15449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15450         this_ptr_conv.is_owned = false;
15451         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
15452 }
15453
15454 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
15455         LDKUpdateFulfillHTLC this_ptr_conv;
15456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15457         this_ptr_conv.is_owned = false;
15458         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15459         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
15460         return ret_arr;
15461 }
15462
15463 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
15464         LDKUpdateFulfillHTLC this_ptr_conv;
15465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15466         this_ptr_conv.is_owned = false;
15467         LDKThirtyTwoBytes val_ref;
15468         CHECK(*((uint32_t*)val) == 32);
15469         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15470         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
15471 }
15472
15473 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
15474         LDKThirtyTwoBytes channel_id_arg_ref;
15475         CHECK(*((uint32_t*)channel_id_arg) == 32);
15476         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15477         LDKThirtyTwoBytes payment_preimage_arg_ref;
15478         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
15479         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
15480         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
15481         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15482         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15483         uint64_t ret_ref = (uint64_t)ret_var.inner;
15484         if (ret_var.is_owned) {
15485                 ret_ref |= 1;
15486         }
15487         return ret_ref;
15488 }
15489
15490 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
15491         LDKUpdateFulfillHTLC orig_conv;
15492         orig_conv.inner = (void*)(orig & (~1));
15493         orig_conv.is_owned = false;
15494         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
15495         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15496         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15497         uint64_t ret_ref = (uint64_t)ret_var.inner;
15498         if (ret_var.is_owned) {
15499                 ret_ref |= 1;
15500         }
15501         return ret_ref;
15502 }
15503
15504 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
15505         LDKUpdateFailHTLC this_obj_conv;
15506         this_obj_conv.inner = (void*)(this_obj & (~1));
15507         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15508         UpdateFailHTLC_free(this_obj_conv);
15509 }
15510
15511 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
15512         LDKUpdateFailHTLC this_ptr_conv;
15513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15514         this_ptr_conv.is_owned = false;
15515         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15516         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
15517         return ret_arr;
15518 }
15519
15520 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15521         LDKUpdateFailHTLC this_ptr_conv;
15522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15523         this_ptr_conv.is_owned = false;
15524         LDKThirtyTwoBytes val_ref;
15525         CHECK(*((uint32_t*)val) == 32);
15526         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15527         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
15528 }
15529
15530 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
15531         LDKUpdateFailHTLC this_ptr_conv;
15532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15533         this_ptr_conv.is_owned = false;
15534         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
15535         return ret_val;
15536 }
15537
15538 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15539         LDKUpdateFailHTLC this_ptr_conv;
15540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15541         this_ptr_conv.is_owned = false;
15542         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
15543 }
15544
15545 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
15546         LDKUpdateFailHTLC orig_conv;
15547         orig_conv.inner = (void*)(orig & (~1));
15548         orig_conv.is_owned = false;
15549         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
15550         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15551         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15552         uint64_t ret_ref = (uint64_t)ret_var.inner;
15553         if (ret_var.is_owned) {
15554                 ret_ref |= 1;
15555         }
15556         return ret_ref;
15557 }
15558
15559 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
15560         LDKUpdateFailMalformedHTLC this_obj_conv;
15561         this_obj_conv.inner = (void*)(this_obj & (~1));
15562         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15563         UpdateFailMalformedHTLC_free(this_obj_conv);
15564 }
15565
15566 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
15567         LDKUpdateFailMalformedHTLC this_ptr_conv;
15568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15569         this_ptr_conv.is_owned = false;
15570         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15571         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
15572         return ret_arr;
15573 }
15574
15575 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15576         LDKUpdateFailMalformedHTLC this_ptr_conv;
15577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15578         this_ptr_conv.is_owned = false;
15579         LDKThirtyTwoBytes val_ref;
15580         CHECK(*((uint32_t*)val) == 32);
15581         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15582         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
15583 }
15584
15585 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
15586         LDKUpdateFailMalformedHTLC this_ptr_conv;
15587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15588         this_ptr_conv.is_owned = false;
15589         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
15590         return ret_val;
15591 }
15592
15593 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15594         LDKUpdateFailMalformedHTLC this_ptr_conv;
15595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15596         this_ptr_conv.is_owned = false;
15597         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
15598 }
15599
15600 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
15601         LDKUpdateFailMalformedHTLC this_ptr_conv;
15602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15603         this_ptr_conv.is_owned = false;
15604         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
15605         return ret_val;
15606 }
15607
15608 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
15609         LDKUpdateFailMalformedHTLC this_ptr_conv;
15610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15611         this_ptr_conv.is_owned = false;
15612         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
15613 }
15614
15615 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
15616         LDKUpdateFailMalformedHTLC orig_conv;
15617         orig_conv.inner = (void*)(orig & (~1));
15618         orig_conv.is_owned = false;
15619         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
15620         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15621         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15622         uint64_t ret_ref = (uint64_t)ret_var.inner;
15623         if (ret_var.is_owned) {
15624                 ret_ref |= 1;
15625         }
15626         return ret_ref;
15627 }
15628
15629 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
15630         LDKCommitmentSigned this_obj_conv;
15631         this_obj_conv.inner = (void*)(this_obj & (~1));
15632         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15633         CommitmentSigned_free(this_obj_conv);
15634 }
15635
15636 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
15637         LDKCommitmentSigned this_ptr_conv;
15638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15639         this_ptr_conv.is_owned = false;
15640         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15641         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
15642         return ret_arr;
15643 }
15644
15645 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15646         LDKCommitmentSigned this_ptr_conv;
15647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15648         this_ptr_conv.is_owned = false;
15649         LDKThirtyTwoBytes val_ref;
15650         CHECK(*((uint32_t*)val) == 32);
15651         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15652         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
15653 }
15654
15655 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
15656         LDKCommitmentSigned this_ptr_conv;
15657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15658         this_ptr_conv.is_owned = false;
15659         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15660         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
15661         return ret_arr;
15662 }
15663
15664 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
15665         LDKCommitmentSigned this_ptr_conv;
15666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15667         this_ptr_conv.is_owned = false;
15668         LDKSignature val_ref;
15669         CHECK(*((uint32_t*)val) == 64);
15670         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15671         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
15672 }
15673
15674 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
15675         LDKCommitmentSigned this_ptr_conv;
15676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15677         this_ptr_conv.is_owned = false;
15678         LDKCVec_SignatureZ val_constr;
15679         val_constr.datalen = *((uint32_t*)val);
15680         if (val_constr.datalen > 0)
15681                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15682         else
15683                 val_constr.data = NULL;
15684         int8_tArray* val_vals = (int8_tArray*)(val + 4);
15685         for (size_t m = 0; m < val_constr.datalen; m++) {
15686                 int8_tArray val_conv_12 = val_vals[m];
15687                 LDKSignature val_conv_12_ref;
15688                 CHECK(*((uint32_t*)val_conv_12) == 64);
15689                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
15690                 val_constr.data[m] = val_conv_12_ref;
15691         }
15692         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
15693 }
15694
15695 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
15696         LDKThirtyTwoBytes channel_id_arg_ref;
15697         CHECK(*((uint32_t*)channel_id_arg) == 32);
15698         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15699         LDKSignature signature_arg_ref;
15700         CHECK(*((uint32_t*)signature_arg) == 64);
15701         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15702         LDKCVec_SignatureZ htlc_signatures_arg_constr;
15703         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
15704         if (htlc_signatures_arg_constr.datalen > 0)
15705                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15706         else
15707                 htlc_signatures_arg_constr.data = NULL;
15708         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
15709         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
15710                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
15711                 LDKSignature htlc_signatures_arg_conv_12_ref;
15712                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
15713                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
15714                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
15715         }
15716         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
15717         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15718         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15719         uint64_t ret_ref = (uint64_t)ret_var.inner;
15720         if (ret_var.is_owned) {
15721                 ret_ref |= 1;
15722         }
15723         return ret_ref;
15724 }
15725
15726 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
15727         LDKCommitmentSigned orig_conv;
15728         orig_conv.inner = (void*)(orig & (~1));
15729         orig_conv.is_owned = false;
15730         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
15731         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15732         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15733         uint64_t ret_ref = (uint64_t)ret_var.inner;
15734         if (ret_var.is_owned) {
15735                 ret_ref |= 1;
15736         }
15737         return ret_ref;
15738 }
15739
15740 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
15741         LDKRevokeAndACK this_obj_conv;
15742         this_obj_conv.inner = (void*)(this_obj & (~1));
15743         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15744         RevokeAndACK_free(this_obj_conv);
15745 }
15746
15747 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
15748         LDKRevokeAndACK this_ptr_conv;
15749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15750         this_ptr_conv.is_owned = false;
15751         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15752         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
15753         return ret_arr;
15754 }
15755
15756 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15757         LDKRevokeAndACK this_ptr_conv;
15758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15759         this_ptr_conv.is_owned = false;
15760         LDKThirtyTwoBytes val_ref;
15761         CHECK(*((uint32_t*)val) == 32);
15762         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15763         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
15764 }
15765
15766 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
15767         LDKRevokeAndACK this_ptr_conv;
15768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15769         this_ptr_conv.is_owned = false;
15770         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15771         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
15772         return ret_arr;
15773 }
15774
15775 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
15776         LDKRevokeAndACK this_ptr_conv;
15777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15778         this_ptr_conv.is_owned = false;
15779         LDKThirtyTwoBytes val_ref;
15780         CHECK(*((uint32_t*)val) == 32);
15781         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15782         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
15783 }
15784
15785 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
15786         LDKRevokeAndACK this_ptr_conv;
15787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15788         this_ptr_conv.is_owned = false;
15789         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15790         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
15791         return ret_arr;
15792 }
15793
15794 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
15795         LDKRevokeAndACK this_ptr_conv;
15796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15797         this_ptr_conv.is_owned = false;
15798         LDKPublicKey val_ref;
15799         CHECK(*((uint32_t*)val) == 33);
15800         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15801         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
15802 }
15803
15804 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) {
15805         LDKThirtyTwoBytes channel_id_arg_ref;
15806         CHECK(*((uint32_t*)channel_id_arg) == 32);
15807         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15808         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
15809         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
15810         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
15811         LDKPublicKey next_per_commitment_point_arg_ref;
15812         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
15813         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
15814         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
15815         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15816         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15817         uint64_t ret_ref = (uint64_t)ret_var.inner;
15818         if (ret_var.is_owned) {
15819                 ret_ref |= 1;
15820         }
15821         return ret_ref;
15822 }
15823
15824 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
15825         LDKRevokeAndACK orig_conv;
15826         orig_conv.inner = (void*)(orig & (~1));
15827         orig_conv.is_owned = false;
15828         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
15829         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15830         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15831         uint64_t ret_ref = (uint64_t)ret_var.inner;
15832         if (ret_var.is_owned) {
15833                 ret_ref |= 1;
15834         }
15835         return ret_ref;
15836 }
15837
15838 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
15839         LDKUpdateFee this_obj_conv;
15840         this_obj_conv.inner = (void*)(this_obj & (~1));
15841         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15842         UpdateFee_free(this_obj_conv);
15843 }
15844
15845 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
15846         LDKUpdateFee this_ptr_conv;
15847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15848         this_ptr_conv.is_owned = false;
15849         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15850         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
15851         return ret_arr;
15852 }
15853
15854 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15855         LDKUpdateFee this_ptr_conv;
15856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15857         this_ptr_conv.is_owned = false;
15858         LDKThirtyTwoBytes val_ref;
15859         CHECK(*((uint32_t*)val) == 32);
15860         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15861         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
15862 }
15863
15864 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
15865         LDKUpdateFee this_ptr_conv;
15866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15867         this_ptr_conv.is_owned = false;
15868         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
15869         return ret_val;
15870 }
15871
15872 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
15873         LDKUpdateFee this_ptr_conv;
15874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15875         this_ptr_conv.is_owned = false;
15876         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
15877 }
15878
15879 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
15880         LDKThirtyTwoBytes channel_id_arg_ref;
15881         CHECK(*((uint32_t*)channel_id_arg) == 32);
15882         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15883         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
15884         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15885         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15886         uint64_t ret_ref = (uint64_t)ret_var.inner;
15887         if (ret_var.is_owned) {
15888                 ret_ref |= 1;
15889         }
15890         return ret_ref;
15891 }
15892
15893 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
15894         LDKUpdateFee orig_conv;
15895         orig_conv.inner = (void*)(orig & (~1));
15896         orig_conv.is_owned = false;
15897         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
15898         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15899         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15900         uint64_t ret_ref = (uint64_t)ret_var.inner;
15901         if (ret_var.is_owned) {
15902                 ret_ref |= 1;
15903         }
15904         return ret_ref;
15905 }
15906
15907 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
15908         LDKDataLossProtect this_obj_conv;
15909         this_obj_conv.inner = (void*)(this_obj & (~1));
15910         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15911         DataLossProtect_free(this_obj_conv);
15912 }
15913
15914 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
15915         LDKDataLossProtect this_ptr_conv;
15916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15917         this_ptr_conv.is_owned = false;
15918         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15919         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
15920         return ret_arr;
15921 }
15922
15923 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
15924         LDKDataLossProtect this_ptr_conv;
15925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15926         this_ptr_conv.is_owned = false;
15927         LDKThirtyTwoBytes val_ref;
15928         CHECK(*((uint32_t*)val) == 32);
15929         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15930         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
15931 }
15932
15933 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
15934         LDKDataLossProtect this_ptr_conv;
15935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15936         this_ptr_conv.is_owned = false;
15937         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15938         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
15939         return ret_arr;
15940 }
15941
15942 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
15943         LDKDataLossProtect this_ptr_conv;
15944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15945         this_ptr_conv.is_owned = false;
15946         LDKPublicKey val_ref;
15947         CHECK(*((uint32_t*)val) == 33);
15948         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15949         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
15950 }
15951
15952 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
15953         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
15954         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
15955         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
15956         LDKPublicKey my_current_per_commitment_point_arg_ref;
15957         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
15958         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
15959         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
15960         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15961         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15962         uint64_t ret_ref = (uint64_t)ret_var.inner;
15963         if (ret_var.is_owned) {
15964                 ret_ref |= 1;
15965         }
15966         return ret_ref;
15967 }
15968
15969 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
15970         LDKDataLossProtect orig_conv;
15971         orig_conv.inner = (void*)(orig & (~1));
15972         orig_conv.is_owned = false;
15973         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
15974         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15975         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15976         uint64_t ret_ref = (uint64_t)ret_var.inner;
15977         if (ret_var.is_owned) {
15978                 ret_ref |= 1;
15979         }
15980         return ret_ref;
15981 }
15982
15983 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
15984         LDKChannelReestablish this_obj_conv;
15985         this_obj_conv.inner = (void*)(this_obj & (~1));
15986         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15987         ChannelReestablish_free(this_obj_conv);
15988 }
15989
15990 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
15991         LDKChannelReestablish this_ptr_conv;
15992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15993         this_ptr_conv.is_owned = false;
15994         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15995         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
15996         return ret_arr;
15997 }
15998
15999 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16000         LDKChannelReestablish this_ptr_conv;
16001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16002         this_ptr_conv.is_owned = false;
16003         LDKThirtyTwoBytes val_ref;
16004         CHECK(*((uint32_t*)val) == 32);
16005         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16006         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
16007 }
16008
16009 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
16010         LDKChannelReestablish this_ptr_conv;
16011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16012         this_ptr_conv.is_owned = false;
16013         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
16014         return ret_val;
16015 }
16016
16017 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
16018         LDKChannelReestablish this_ptr_conv;
16019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16020         this_ptr_conv.is_owned = false;
16021         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
16022 }
16023
16024 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
16025         LDKChannelReestablish this_ptr_conv;
16026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16027         this_ptr_conv.is_owned = false;
16028         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
16029         return ret_val;
16030 }
16031
16032 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
16033         LDKChannelReestablish this_ptr_conv;
16034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16035         this_ptr_conv.is_owned = false;
16036         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
16037 }
16038
16039 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
16040         LDKChannelReestablish orig_conv;
16041         orig_conv.inner = (void*)(orig & (~1));
16042         orig_conv.is_owned = false;
16043         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
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 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
16054         LDKAnnouncementSignatures this_obj_conv;
16055         this_obj_conv.inner = (void*)(this_obj & (~1));
16056         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16057         AnnouncementSignatures_free(this_obj_conv);
16058 }
16059
16060 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
16061         LDKAnnouncementSignatures this_ptr_conv;
16062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16063         this_ptr_conv.is_owned = false;
16064         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16065         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
16066         return ret_arr;
16067 }
16068
16069 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16070         LDKAnnouncementSignatures this_ptr_conv;
16071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16072         this_ptr_conv.is_owned = false;
16073         LDKThirtyTwoBytes val_ref;
16074         CHECK(*((uint32_t*)val) == 32);
16075         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16076         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
16077 }
16078
16079 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
16080         LDKAnnouncementSignatures this_ptr_conv;
16081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16082         this_ptr_conv.is_owned = false;
16083         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
16084         return ret_val;
16085 }
16086
16087 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
16088         LDKAnnouncementSignatures this_ptr_conv;
16089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16090         this_ptr_conv.is_owned = false;
16091         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
16092 }
16093
16094 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
16095         LDKAnnouncementSignatures this_ptr_conv;
16096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16097         this_ptr_conv.is_owned = false;
16098         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16099         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
16100         return ret_arr;
16101 }
16102
16103 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
16104         LDKAnnouncementSignatures this_ptr_conv;
16105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16106         this_ptr_conv.is_owned = false;
16107         LDKSignature val_ref;
16108         CHECK(*((uint32_t*)val) == 64);
16109         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16110         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
16111 }
16112
16113 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
16114         LDKAnnouncementSignatures this_ptr_conv;
16115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16116         this_ptr_conv.is_owned = false;
16117         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16118         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
16119         return ret_arr;
16120 }
16121
16122 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
16123         LDKAnnouncementSignatures this_ptr_conv;
16124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16125         this_ptr_conv.is_owned = false;
16126         LDKSignature val_ref;
16127         CHECK(*((uint32_t*)val) == 64);
16128         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16129         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
16130 }
16131
16132 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) {
16133         LDKThirtyTwoBytes channel_id_arg_ref;
16134         CHECK(*((uint32_t*)channel_id_arg) == 32);
16135         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16136         LDKSignature node_signature_arg_ref;
16137         CHECK(*((uint32_t*)node_signature_arg) == 64);
16138         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
16139         LDKSignature bitcoin_signature_arg_ref;
16140         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
16141         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
16142         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
16143         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16144         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16145         uint64_t ret_ref = (uint64_t)ret_var.inner;
16146         if (ret_var.is_owned) {
16147                 ret_ref |= 1;
16148         }
16149         return ret_ref;
16150 }
16151
16152 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
16153         LDKAnnouncementSignatures orig_conv;
16154         orig_conv.inner = (void*)(orig & (~1));
16155         orig_conv.is_owned = false;
16156         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
16157         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16158         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16159         uint64_t ret_ref = (uint64_t)ret_var.inner;
16160         if (ret_var.is_owned) {
16161                 ret_ref |= 1;
16162         }
16163         return ret_ref;
16164 }
16165
16166 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
16167         if ((this_ptr & 1) != 0) return;
16168         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
16169         FREE((void*)this_ptr);
16170         NetAddress_free(this_ptr_conv);
16171 }
16172
16173 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
16174         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
16175         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
16176         *ret_copy = NetAddress_clone(orig_conv);
16177         uint64_t ret_ref = (uint64_t)ret_copy;
16178         return ret_ref;
16179 }
16180
16181 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
16182         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
16183         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
16184         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16185         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16186         CVec_u8Z_free(ret_var);
16187         return ret_arr;
16188 }
16189
16190 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
16191         LDKu8slice ser_ref;
16192         ser_ref.datalen = *((uint32_t*)ser);
16193         ser_ref.data = (int8_t*)(ser + 4);
16194         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
16195         *ret_conv = Result_read(ser_ref);
16196         return (uint64_t)ret_conv;
16197 }
16198
16199 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
16200         LDKu8slice ser_ref;
16201         ser_ref.datalen = *((uint32_t*)ser);
16202         ser_ref.data = (int8_t*)(ser + 4);
16203         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
16204         *ret_conv = NetAddress_read(ser_ref);
16205         return (uint64_t)ret_conv;
16206 }
16207
16208 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
16209         LDKUnsignedNodeAnnouncement 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         UnsignedNodeAnnouncement_free(this_obj_conv);
16213 }
16214
16215 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
16216         LDKUnsignedNodeAnnouncement this_ptr_conv;
16217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16218         this_ptr_conv.is_owned = false;
16219         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
16220         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16221         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16222         uint64_t ret_ref = (uint64_t)ret_var.inner;
16223         if (ret_var.is_owned) {
16224                 ret_ref |= 1;
16225         }
16226         return ret_ref;
16227 }
16228
16229 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
16230         LDKUnsignedNodeAnnouncement this_ptr_conv;
16231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16232         this_ptr_conv.is_owned = false;
16233         LDKNodeFeatures val_conv;
16234         val_conv.inner = (void*)(val & (~1));
16235         val_conv.is_owned = (val & 1) || (val == 0);
16236         val_conv = NodeFeatures_clone(&val_conv);
16237         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
16238 }
16239
16240 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
16241         LDKUnsignedNodeAnnouncement this_ptr_conv;
16242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16243         this_ptr_conv.is_owned = false;
16244         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
16245         return ret_val;
16246 }
16247
16248 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
16249         LDKUnsignedNodeAnnouncement this_ptr_conv;
16250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16251         this_ptr_conv.is_owned = false;
16252         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
16253 }
16254
16255 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
16256         LDKUnsignedNodeAnnouncement this_ptr_conv;
16257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16258         this_ptr_conv.is_owned = false;
16259         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16260         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
16261         return ret_arr;
16262 }
16263
16264 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
16265         LDKUnsignedNodeAnnouncement this_ptr_conv;
16266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16267         this_ptr_conv.is_owned = false;
16268         LDKPublicKey val_ref;
16269         CHECK(*((uint32_t*)val) == 33);
16270         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16271         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
16272 }
16273
16274 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
16275         LDKUnsignedNodeAnnouncement this_ptr_conv;
16276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16277         this_ptr_conv.is_owned = false;
16278         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
16279         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
16280         return ret_arr;
16281 }
16282
16283 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
16284         LDKUnsignedNodeAnnouncement this_ptr_conv;
16285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16286         this_ptr_conv.is_owned = false;
16287         LDKThreeBytes val_ref;
16288         CHECK(*((uint32_t*)val) == 3);
16289         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
16290         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
16291 }
16292
16293 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
16294         LDKUnsignedNodeAnnouncement this_ptr_conv;
16295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16296         this_ptr_conv.is_owned = false;
16297         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16298         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
16299         return ret_arr;
16300 }
16301
16302 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
16303         LDKUnsignedNodeAnnouncement this_ptr_conv;
16304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16305         this_ptr_conv.is_owned = false;
16306         LDKThirtyTwoBytes val_ref;
16307         CHECK(*((uint32_t*)val) == 32);
16308         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16309         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
16310 }
16311
16312 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
16313         LDKUnsignedNodeAnnouncement this_ptr_conv;
16314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16315         this_ptr_conv.is_owned = false;
16316         LDKCVec_NetAddressZ val_constr;
16317         val_constr.datalen = *((uint32_t*)val);
16318         if (val_constr.datalen > 0)
16319                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16320         else
16321                 val_constr.data = NULL;
16322         uint32_t* val_vals = (uint32_t*)(val + 4);
16323         for (size_t m = 0; m < val_constr.datalen; m++) {
16324                 uint32_t val_conv_12 = val_vals[m];
16325                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
16326                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
16327                 val_constr.data[m] = val_conv_12_conv;
16328         }
16329         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
16330 }
16331
16332 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
16333         LDKUnsignedNodeAnnouncement orig_conv;
16334         orig_conv.inner = (void*)(orig & (~1));
16335         orig_conv.is_owned = false;
16336         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
16337         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16338         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16339         uint64_t ret_ref = (uint64_t)ret_var.inner;
16340         if (ret_var.is_owned) {
16341                 ret_ref |= 1;
16342         }
16343         return ret_ref;
16344 }
16345
16346 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
16347         LDKNodeAnnouncement this_obj_conv;
16348         this_obj_conv.inner = (void*)(this_obj & (~1));
16349         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16350         NodeAnnouncement_free(this_obj_conv);
16351 }
16352
16353 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
16354         LDKNodeAnnouncement this_ptr_conv;
16355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16356         this_ptr_conv.is_owned = false;
16357         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16358         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
16359         return ret_arr;
16360 }
16361
16362 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
16363         LDKNodeAnnouncement this_ptr_conv;
16364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16365         this_ptr_conv.is_owned = false;
16366         LDKSignature val_ref;
16367         CHECK(*((uint32_t*)val) == 64);
16368         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16369         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
16370 }
16371
16372 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
16373         LDKNodeAnnouncement this_ptr_conv;
16374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16375         this_ptr_conv.is_owned = false;
16376         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
16377         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16378         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16379         uint64_t ret_ref = (uint64_t)ret_var.inner;
16380         if (ret_var.is_owned) {
16381                 ret_ref |= 1;
16382         }
16383         return ret_ref;
16384 }
16385
16386 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
16387         LDKNodeAnnouncement this_ptr_conv;
16388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16389         this_ptr_conv.is_owned = false;
16390         LDKUnsignedNodeAnnouncement val_conv;
16391         val_conv.inner = (void*)(val & (~1));
16392         val_conv.is_owned = (val & 1) || (val == 0);
16393         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
16394         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
16395 }
16396
16397 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
16398         LDKSignature signature_arg_ref;
16399         CHECK(*((uint32_t*)signature_arg) == 64);
16400         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
16401         LDKUnsignedNodeAnnouncement contents_arg_conv;
16402         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16403         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16404         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
16405         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
16406         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16407         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16408         uint64_t ret_ref = (uint64_t)ret_var.inner;
16409         if (ret_var.is_owned) {
16410                 ret_ref |= 1;
16411         }
16412         return ret_ref;
16413 }
16414
16415 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
16416         LDKNodeAnnouncement orig_conv;
16417         orig_conv.inner = (void*)(orig & (~1));
16418         orig_conv.is_owned = false;
16419         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
16420         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16421         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16422         uint64_t ret_ref = (uint64_t)ret_var.inner;
16423         if (ret_var.is_owned) {
16424                 ret_ref |= 1;
16425         }
16426         return ret_ref;
16427 }
16428
16429 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
16430         LDKUnsignedChannelAnnouncement this_obj_conv;
16431         this_obj_conv.inner = (void*)(this_obj & (~1));
16432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16433         UnsignedChannelAnnouncement_free(this_obj_conv);
16434 }
16435
16436 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
16437         LDKUnsignedChannelAnnouncement this_ptr_conv;
16438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16439         this_ptr_conv.is_owned = false;
16440         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
16441         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16442         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16443         uint64_t ret_ref = (uint64_t)ret_var.inner;
16444         if (ret_var.is_owned) {
16445                 ret_ref |= 1;
16446         }
16447         return ret_ref;
16448 }
16449
16450 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
16451         LDKUnsignedChannelAnnouncement this_ptr_conv;
16452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16453         this_ptr_conv.is_owned = false;
16454         LDKChannelFeatures val_conv;
16455         val_conv.inner = (void*)(val & (~1));
16456         val_conv.is_owned = (val & 1) || (val == 0);
16457         val_conv = ChannelFeatures_clone(&val_conv);
16458         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
16459 }
16460
16461 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
16462         LDKUnsignedChannelAnnouncement this_ptr_conv;
16463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16464         this_ptr_conv.is_owned = false;
16465         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16466         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
16467         return ret_arr;
16468 }
16469
16470 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16471         LDKUnsignedChannelAnnouncement this_ptr_conv;
16472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16473         this_ptr_conv.is_owned = false;
16474         LDKThirtyTwoBytes val_ref;
16475         CHECK(*((uint32_t*)val) == 32);
16476         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16477         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
16478 }
16479
16480 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
16481         LDKUnsignedChannelAnnouncement this_ptr_conv;
16482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16483         this_ptr_conv.is_owned = false;
16484         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
16485         return ret_val;
16486 }
16487
16488 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
16489         LDKUnsignedChannelAnnouncement this_ptr_conv;
16490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16491         this_ptr_conv.is_owned = false;
16492         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
16493 }
16494
16495 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
16496         LDKUnsignedChannelAnnouncement this_ptr_conv;
16497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16498         this_ptr_conv.is_owned = false;
16499         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16500         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
16501         return ret_arr;
16502 }
16503
16504 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
16505         LDKUnsignedChannelAnnouncement this_ptr_conv;
16506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16507         this_ptr_conv.is_owned = false;
16508         LDKPublicKey val_ref;
16509         CHECK(*((uint32_t*)val) == 33);
16510         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16511         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
16512 }
16513
16514 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
16515         LDKUnsignedChannelAnnouncement this_ptr_conv;
16516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16517         this_ptr_conv.is_owned = false;
16518         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16519         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
16520         return ret_arr;
16521 }
16522
16523 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
16524         LDKUnsignedChannelAnnouncement this_ptr_conv;
16525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16526         this_ptr_conv.is_owned = false;
16527         LDKPublicKey val_ref;
16528         CHECK(*((uint32_t*)val) == 33);
16529         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16530         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
16531 }
16532
16533 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
16534         LDKUnsignedChannelAnnouncement this_ptr_conv;
16535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16536         this_ptr_conv.is_owned = false;
16537         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16538         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
16539         return ret_arr;
16540 }
16541
16542 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
16543         LDKUnsignedChannelAnnouncement this_ptr_conv;
16544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16545         this_ptr_conv.is_owned = false;
16546         LDKPublicKey val_ref;
16547         CHECK(*((uint32_t*)val) == 33);
16548         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16549         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
16550 }
16551
16552 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
16553         LDKUnsignedChannelAnnouncement this_ptr_conv;
16554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16555         this_ptr_conv.is_owned = false;
16556         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16557         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
16558         return ret_arr;
16559 }
16560
16561 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
16562         LDKUnsignedChannelAnnouncement this_ptr_conv;
16563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16564         this_ptr_conv.is_owned = false;
16565         LDKPublicKey val_ref;
16566         CHECK(*((uint32_t*)val) == 33);
16567         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16568         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
16569 }
16570
16571 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
16572         LDKUnsignedChannelAnnouncement orig_conv;
16573         orig_conv.inner = (void*)(orig & (~1));
16574         orig_conv.is_owned = false;
16575         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
16576         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16577         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16578         uint64_t ret_ref = (uint64_t)ret_var.inner;
16579         if (ret_var.is_owned) {
16580                 ret_ref |= 1;
16581         }
16582         return ret_ref;
16583 }
16584
16585 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
16586         LDKChannelAnnouncement this_obj_conv;
16587         this_obj_conv.inner = (void*)(this_obj & (~1));
16588         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16589         ChannelAnnouncement_free(this_obj_conv);
16590 }
16591
16592 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
16593         LDKChannelAnnouncement this_ptr_conv;
16594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16595         this_ptr_conv.is_owned = false;
16596         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16597         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
16598         return ret_arr;
16599 }
16600
16601 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
16602         LDKChannelAnnouncement this_ptr_conv;
16603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16604         this_ptr_conv.is_owned = false;
16605         LDKSignature val_ref;
16606         CHECK(*((uint32_t*)val) == 64);
16607         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16608         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
16609 }
16610
16611 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
16612         LDKChannelAnnouncement this_ptr_conv;
16613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16614         this_ptr_conv.is_owned = false;
16615         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16616         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
16617         return ret_arr;
16618 }
16619
16620 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
16621         LDKChannelAnnouncement this_ptr_conv;
16622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16623         this_ptr_conv.is_owned = false;
16624         LDKSignature val_ref;
16625         CHECK(*((uint32_t*)val) == 64);
16626         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16627         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
16628 }
16629
16630 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
16631         LDKChannelAnnouncement this_ptr_conv;
16632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16633         this_ptr_conv.is_owned = false;
16634         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16635         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
16636         return ret_arr;
16637 }
16638
16639 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
16640         LDKChannelAnnouncement this_ptr_conv;
16641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16642         this_ptr_conv.is_owned = false;
16643         LDKSignature val_ref;
16644         CHECK(*((uint32_t*)val) == 64);
16645         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16646         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
16647 }
16648
16649 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
16650         LDKChannelAnnouncement this_ptr_conv;
16651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16652         this_ptr_conv.is_owned = false;
16653         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16654         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
16655         return ret_arr;
16656 }
16657
16658 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
16659         LDKChannelAnnouncement this_ptr_conv;
16660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16661         this_ptr_conv.is_owned = false;
16662         LDKSignature val_ref;
16663         CHECK(*((uint32_t*)val) == 64);
16664         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16665         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
16666 }
16667
16668 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
16669         LDKChannelAnnouncement this_ptr_conv;
16670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16671         this_ptr_conv.is_owned = false;
16672         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
16673         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16674         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16675         uint64_t ret_ref = (uint64_t)ret_var.inner;
16676         if (ret_var.is_owned) {
16677                 ret_ref |= 1;
16678         }
16679         return ret_ref;
16680 }
16681
16682 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
16683         LDKChannelAnnouncement this_ptr_conv;
16684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16685         this_ptr_conv.is_owned = false;
16686         LDKUnsignedChannelAnnouncement val_conv;
16687         val_conv.inner = (void*)(val & (~1));
16688         val_conv.is_owned = (val & 1) || (val == 0);
16689         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
16690         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
16691 }
16692
16693 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) {
16694         LDKSignature node_signature_1_arg_ref;
16695         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
16696         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
16697         LDKSignature node_signature_2_arg_ref;
16698         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
16699         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
16700         LDKSignature bitcoin_signature_1_arg_ref;
16701         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
16702         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
16703         LDKSignature bitcoin_signature_2_arg_ref;
16704         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
16705         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
16706         LDKUnsignedChannelAnnouncement contents_arg_conv;
16707         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16708         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16709         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
16710         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);
16711         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16712         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16713         uint64_t ret_ref = (uint64_t)ret_var.inner;
16714         if (ret_var.is_owned) {
16715                 ret_ref |= 1;
16716         }
16717         return ret_ref;
16718 }
16719
16720 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
16721         LDKChannelAnnouncement orig_conv;
16722         orig_conv.inner = (void*)(orig & (~1));
16723         orig_conv.is_owned = false;
16724         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
16725         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16726         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16727         uint64_t ret_ref = (uint64_t)ret_var.inner;
16728         if (ret_var.is_owned) {
16729                 ret_ref |= 1;
16730         }
16731         return ret_ref;
16732 }
16733
16734 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
16735         LDKUnsignedChannelUpdate this_obj_conv;
16736         this_obj_conv.inner = (void*)(this_obj & (~1));
16737         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16738         UnsignedChannelUpdate_free(this_obj_conv);
16739 }
16740
16741 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
16742         LDKUnsignedChannelUpdate this_ptr_conv;
16743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16744         this_ptr_conv.is_owned = false;
16745         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16746         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
16747         return ret_arr;
16748 }
16749
16750 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16751         LDKUnsignedChannelUpdate this_ptr_conv;
16752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16753         this_ptr_conv.is_owned = false;
16754         LDKThirtyTwoBytes val_ref;
16755         CHECK(*((uint32_t*)val) == 32);
16756         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16757         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
16758 }
16759
16760 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
16761         LDKUnsignedChannelUpdate this_ptr_conv;
16762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16763         this_ptr_conv.is_owned = false;
16764         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
16765         return ret_val;
16766 }
16767
16768 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
16769         LDKUnsignedChannelUpdate this_ptr_conv;
16770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16771         this_ptr_conv.is_owned = false;
16772         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
16773 }
16774
16775 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
16776         LDKUnsignedChannelUpdate this_ptr_conv;
16777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16778         this_ptr_conv.is_owned = false;
16779         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
16780         return ret_val;
16781 }
16782
16783 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
16784         LDKUnsignedChannelUpdate this_ptr_conv;
16785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16786         this_ptr_conv.is_owned = false;
16787         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
16788 }
16789
16790 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
16791         LDKUnsignedChannelUpdate this_ptr_conv;
16792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16793         this_ptr_conv.is_owned = false;
16794         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
16795         return ret_val;
16796 }
16797
16798 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
16799         LDKUnsignedChannelUpdate this_ptr_conv;
16800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16801         this_ptr_conv.is_owned = false;
16802         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
16803 }
16804
16805 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
16806         LDKUnsignedChannelUpdate this_ptr_conv;
16807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16808         this_ptr_conv.is_owned = false;
16809         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
16810         return ret_val;
16811 }
16812
16813 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
16814         LDKUnsignedChannelUpdate this_ptr_conv;
16815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16816         this_ptr_conv.is_owned = false;
16817         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
16818 }
16819
16820 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
16821         LDKUnsignedChannelUpdate this_ptr_conv;
16822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16823         this_ptr_conv.is_owned = false;
16824         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
16825         return ret_val;
16826 }
16827
16828 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
16829         LDKUnsignedChannelUpdate this_ptr_conv;
16830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16831         this_ptr_conv.is_owned = false;
16832         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
16833 }
16834
16835 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
16836         LDKUnsignedChannelUpdate this_ptr_conv;
16837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16838         this_ptr_conv.is_owned = false;
16839         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
16840         return ret_val;
16841 }
16842
16843 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
16844         LDKUnsignedChannelUpdate this_ptr_conv;
16845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16846         this_ptr_conv.is_owned = false;
16847         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
16848 }
16849
16850 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
16851         LDKUnsignedChannelUpdate this_ptr_conv;
16852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16853         this_ptr_conv.is_owned = false;
16854         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
16855         return ret_val;
16856 }
16857
16858 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
16859         LDKUnsignedChannelUpdate this_ptr_conv;
16860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16861         this_ptr_conv.is_owned = false;
16862         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
16863 }
16864
16865 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
16866         LDKUnsignedChannelUpdate orig_conv;
16867         orig_conv.inner = (void*)(orig & (~1));
16868         orig_conv.is_owned = false;
16869         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
16870         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16871         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16872         uint64_t ret_ref = (uint64_t)ret_var.inner;
16873         if (ret_var.is_owned) {
16874                 ret_ref |= 1;
16875         }
16876         return ret_ref;
16877 }
16878
16879 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
16880         LDKChannelUpdate this_obj_conv;
16881         this_obj_conv.inner = (void*)(this_obj & (~1));
16882         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16883         ChannelUpdate_free(this_obj_conv);
16884 }
16885
16886 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
16887         LDKChannelUpdate this_ptr_conv;
16888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16889         this_ptr_conv.is_owned = false;
16890         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16891         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
16892         return ret_arr;
16893 }
16894
16895 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
16896         LDKChannelUpdate this_ptr_conv;
16897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16898         this_ptr_conv.is_owned = false;
16899         LDKSignature val_ref;
16900         CHECK(*((uint32_t*)val) == 64);
16901         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16902         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
16903 }
16904
16905 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
16906         LDKChannelUpdate this_ptr_conv;
16907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16908         this_ptr_conv.is_owned = false;
16909         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
16910         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16911         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16912         uint64_t ret_ref = (uint64_t)ret_var.inner;
16913         if (ret_var.is_owned) {
16914                 ret_ref |= 1;
16915         }
16916         return ret_ref;
16917 }
16918
16919 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
16920         LDKChannelUpdate this_ptr_conv;
16921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16922         this_ptr_conv.is_owned = false;
16923         LDKUnsignedChannelUpdate val_conv;
16924         val_conv.inner = (void*)(val & (~1));
16925         val_conv.is_owned = (val & 1) || (val == 0);
16926         val_conv = UnsignedChannelUpdate_clone(&val_conv);
16927         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
16928 }
16929
16930 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
16931         LDKSignature signature_arg_ref;
16932         CHECK(*((uint32_t*)signature_arg) == 64);
16933         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
16934         LDKUnsignedChannelUpdate contents_arg_conv;
16935         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16936         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16937         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
16938         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
16939         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16940         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16941         uint64_t ret_ref = (uint64_t)ret_var.inner;
16942         if (ret_var.is_owned) {
16943                 ret_ref |= 1;
16944         }
16945         return ret_ref;
16946 }
16947
16948 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
16949         LDKChannelUpdate orig_conv;
16950         orig_conv.inner = (void*)(orig & (~1));
16951         orig_conv.is_owned = false;
16952         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
16953         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16954         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16955         uint64_t ret_ref = (uint64_t)ret_var.inner;
16956         if (ret_var.is_owned) {
16957                 ret_ref |= 1;
16958         }
16959         return ret_ref;
16960 }
16961
16962 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
16963         LDKQueryChannelRange this_obj_conv;
16964         this_obj_conv.inner = (void*)(this_obj & (~1));
16965         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16966         QueryChannelRange_free(this_obj_conv);
16967 }
16968
16969 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
16970         LDKQueryChannelRange this_ptr_conv;
16971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16972         this_ptr_conv.is_owned = false;
16973         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16974         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
16975         return ret_arr;
16976 }
16977
16978 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16979         LDKQueryChannelRange this_ptr_conv;
16980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16981         this_ptr_conv.is_owned = false;
16982         LDKThirtyTwoBytes val_ref;
16983         CHECK(*((uint32_t*)val) == 32);
16984         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16985         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
16986 }
16987
16988 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
16989         LDKQueryChannelRange this_ptr_conv;
16990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16991         this_ptr_conv.is_owned = false;
16992         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
16993         return ret_val;
16994 }
16995
16996 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
16997         LDKQueryChannelRange this_ptr_conv;
16998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16999         this_ptr_conv.is_owned = false;
17000         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
17001 }
17002
17003 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
17004         LDKQueryChannelRange this_ptr_conv;
17005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17006         this_ptr_conv.is_owned = false;
17007         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
17008         return ret_val;
17009 }
17010
17011 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
17012         LDKQueryChannelRange this_ptr_conv;
17013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17014         this_ptr_conv.is_owned = false;
17015         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
17016 }
17017
17018 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
17019         LDKThirtyTwoBytes chain_hash_arg_ref;
17020         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17021         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17022         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
17023         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17024         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17025         uint64_t ret_ref = (uint64_t)ret_var.inner;
17026         if (ret_var.is_owned) {
17027                 ret_ref |= 1;
17028         }
17029         return ret_ref;
17030 }
17031
17032 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
17033         LDKQueryChannelRange orig_conv;
17034         orig_conv.inner = (void*)(orig & (~1));
17035         orig_conv.is_owned = false;
17036         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
17037         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17038         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17039         uint64_t ret_ref = (uint64_t)ret_var.inner;
17040         if (ret_var.is_owned) {
17041                 ret_ref |= 1;
17042         }
17043         return ret_ref;
17044 }
17045
17046 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
17047         LDKReplyChannelRange this_obj_conv;
17048         this_obj_conv.inner = (void*)(this_obj & (~1));
17049         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17050         ReplyChannelRange_free(this_obj_conv);
17051 }
17052
17053 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
17054         LDKReplyChannelRange this_ptr_conv;
17055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17056         this_ptr_conv.is_owned = false;
17057         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17058         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
17059         return ret_arr;
17060 }
17061
17062 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17063         LDKReplyChannelRange this_ptr_conv;
17064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17065         this_ptr_conv.is_owned = false;
17066         LDKThirtyTwoBytes val_ref;
17067         CHECK(*((uint32_t*)val) == 32);
17068         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17069         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
17070 }
17071
17072 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
17073         LDKReplyChannelRange this_ptr_conv;
17074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17075         this_ptr_conv.is_owned = false;
17076         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
17077         return ret_val;
17078 }
17079
17080 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
17081         LDKReplyChannelRange this_ptr_conv;
17082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17083         this_ptr_conv.is_owned = false;
17084         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
17085 }
17086
17087 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
17088         LDKReplyChannelRange this_ptr_conv;
17089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17090         this_ptr_conv.is_owned = false;
17091         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
17092         return ret_val;
17093 }
17094
17095 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
17096         LDKReplyChannelRange this_ptr_conv;
17097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17098         this_ptr_conv.is_owned = false;
17099         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
17100 }
17101
17102 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
17103         LDKReplyChannelRange this_ptr_conv;
17104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17105         this_ptr_conv.is_owned = false;
17106         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
17107         return ret_val;
17108 }
17109
17110 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
17111         LDKReplyChannelRange this_ptr_conv;
17112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17113         this_ptr_conv.is_owned = false;
17114         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
17115 }
17116
17117 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
17118         LDKReplyChannelRange this_ptr_conv;
17119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17120         this_ptr_conv.is_owned = false;
17121         LDKCVec_u64Z val_constr;
17122         val_constr.datalen = *((uint32_t*)val);
17123         if (val_constr.datalen > 0)
17124                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17125         else
17126                 val_constr.data = NULL;
17127         int64_t* val_vals = (int64_t*)(val + 4);
17128         for (size_t i = 0; i < val_constr.datalen; i++) {
17129                 int64_t val_conv_8 = val_vals[i];
17130                 val_constr.data[i] = val_conv_8;
17131         }
17132         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
17133 }
17134
17135 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) {
17136         LDKThirtyTwoBytes chain_hash_arg_ref;
17137         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17138         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17139         LDKCVec_u64Z short_channel_ids_arg_constr;
17140         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
17141         if (short_channel_ids_arg_constr.datalen > 0)
17142                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17143         else
17144                 short_channel_ids_arg_constr.data = NULL;
17145         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
17146         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
17147                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
17148                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
17149         }
17150         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
17151         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17152         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17153         uint64_t ret_ref = (uint64_t)ret_var.inner;
17154         if (ret_var.is_owned) {
17155                 ret_ref |= 1;
17156         }
17157         return ret_ref;
17158 }
17159
17160 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
17161         LDKReplyChannelRange orig_conv;
17162         orig_conv.inner = (void*)(orig & (~1));
17163         orig_conv.is_owned = false;
17164         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
17165         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17166         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17167         uint64_t ret_ref = (uint64_t)ret_var.inner;
17168         if (ret_var.is_owned) {
17169                 ret_ref |= 1;
17170         }
17171         return ret_ref;
17172 }
17173
17174 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
17175         LDKQueryShortChannelIds this_obj_conv;
17176         this_obj_conv.inner = (void*)(this_obj & (~1));
17177         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17178         QueryShortChannelIds_free(this_obj_conv);
17179 }
17180
17181 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
17182         LDKQueryShortChannelIds this_ptr_conv;
17183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17184         this_ptr_conv.is_owned = false;
17185         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17186         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
17187         return ret_arr;
17188 }
17189
17190 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17191         LDKQueryShortChannelIds this_ptr_conv;
17192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17193         this_ptr_conv.is_owned = false;
17194         LDKThirtyTwoBytes val_ref;
17195         CHECK(*((uint32_t*)val) == 32);
17196         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17197         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
17198 }
17199
17200 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
17201         LDKQueryShortChannelIds this_ptr_conv;
17202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17203         this_ptr_conv.is_owned = false;
17204         LDKCVec_u64Z val_constr;
17205         val_constr.datalen = *((uint32_t*)val);
17206         if (val_constr.datalen > 0)
17207                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17208         else
17209                 val_constr.data = NULL;
17210         int64_t* val_vals = (int64_t*)(val + 4);
17211         for (size_t i = 0; i < val_constr.datalen; i++) {
17212                 int64_t val_conv_8 = val_vals[i];
17213                 val_constr.data[i] = val_conv_8;
17214         }
17215         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
17216 }
17217
17218 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
17219         LDKThirtyTwoBytes chain_hash_arg_ref;
17220         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17221         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17222         LDKCVec_u64Z short_channel_ids_arg_constr;
17223         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
17224         if (short_channel_ids_arg_constr.datalen > 0)
17225                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17226         else
17227                 short_channel_ids_arg_constr.data = NULL;
17228         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
17229         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
17230                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
17231                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
17232         }
17233         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
17234         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17235         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17236         uint64_t ret_ref = (uint64_t)ret_var.inner;
17237         if (ret_var.is_owned) {
17238                 ret_ref |= 1;
17239         }
17240         return ret_ref;
17241 }
17242
17243 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
17244         LDKQueryShortChannelIds orig_conv;
17245         orig_conv.inner = (void*)(orig & (~1));
17246         orig_conv.is_owned = false;
17247         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
17248         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17249         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17250         uint64_t ret_ref = (uint64_t)ret_var.inner;
17251         if (ret_var.is_owned) {
17252                 ret_ref |= 1;
17253         }
17254         return ret_ref;
17255 }
17256
17257 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
17258         LDKReplyShortChannelIdsEnd this_obj_conv;
17259         this_obj_conv.inner = (void*)(this_obj & (~1));
17260         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17261         ReplyShortChannelIdsEnd_free(this_obj_conv);
17262 }
17263
17264 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
17265         LDKReplyShortChannelIdsEnd this_ptr_conv;
17266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17267         this_ptr_conv.is_owned = false;
17268         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17269         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
17270         return ret_arr;
17271 }
17272
17273 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17274         LDKReplyShortChannelIdsEnd this_ptr_conv;
17275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17276         this_ptr_conv.is_owned = false;
17277         LDKThirtyTwoBytes val_ref;
17278         CHECK(*((uint32_t*)val) == 32);
17279         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17280         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
17281 }
17282
17283 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
17284         LDKReplyShortChannelIdsEnd this_ptr_conv;
17285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17286         this_ptr_conv.is_owned = false;
17287         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
17288         return ret_val;
17289 }
17290
17291 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
17292         LDKReplyShortChannelIdsEnd this_ptr_conv;
17293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17294         this_ptr_conv.is_owned = false;
17295         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
17296 }
17297
17298 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
17299         LDKThirtyTwoBytes chain_hash_arg_ref;
17300         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17301         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17302         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
17303         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17304         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17305         uint64_t ret_ref = (uint64_t)ret_var.inner;
17306         if (ret_var.is_owned) {
17307                 ret_ref |= 1;
17308         }
17309         return ret_ref;
17310 }
17311
17312 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
17313         LDKReplyShortChannelIdsEnd orig_conv;
17314         orig_conv.inner = (void*)(orig & (~1));
17315         orig_conv.is_owned = false;
17316         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
17317         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17318         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17319         uint64_t ret_ref = (uint64_t)ret_var.inner;
17320         if (ret_var.is_owned) {
17321                 ret_ref |= 1;
17322         }
17323         return ret_ref;
17324 }
17325
17326 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
17327         LDKGossipTimestampFilter this_obj_conv;
17328         this_obj_conv.inner = (void*)(this_obj & (~1));
17329         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17330         GossipTimestampFilter_free(this_obj_conv);
17331 }
17332
17333 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
17334         LDKGossipTimestampFilter 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(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17338         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
17339         return ret_arr;
17340 }
17341
17342 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17343         LDKGossipTimestampFilter this_ptr_conv;
17344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17345         this_ptr_conv.is_owned = false;
17346         LDKThirtyTwoBytes val_ref;
17347         CHECK(*((uint32_t*)val) == 32);
17348         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17349         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
17350 }
17351
17352 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
17353         LDKGossipTimestampFilter this_ptr_conv;
17354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17355         this_ptr_conv.is_owned = false;
17356         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
17357         return ret_val;
17358 }
17359
17360 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
17361         LDKGossipTimestampFilter this_ptr_conv;
17362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17363         this_ptr_conv.is_owned = false;
17364         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
17365 }
17366
17367 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
17368         LDKGossipTimestampFilter this_ptr_conv;
17369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17370         this_ptr_conv.is_owned = false;
17371         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
17372         return ret_val;
17373 }
17374
17375 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
17376         LDKGossipTimestampFilter this_ptr_conv;
17377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17378         this_ptr_conv.is_owned = false;
17379         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
17380 }
17381
17382 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
17383         LDKThirtyTwoBytes chain_hash_arg_ref;
17384         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17385         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17386         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
17387         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17388         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17389         uint64_t ret_ref = (uint64_t)ret_var.inner;
17390         if (ret_var.is_owned) {
17391                 ret_ref |= 1;
17392         }
17393         return ret_ref;
17394 }
17395
17396 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
17397         LDKGossipTimestampFilter orig_conv;
17398         orig_conv.inner = (void*)(orig & (~1));
17399         orig_conv.is_owned = false;
17400         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
17401         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17402         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17403         uint64_t ret_ref = (uint64_t)ret_var.inner;
17404         if (ret_var.is_owned) {
17405                 ret_ref |= 1;
17406         }
17407         return ret_ref;
17408 }
17409
17410 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
17411         if ((this_ptr & 1) != 0) return;
17412         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
17413         FREE((void*)this_ptr);
17414         ErrorAction_free(this_ptr_conv);
17415 }
17416
17417 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
17418         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
17419         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
17420         *ret_copy = ErrorAction_clone(orig_conv);
17421         uint64_t ret_ref = (uint64_t)ret_copy;
17422         return ret_ref;
17423 }
17424
17425 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
17426         LDKLightningError this_obj_conv;
17427         this_obj_conv.inner = (void*)(this_obj & (~1));
17428         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17429         LightningError_free(this_obj_conv);
17430 }
17431
17432 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
17433         LDKLightningError this_ptr_conv;
17434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17435         this_ptr_conv.is_owned = false;
17436         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
17437         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17438         return ret_conv;
17439 }
17440
17441 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
17442         LDKLightningError this_ptr_conv;
17443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17444         this_ptr_conv.is_owned = false;
17445         LDKStr val_conv = str_ref_to_owned_c(val);
17446         LightningError_set_err(&this_ptr_conv, val_conv);
17447 }
17448
17449 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
17450         LDKLightningError this_ptr_conv;
17451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17452         this_ptr_conv.is_owned = false;
17453         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
17454         *ret_copy = LightningError_get_action(&this_ptr_conv);
17455         uint64_t ret_ref = (uint64_t)ret_copy;
17456         return ret_ref;
17457 }
17458
17459 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
17460         LDKLightningError this_ptr_conv;
17461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17462         this_ptr_conv.is_owned = false;
17463         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
17464         LightningError_set_action(&this_ptr_conv, val_conv);
17465 }
17466
17467 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
17468         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
17469         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
17470         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
17471         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17472         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17473         uint64_t ret_ref = (uint64_t)ret_var.inner;
17474         if (ret_var.is_owned) {
17475                 ret_ref |= 1;
17476         }
17477         return ret_ref;
17478 }
17479
17480 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
17481         LDKLightningError orig_conv;
17482         orig_conv.inner = (void*)(orig & (~1));
17483         orig_conv.is_owned = false;
17484         LDKLightningError ret_var = LightningError_clone(&orig_conv);
17485         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17486         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17487         uint64_t ret_ref = (uint64_t)ret_var.inner;
17488         if (ret_var.is_owned) {
17489                 ret_ref |= 1;
17490         }
17491         return ret_ref;
17492 }
17493
17494 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
17495         LDKCommitmentUpdate this_obj_conv;
17496         this_obj_conv.inner = (void*)(this_obj & (~1));
17497         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17498         CommitmentUpdate_free(this_obj_conv);
17499 }
17500
17501 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
17502         LDKCommitmentUpdate this_ptr_conv;
17503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17504         this_ptr_conv.is_owned = false;
17505         LDKCVec_UpdateAddHTLCZ val_constr;
17506         val_constr.datalen = *((uint32_t*)val);
17507         if (val_constr.datalen > 0)
17508                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17509         else
17510                 val_constr.data = NULL;
17511         uint32_t* val_vals = (uint32_t*)(val + 4);
17512         for (size_t p = 0; p < val_constr.datalen; p++) {
17513                 uint32_t val_conv_15 = val_vals[p];
17514                 LDKUpdateAddHTLC val_conv_15_conv;
17515                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
17516                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
17517                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
17518                 val_constr.data[p] = val_conv_15_conv;
17519         }
17520         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
17521 }
17522
17523 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
17524         LDKCommitmentUpdate this_ptr_conv;
17525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17526         this_ptr_conv.is_owned = false;
17527         LDKCVec_UpdateFulfillHTLCZ val_constr;
17528         val_constr.datalen = *((uint32_t*)val);
17529         if (val_constr.datalen > 0)
17530                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17531         else
17532                 val_constr.data = NULL;
17533         uint32_t* val_vals = (uint32_t*)(val + 4);
17534         for (size_t t = 0; t < val_constr.datalen; t++) {
17535                 uint32_t val_conv_19 = val_vals[t];
17536                 LDKUpdateFulfillHTLC val_conv_19_conv;
17537                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
17538                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
17539                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
17540                 val_constr.data[t] = val_conv_19_conv;
17541         }
17542         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
17543 }
17544
17545 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
17546         LDKCommitmentUpdate this_ptr_conv;
17547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17548         this_ptr_conv.is_owned = false;
17549         LDKCVec_UpdateFailHTLCZ val_constr;
17550         val_constr.datalen = *((uint32_t*)val);
17551         if (val_constr.datalen > 0)
17552                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17553         else
17554                 val_constr.data = NULL;
17555         uint32_t* val_vals = (uint32_t*)(val + 4);
17556         for (size_t q = 0; q < val_constr.datalen; q++) {
17557                 uint32_t val_conv_16 = val_vals[q];
17558                 LDKUpdateFailHTLC val_conv_16_conv;
17559                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
17560                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
17561                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
17562                 val_constr.data[q] = val_conv_16_conv;
17563         }
17564         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
17565 }
17566
17567 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
17568         LDKCommitmentUpdate this_ptr_conv;
17569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17570         this_ptr_conv.is_owned = false;
17571         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
17572         val_constr.datalen = *((uint32_t*)val);
17573         if (val_constr.datalen > 0)
17574                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17575         else
17576                 val_constr.data = NULL;
17577         uint32_t* val_vals = (uint32_t*)(val + 4);
17578         for (size_t z = 0; z < val_constr.datalen; z++) {
17579                 uint32_t val_conv_25 = val_vals[z];
17580                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
17581                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
17582                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
17583                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
17584                 val_constr.data[z] = val_conv_25_conv;
17585         }
17586         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
17587 }
17588
17589 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
17590         LDKCommitmentUpdate this_ptr_conv;
17591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17592         this_ptr_conv.is_owned = false;
17593         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
17594         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17595         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17596         uint64_t ret_ref = (uint64_t)ret_var.inner;
17597         if (ret_var.is_owned) {
17598                 ret_ref |= 1;
17599         }
17600         return ret_ref;
17601 }
17602
17603 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
17604         LDKCommitmentUpdate this_ptr_conv;
17605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17606         this_ptr_conv.is_owned = false;
17607         LDKUpdateFee val_conv;
17608         val_conv.inner = (void*)(val & (~1));
17609         val_conv.is_owned = (val & 1) || (val == 0);
17610         val_conv = UpdateFee_clone(&val_conv);
17611         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
17612 }
17613
17614 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
17615         LDKCommitmentUpdate this_ptr_conv;
17616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17617         this_ptr_conv.is_owned = false;
17618         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
17619         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17620         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17621         uint64_t ret_ref = (uint64_t)ret_var.inner;
17622         if (ret_var.is_owned) {
17623                 ret_ref |= 1;
17624         }
17625         return ret_ref;
17626 }
17627
17628 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
17629         LDKCommitmentUpdate this_ptr_conv;
17630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17631         this_ptr_conv.is_owned = false;
17632         LDKCommitmentSigned val_conv;
17633         val_conv.inner = (void*)(val & (~1));
17634         val_conv.is_owned = (val & 1) || (val == 0);
17635         val_conv = CommitmentSigned_clone(&val_conv);
17636         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
17637 }
17638
17639 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) {
17640         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
17641         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
17642         if (update_add_htlcs_arg_constr.datalen > 0)
17643                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17644         else
17645                 update_add_htlcs_arg_constr.data = NULL;
17646         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
17647         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
17648                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
17649                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
17650                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
17651                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
17652                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
17653                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
17654         }
17655         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
17656         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
17657         if (update_fulfill_htlcs_arg_constr.datalen > 0)
17658                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17659         else
17660                 update_fulfill_htlcs_arg_constr.data = NULL;
17661         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
17662         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
17663                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
17664                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
17665                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
17666                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
17667                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
17668                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
17669         }
17670         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
17671         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
17672         if (update_fail_htlcs_arg_constr.datalen > 0)
17673                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17674         else
17675                 update_fail_htlcs_arg_constr.data = NULL;
17676         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
17677         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
17678                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
17679                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
17680                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
17681                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
17682                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
17683                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
17684         }
17685         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
17686         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
17687         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
17688                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17689         else
17690                 update_fail_malformed_htlcs_arg_constr.data = NULL;
17691         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
17692         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
17693                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
17694                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
17695                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
17696                 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);
17697                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
17698                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
17699         }
17700         LDKUpdateFee update_fee_arg_conv;
17701         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
17702         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
17703         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
17704         LDKCommitmentSigned commitment_signed_arg_conv;
17705         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
17706         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
17707         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
17708         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);
17709         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17710         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17711         uint64_t ret_ref = (uint64_t)ret_var.inner;
17712         if (ret_var.is_owned) {
17713                 ret_ref |= 1;
17714         }
17715         return ret_ref;
17716 }
17717
17718 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
17719         LDKCommitmentUpdate orig_conv;
17720         orig_conv.inner = (void*)(orig & (~1));
17721         orig_conv.is_owned = false;
17722         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
17723         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17724         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17725         uint64_t ret_ref = (uint64_t)ret_var.inner;
17726         if (ret_var.is_owned) {
17727                 ret_ref |= 1;
17728         }
17729         return ret_ref;
17730 }
17731
17732 void  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) {
17733         if ((this_ptr & 1) != 0) return;
17734         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
17735         FREE((void*)this_ptr);
17736         HTLCFailChannelUpdate_free(this_ptr_conv);
17737 }
17738
17739 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) {
17740         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
17741         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
17742         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
17743         uint64_t ret_ref = (uint64_t)ret_copy;
17744         return ret_ref;
17745 }
17746
17747 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
17748         if ((this_ptr & 1) != 0) return;
17749         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
17750         FREE((void*)this_ptr);
17751         ChannelMessageHandler_free(this_ptr_conv);
17752 }
17753
17754 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
17755         if ((this_ptr & 1) != 0) return;
17756         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
17757         FREE((void*)this_ptr);
17758         RoutingMessageHandler_free(this_ptr_conv);
17759 }
17760
17761 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
17762         LDKAcceptChannel obj_conv;
17763         obj_conv.inner = (void*)(obj & (~1));
17764         obj_conv.is_owned = false;
17765         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
17766         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17767         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17768         CVec_u8Z_free(ret_var);
17769         return ret_arr;
17770 }
17771
17772 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
17773         LDKu8slice ser_ref;
17774         ser_ref.datalen = *((uint32_t*)ser);
17775         ser_ref.data = (int8_t*)(ser + 4);
17776         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17777         *ret_conv = AcceptChannel_read(ser_ref);
17778         return (uint64_t)ret_conv;
17779 }
17780
17781 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
17782         LDKAnnouncementSignatures obj_conv;
17783         obj_conv.inner = (void*)(obj & (~1));
17784         obj_conv.is_owned = false;
17785         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
17786         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17787         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17788         CVec_u8Z_free(ret_var);
17789         return ret_arr;
17790 }
17791
17792 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
17793         LDKu8slice ser_ref;
17794         ser_ref.datalen = *((uint32_t*)ser);
17795         ser_ref.data = (int8_t*)(ser + 4);
17796         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17797         *ret_conv = AnnouncementSignatures_read(ser_ref);
17798         return (uint64_t)ret_conv;
17799 }
17800
17801 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
17802         LDKChannelReestablish obj_conv;
17803         obj_conv.inner = (void*)(obj & (~1));
17804         obj_conv.is_owned = false;
17805         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
17806         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17807         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17808         CVec_u8Z_free(ret_var);
17809         return ret_arr;
17810 }
17811
17812 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
17813         LDKu8slice ser_ref;
17814         ser_ref.datalen = *((uint32_t*)ser);
17815         ser_ref.data = (int8_t*)(ser + 4);
17816         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17817         *ret_conv = ChannelReestablish_read(ser_ref);
17818         return (uint64_t)ret_conv;
17819 }
17820
17821 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
17822         LDKClosingSigned obj_conv;
17823         obj_conv.inner = (void*)(obj & (~1));
17824         obj_conv.is_owned = false;
17825         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
17826         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17827         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17828         CVec_u8Z_free(ret_var);
17829         return ret_arr;
17830 }
17831
17832 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
17833         LDKu8slice ser_ref;
17834         ser_ref.datalen = *((uint32_t*)ser);
17835         ser_ref.data = (int8_t*)(ser + 4);
17836         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17837         *ret_conv = ClosingSigned_read(ser_ref);
17838         return (uint64_t)ret_conv;
17839 }
17840
17841 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
17842         LDKCommitmentSigned obj_conv;
17843         obj_conv.inner = (void*)(obj & (~1));
17844         obj_conv.is_owned = false;
17845         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
17846         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17847         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17848         CVec_u8Z_free(ret_var);
17849         return ret_arr;
17850 }
17851
17852 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
17853         LDKu8slice ser_ref;
17854         ser_ref.datalen = *((uint32_t*)ser);
17855         ser_ref.data = (int8_t*)(ser + 4);
17856         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17857         *ret_conv = CommitmentSigned_read(ser_ref);
17858         return (uint64_t)ret_conv;
17859 }
17860
17861 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
17862         LDKFundingCreated obj_conv;
17863         obj_conv.inner = (void*)(obj & (~1));
17864         obj_conv.is_owned = false;
17865         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
17866         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17867         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17868         CVec_u8Z_free(ret_var);
17869         return ret_arr;
17870 }
17871
17872 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
17873         LDKu8slice ser_ref;
17874         ser_ref.datalen = *((uint32_t*)ser);
17875         ser_ref.data = (int8_t*)(ser + 4);
17876         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17877         *ret_conv = FundingCreated_read(ser_ref);
17878         return (uint64_t)ret_conv;
17879 }
17880
17881 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
17882         LDKFundingSigned obj_conv;
17883         obj_conv.inner = (void*)(obj & (~1));
17884         obj_conv.is_owned = false;
17885         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
17886         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17887         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17888         CVec_u8Z_free(ret_var);
17889         return ret_arr;
17890 }
17891
17892 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
17893         LDKu8slice ser_ref;
17894         ser_ref.datalen = *((uint32_t*)ser);
17895         ser_ref.data = (int8_t*)(ser + 4);
17896         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17897         *ret_conv = FundingSigned_read(ser_ref);
17898         return (uint64_t)ret_conv;
17899 }
17900
17901 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
17902         LDKFundingLocked obj_conv;
17903         obj_conv.inner = (void*)(obj & (~1));
17904         obj_conv.is_owned = false;
17905         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
17906         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17907         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17908         CVec_u8Z_free(ret_var);
17909         return ret_arr;
17910 }
17911
17912 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
17913         LDKu8slice ser_ref;
17914         ser_ref.datalen = *((uint32_t*)ser);
17915         ser_ref.data = (int8_t*)(ser + 4);
17916         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17917         *ret_conv = FundingLocked_read(ser_ref);
17918         return (uint64_t)ret_conv;
17919 }
17920
17921 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
17922         LDKInit obj_conv;
17923         obj_conv.inner = (void*)(obj & (~1));
17924         obj_conv.is_owned = false;
17925         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
17926         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17927         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17928         CVec_u8Z_free(ret_var);
17929         return ret_arr;
17930 }
17931
17932 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
17933         LDKu8slice ser_ref;
17934         ser_ref.datalen = *((uint32_t*)ser);
17935         ser_ref.data = (int8_t*)(ser + 4);
17936         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17937         *ret_conv = Init_read(ser_ref);
17938         return (uint64_t)ret_conv;
17939 }
17940
17941 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
17942         LDKOpenChannel obj_conv;
17943         obj_conv.inner = (void*)(obj & (~1));
17944         obj_conv.is_owned = false;
17945         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
17946         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17947         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17948         CVec_u8Z_free(ret_var);
17949         return ret_arr;
17950 }
17951
17952 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
17953         LDKu8slice ser_ref;
17954         ser_ref.datalen = *((uint32_t*)ser);
17955         ser_ref.data = (int8_t*)(ser + 4);
17956         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17957         *ret_conv = OpenChannel_read(ser_ref);
17958         return (uint64_t)ret_conv;
17959 }
17960
17961 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
17962         LDKRevokeAndACK obj_conv;
17963         obj_conv.inner = (void*)(obj & (~1));
17964         obj_conv.is_owned = false;
17965         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
17966         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17967         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17968         CVec_u8Z_free(ret_var);
17969         return ret_arr;
17970 }
17971
17972 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
17973         LDKu8slice ser_ref;
17974         ser_ref.datalen = *((uint32_t*)ser);
17975         ser_ref.data = (int8_t*)(ser + 4);
17976         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17977         *ret_conv = RevokeAndACK_read(ser_ref);
17978         return (uint64_t)ret_conv;
17979 }
17980
17981 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
17982         LDKShutdown obj_conv;
17983         obj_conv.inner = (void*)(obj & (~1));
17984         obj_conv.is_owned = false;
17985         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
17986         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17987         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17988         CVec_u8Z_free(ret_var);
17989         return ret_arr;
17990 }
17991
17992 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
17993         LDKu8slice ser_ref;
17994         ser_ref.datalen = *((uint32_t*)ser);
17995         ser_ref.data = (int8_t*)(ser + 4);
17996         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17997         *ret_conv = Shutdown_read(ser_ref);
17998         return (uint64_t)ret_conv;
17999 }
18000
18001 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
18002         LDKUpdateFailHTLC obj_conv;
18003         obj_conv.inner = (void*)(obj & (~1));
18004         obj_conv.is_owned = false;
18005         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
18006         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18007         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18008         CVec_u8Z_free(ret_var);
18009         return ret_arr;
18010 }
18011
18012 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
18013         LDKu8slice ser_ref;
18014         ser_ref.datalen = *((uint32_t*)ser);
18015         ser_ref.data = (int8_t*)(ser + 4);
18016         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18017         *ret_conv = UpdateFailHTLC_read(ser_ref);
18018         return (uint64_t)ret_conv;
18019 }
18020
18021 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
18022         LDKUpdateFailMalformedHTLC obj_conv;
18023         obj_conv.inner = (void*)(obj & (~1));
18024         obj_conv.is_owned = false;
18025         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
18026         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18027         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18028         CVec_u8Z_free(ret_var);
18029         return ret_arr;
18030 }
18031
18032 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
18033         LDKu8slice ser_ref;
18034         ser_ref.datalen = *((uint32_t*)ser);
18035         ser_ref.data = (int8_t*)(ser + 4);
18036         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18037         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
18038         return (uint64_t)ret_conv;
18039 }
18040
18041 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
18042         LDKUpdateFee obj_conv;
18043         obj_conv.inner = (void*)(obj & (~1));
18044         obj_conv.is_owned = false;
18045         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
18046         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18047         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18048         CVec_u8Z_free(ret_var);
18049         return ret_arr;
18050 }
18051
18052 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
18053         LDKu8slice ser_ref;
18054         ser_ref.datalen = *((uint32_t*)ser);
18055         ser_ref.data = (int8_t*)(ser + 4);
18056         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18057         *ret_conv = UpdateFee_read(ser_ref);
18058         return (uint64_t)ret_conv;
18059 }
18060
18061 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
18062         LDKUpdateFulfillHTLC obj_conv;
18063         obj_conv.inner = (void*)(obj & (~1));
18064         obj_conv.is_owned = false;
18065         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
18066         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18067         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18068         CVec_u8Z_free(ret_var);
18069         return ret_arr;
18070 }
18071
18072 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
18073         LDKu8slice ser_ref;
18074         ser_ref.datalen = *((uint32_t*)ser);
18075         ser_ref.data = (int8_t*)(ser + 4);
18076         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18077         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
18078         return (uint64_t)ret_conv;
18079 }
18080
18081 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
18082         LDKUpdateAddHTLC obj_conv;
18083         obj_conv.inner = (void*)(obj & (~1));
18084         obj_conv.is_owned = false;
18085         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
18086         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18087         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18088         CVec_u8Z_free(ret_var);
18089         return ret_arr;
18090 }
18091
18092 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
18093         LDKu8slice ser_ref;
18094         ser_ref.datalen = *((uint32_t*)ser);
18095         ser_ref.data = (int8_t*)(ser + 4);
18096         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18097         *ret_conv = UpdateAddHTLC_read(ser_ref);
18098         return (uint64_t)ret_conv;
18099 }
18100
18101 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
18102         LDKPing obj_conv;
18103         obj_conv.inner = (void*)(obj & (~1));
18104         obj_conv.is_owned = false;
18105         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
18106         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18107         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18108         CVec_u8Z_free(ret_var);
18109         return ret_arr;
18110 }
18111
18112 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
18113         LDKu8slice ser_ref;
18114         ser_ref.datalen = *((uint32_t*)ser);
18115         ser_ref.data = (int8_t*)(ser + 4);
18116         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18117         *ret_conv = Ping_read(ser_ref);
18118         return (uint64_t)ret_conv;
18119 }
18120
18121 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
18122         LDKPong obj_conv;
18123         obj_conv.inner = (void*)(obj & (~1));
18124         obj_conv.is_owned = false;
18125         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
18126         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18127         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18128         CVec_u8Z_free(ret_var);
18129         return ret_arr;
18130 }
18131
18132 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
18133         LDKu8slice ser_ref;
18134         ser_ref.datalen = *((uint32_t*)ser);
18135         ser_ref.data = (int8_t*)(ser + 4);
18136         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18137         *ret_conv = Pong_read(ser_ref);
18138         return (uint64_t)ret_conv;
18139 }
18140
18141 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
18142         LDKUnsignedChannelAnnouncement obj_conv;
18143         obj_conv.inner = (void*)(obj & (~1));
18144         obj_conv.is_owned = false;
18145         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
18146         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18147         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18148         CVec_u8Z_free(ret_var);
18149         return ret_arr;
18150 }
18151
18152 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
18153         LDKu8slice ser_ref;
18154         ser_ref.datalen = *((uint32_t*)ser);
18155         ser_ref.data = (int8_t*)(ser + 4);
18156         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18157         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
18158         return (uint64_t)ret_conv;
18159 }
18160
18161 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
18162         LDKChannelAnnouncement obj_conv;
18163         obj_conv.inner = (void*)(obj & (~1));
18164         obj_conv.is_owned = false;
18165         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
18166         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18167         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18168         CVec_u8Z_free(ret_var);
18169         return ret_arr;
18170 }
18171
18172 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
18173         LDKu8slice ser_ref;
18174         ser_ref.datalen = *((uint32_t*)ser);
18175         ser_ref.data = (int8_t*)(ser + 4);
18176         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18177         *ret_conv = ChannelAnnouncement_read(ser_ref);
18178         return (uint64_t)ret_conv;
18179 }
18180
18181 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
18182         LDKUnsignedChannelUpdate obj_conv;
18183         obj_conv.inner = (void*)(obj & (~1));
18184         obj_conv.is_owned = false;
18185         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
18186         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18187         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18188         CVec_u8Z_free(ret_var);
18189         return ret_arr;
18190 }
18191
18192 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
18193         LDKu8slice ser_ref;
18194         ser_ref.datalen = *((uint32_t*)ser);
18195         ser_ref.data = (int8_t*)(ser + 4);
18196         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18197         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
18198         return (uint64_t)ret_conv;
18199 }
18200
18201 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
18202         LDKChannelUpdate obj_conv;
18203         obj_conv.inner = (void*)(obj & (~1));
18204         obj_conv.is_owned = false;
18205         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
18206         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18207         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18208         CVec_u8Z_free(ret_var);
18209         return ret_arr;
18210 }
18211
18212 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
18213         LDKu8slice ser_ref;
18214         ser_ref.datalen = *((uint32_t*)ser);
18215         ser_ref.data = (int8_t*)(ser + 4);
18216         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18217         *ret_conv = ChannelUpdate_read(ser_ref);
18218         return (uint64_t)ret_conv;
18219 }
18220
18221 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
18222         LDKErrorMessage obj_conv;
18223         obj_conv.inner = (void*)(obj & (~1));
18224         obj_conv.is_owned = false;
18225         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
18226         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18227         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18228         CVec_u8Z_free(ret_var);
18229         return ret_arr;
18230 }
18231
18232 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
18233         LDKu8slice ser_ref;
18234         ser_ref.datalen = *((uint32_t*)ser);
18235         ser_ref.data = (int8_t*)(ser + 4);
18236         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18237         *ret_conv = ErrorMessage_read(ser_ref);
18238         return (uint64_t)ret_conv;
18239 }
18240
18241 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
18242         LDKUnsignedNodeAnnouncement obj_conv;
18243         obj_conv.inner = (void*)(obj & (~1));
18244         obj_conv.is_owned = false;
18245         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
18246         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18247         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18248         CVec_u8Z_free(ret_var);
18249         return ret_arr;
18250 }
18251
18252 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
18253         LDKu8slice ser_ref;
18254         ser_ref.datalen = *((uint32_t*)ser);
18255         ser_ref.data = (int8_t*)(ser + 4);
18256         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18257         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
18258         return (uint64_t)ret_conv;
18259 }
18260
18261 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
18262         LDKNodeAnnouncement obj_conv;
18263         obj_conv.inner = (void*)(obj & (~1));
18264         obj_conv.is_owned = false;
18265         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
18266         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18267         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18268         CVec_u8Z_free(ret_var);
18269         return ret_arr;
18270 }
18271
18272 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
18273         LDKu8slice ser_ref;
18274         ser_ref.datalen = *((uint32_t*)ser);
18275         ser_ref.data = (int8_t*)(ser + 4);
18276         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18277         *ret_conv = NodeAnnouncement_read(ser_ref);
18278         return (uint64_t)ret_conv;
18279 }
18280
18281 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
18282         LDKu8slice ser_ref;
18283         ser_ref.datalen = *((uint32_t*)ser);
18284         ser_ref.data = (int8_t*)(ser + 4);
18285         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18286         *ret_conv = QueryShortChannelIds_read(ser_ref);
18287         return (uint64_t)ret_conv;
18288 }
18289
18290 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
18291         LDKQueryShortChannelIds obj_conv;
18292         obj_conv.inner = (void*)(obj & (~1));
18293         obj_conv.is_owned = false;
18294         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
18295         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18296         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18297         CVec_u8Z_free(ret_var);
18298         return ret_arr;
18299 }
18300
18301 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
18302         LDKu8slice ser_ref;
18303         ser_ref.datalen = *((uint32_t*)ser);
18304         ser_ref.data = (int8_t*)(ser + 4);
18305         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18306         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
18307         return (uint64_t)ret_conv;
18308 }
18309
18310 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
18311         LDKReplyShortChannelIdsEnd obj_conv;
18312         obj_conv.inner = (void*)(obj & (~1));
18313         obj_conv.is_owned = false;
18314         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
18315         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18316         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18317         CVec_u8Z_free(ret_var);
18318         return ret_arr;
18319 }
18320
18321 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
18322         LDKQueryChannelRange this_arg_conv;
18323         this_arg_conv.inner = (void*)(this_arg & (~1));
18324         this_arg_conv.is_owned = false;
18325         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
18326         return ret_val;
18327 }
18328
18329 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
18330         LDKu8slice ser_ref;
18331         ser_ref.datalen = *((uint32_t*)ser);
18332         ser_ref.data = (int8_t*)(ser + 4);
18333         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18334         *ret_conv = QueryChannelRange_read(ser_ref);
18335         return (uint64_t)ret_conv;
18336 }
18337
18338 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
18339         LDKQueryChannelRange obj_conv;
18340         obj_conv.inner = (void*)(obj & (~1));
18341         obj_conv.is_owned = false;
18342         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
18343         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18344         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18345         CVec_u8Z_free(ret_var);
18346         return ret_arr;
18347 }
18348
18349 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
18350         LDKu8slice ser_ref;
18351         ser_ref.datalen = *((uint32_t*)ser);
18352         ser_ref.data = (int8_t*)(ser + 4);
18353         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18354         *ret_conv = ReplyChannelRange_read(ser_ref);
18355         return (uint64_t)ret_conv;
18356 }
18357
18358 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
18359         LDKReplyChannelRange obj_conv;
18360         obj_conv.inner = (void*)(obj & (~1));
18361         obj_conv.is_owned = false;
18362         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
18363         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18364         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18365         CVec_u8Z_free(ret_var);
18366         return ret_arr;
18367 }
18368
18369 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
18370         LDKu8slice ser_ref;
18371         ser_ref.datalen = *((uint32_t*)ser);
18372         ser_ref.data = (int8_t*)(ser + 4);
18373         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18374         *ret_conv = GossipTimestampFilter_read(ser_ref);
18375         return (uint64_t)ret_conv;
18376 }
18377
18378 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
18379         LDKGossipTimestampFilter obj_conv;
18380         obj_conv.inner = (void*)(obj & (~1));
18381         obj_conv.is_owned = false;
18382         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
18383         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18384         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18385         CVec_u8Z_free(ret_var);
18386         return ret_arr;
18387 }
18388
18389 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
18390         LDKIgnoringMessageHandler this_obj_conv;
18391         this_obj_conv.inner = (void*)(this_obj & (~1));
18392         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18393         IgnoringMessageHandler_free(this_obj_conv);
18394 }
18395
18396 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
18397         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
18398         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18399         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18400         uint64_t ret_ref = (uint64_t)ret_var.inner;
18401         if (ret_var.is_owned) {
18402                 ret_ref |= 1;
18403         }
18404         return ret_ref;
18405 }
18406
18407 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
18408         LDKIgnoringMessageHandler this_arg_conv;
18409         this_arg_conv.inner = (void*)(this_arg & (~1));
18410         this_arg_conv.is_owned = false;
18411         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18412         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
18413         return (uint64_t)ret;
18414 }
18415
18416 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
18417         LDKIgnoringMessageHandler this_arg_conv;
18418         this_arg_conv.inner = (void*)(this_arg & (~1));
18419         this_arg_conv.is_owned = false;
18420         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
18421         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
18422         return (uint64_t)ret;
18423 }
18424
18425 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
18426         LDKErroringMessageHandler this_obj_conv;
18427         this_obj_conv.inner = (void*)(this_obj & (~1));
18428         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18429         ErroringMessageHandler_free(this_obj_conv);
18430 }
18431
18432 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
18433         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
18434         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18435         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18436         uint64_t ret_ref = (uint64_t)ret_var.inner;
18437         if (ret_var.is_owned) {
18438                 ret_ref |= 1;
18439         }
18440         return ret_ref;
18441 }
18442
18443 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
18444         LDKErroringMessageHandler this_arg_conv;
18445         this_arg_conv.inner = (void*)(this_arg & (~1));
18446         this_arg_conv.is_owned = false;
18447         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18448         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
18449         return (uint64_t)ret;
18450 }
18451
18452 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
18453         LDKErroringMessageHandler this_arg_conv;
18454         this_arg_conv.inner = (void*)(this_arg & (~1));
18455         this_arg_conv.is_owned = false;
18456         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
18457         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
18458         return (uint64_t)ret;
18459 }
18460
18461 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
18462         LDKMessageHandler this_obj_conv;
18463         this_obj_conv.inner = (void*)(this_obj & (~1));
18464         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18465         MessageHandler_free(this_obj_conv);
18466 }
18467
18468 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
18469         LDKMessageHandler this_ptr_conv;
18470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18471         this_ptr_conv.is_owned = false;
18472         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
18473         return ret_ret;
18474 }
18475
18476 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
18477         LDKMessageHandler this_ptr_conv;
18478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18479         this_ptr_conv.is_owned = false;
18480         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
18481         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
18482 }
18483
18484 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
18485         LDKMessageHandler this_ptr_conv;
18486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18487         this_ptr_conv.is_owned = false;
18488         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
18489         return ret_ret;
18490 }
18491
18492 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
18493         LDKMessageHandler this_ptr_conv;
18494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18495         this_ptr_conv.is_owned = false;
18496         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
18497         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
18498 }
18499
18500 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
18501         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
18502         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
18503         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
18504         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18505         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18506         uint64_t ret_ref = (uint64_t)ret_var.inner;
18507         if (ret_var.is_owned) {
18508                 ret_ref |= 1;
18509         }
18510         return ret_ref;
18511 }
18512
18513 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
18514         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
18515         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
18516         *ret = SocketDescriptor_clone(orig_conv);
18517         return (uint64_t)ret;
18518 }
18519
18520 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
18521         if ((this_ptr & 1) != 0) return;
18522         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
18523         FREE((void*)this_ptr);
18524         SocketDescriptor_free(this_ptr_conv);
18525 }
18526
18527 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
18528         LDKPeerHandleError this_obj_conv;
18529         this_obj_conv.inner = (void*)(this_obj & (~1));
18530         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18531         PeerHandleError_free(this_obj_conv);
18532 }
18533
18534 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
18535         LDKPeerHandleError this_ptr_conv;
18536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18537         this_ptr_conv.is_owned = false;
18538         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
18539         return ret_val;
18540 }
18541
18542 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
18543         LDKPeerHandleError this_ptr_conv;
18544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18545         this_ptr_conv.is_owned = false;
18546         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
18547 }
18548
18549 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
18550         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
18551         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18552         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18553         uint64_t ret_ref = (uint64_t)ret_var.inner;
18554         if (ret_var.is_owned) {
18555                 ret_ref |= 1;
18556         }
18557         return ret_ref;
18558 }
18559
18560 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
18561         LDKPeerHandleError orig_conv;
18562         orig_conv.inner = (void*)(orig & (~1));
18563         orig_conv.is_owned = false;
18564         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
18565         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18566         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18567         uint64_t ret_ref = (uint64_t)ret_var.inner;
18568         if (ret_var.is_owned) {
18569                 ret_ref |= 1;
18570         }
18571         return ret_ref;
18572 }
18573
18574 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
18575         LDKPeerManager this_obj_conv;
18576         this_obj_conv.inner = (void*)(this_obj & (~1));
18577         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18578         PeerManager_free(this_obj_conv);
18579 }
18580
18581 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) {
18582         LDKMessageHandler message_handler_conv;
18583         message_handler_conv.inner = (void*)(message_handler & (~1));
18584         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
18585         // Warning: we need a move here but no clone is available for LDKMessageHandler
18586         LDKSecretKey our_node_secret_ref;
18587         CHECK(*((uint32_t*)our_node_secret) == 32);
18588         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
18589         unsigned char ephemeral_random_data_arr[32];
18590         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
18591         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
18592         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
18593         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18594         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
18595         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18596         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18597         uint64_t ret_ref = (uint64_t)ret_var.inner;
18598         if (ret_var.is_owned) {
18599                 ret_ref |= 1;
18600         }
18601         return ret_ref;
18602 }
18603
18604 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
18605         LDKPeerManager this_arg_conv;
18606         this_arg_conv.inner = (void*)(this_arg & (~1));
18607         this_arg_conv.is_owned = false;
18608         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
18609         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
18610         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
18611         for (size_t m = 0; m < ret_var.datalen; m++) {
18612                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18613                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
18614                 ret_arr_ptr[m] = ret_conv_12_arr;
18615         }
18616         FREE(ret_var.data);
18617         return ret_arr;
18618 }
18619
18620 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
18621         LDKPeerManager this_arg_conv;
18622         this_arg_conv.inner = (void*)(this_arg & (~1));
18623         this_arg_conv.is_owned = false;
18624         LDKPublicKey their_node_id_ref;
18625         CHECK(*((uint32_t*)their_node_id) == 33);
18626         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
18627         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18628         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18629         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
18630         return (uint64_t)ret_conv;
18631 }
18632
18633 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
18634         LDKPeerManager this_arg_conv;
18635         this_arg_conv.inner = (void*)(this_arg & (~1));
18636         this_arg_conv.is_owned = false;
18637         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18638         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18639         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
18640         return (uint64_t)ret_conv;
18641 }
18642
18643 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
18644         LDKPeerManager this_arg_conv;
18645         this_arg_conv.inner = (void*)(this_arg & (~1));
18646         this_arg_conv.is_owned = false;
18647         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18648         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18649         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
18650         return (uint64_t)ret_conv;
18651 }
18652
18653 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
18654         LDKPeerManager this_arg_conv;
18655         this_arg_conv.inner = (void*)(this_arg & (~1));
18656         this_arg_conv.is_owned = false;
18657         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
18658         LDKu8slice data_ref;
18659         data_ref.datalen = *((uint32_t*)data);
18660         data_ref.data = (int8_t*)(data + 4);
18661         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18662         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
18663         return (uint64_t)ret_conv;
18664 }
18665
18666 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
18667         LDKPeerManager this_arg_conv;
18668         this_arg_conv.inner = (void*)(this_arg & (~1));
18669         this_arg_conv.is_owned = false;
18670         PeerManager_process_events(&this_arg_conv);
18671 }
18672
18673 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
18674         LDKPeerManager this_arg_conv;
18675         this_arg_conv.inner = (void*)(this_arg & (~1));
18676         this_arg_conv.is_owned = false;
18677         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18678         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
18679 }
18680
18681 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
18682         LDKPeerManager this_arg_conv;
18683         this_arg_conv.inner = (void*)(this_arg & (~1));
18684         this_arg_conv.is_owned = false;
18685         LDKPublicKey node_id_ref;
18686         CHECK(*((uint32_t*)node_id) == 33);
18687         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
18688         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
18689 }
18690
18691 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
18692         LDKPeerManager this_arg_conv;
18693         this_arg_conv.inner = (void*)(this_arg & (~1));
18694         this_arg_conv.is_owned = false;
18695         PeerManager_timer_tick_occurred(&this_arg_conv);
18696 }
18697
18698 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
18699         unsigned char commitment_seed_arr[32];
18700         CHECK(*((uint32_t*)commitment_seed) == 32);
18701         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
18702         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
18703         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18704         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
18705         return ret_arr;
18706 }
18707
18708 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
18709         LDKPublicKey per_commitment_point_ref;
18710         CHECK(*((uint32_t*)per_commitment_point) == 33);
18711         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18712         unsigned char base_secret_arr[32];
18713         CHECK(*((uint32_t*)base_secret) == 32);
18714         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
18715         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
18716         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
18717         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
18718         return (uint64_t)ret_conv;
18719 }
18720
18721 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
18722         LDKPublicKey per_commitment_point_ref;
18723         CHECK(*((uint32_t*)per_commitment_point) == 33);
18724         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18725         LDKPublicKey base_point_ref;
18726         CHECK(*((uint32_t*)base_point) == 33);
18727         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
18728         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
18729         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
18730         return (uint64_t)ret_conv;
18731 }
18732
18733 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
18734         unsigned char per_commitment_secret_arr[32];
18735         CHECK(*((uint32_t*)per_commitment_secret) == 32);
18736         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
18737         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
18738         unsigned char countersignatory_revocation_base_secret_arr[32];
18739         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
18740         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
18741         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
18742         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
18743         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
18744         return (uint64_t)ret_conv;
18745 }
18746
18747 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
18748         LDKPublicKey per_commitment_point_ref;
18749         CHECK(*((uint32_t*)per_commitment_point) == 33);
18750         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18751         LDKPublicKey countersignatory_revocation_base_point_ref;
18752         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
18753         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
18754         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
18755         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
18756         return (uint64_t)ret_conv;
18757 }
18758
18759 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
18760         LDKTxCreationKeys this_obj_conv;
18761         this_obj_conv.inner = (void*)(this_obj & (~1));
18762         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18763         TxCreationKeys_free(this_obj_conv);
18764 }
18765
18766 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
18767         LDKTxCreationKeys this_ptr_conv;
18768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18769         this_ptr_conv.is_owned = false;
18770         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18771         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
18772         return ret_arr;
18773 }
18774
18775 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
18776         LDKTxCreationKeys this_ptr_conv;
18777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18778         this_ptr_conv.is_owned = false;
18779         LDKPublicKey val_ref;
18780         CHECK(*((uint32_t*)val) == 33);
18781         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18782         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
18783 }
18784
18785 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
18786         LDKTxCreationKeys this_ptr_conv;
18787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18788         this_ptr_conv.is_owned = false;
18789         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18790         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
18791         return ret_arr;
18792 }
18793
18794 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
18795         LDKTxCreationKeys this_ptr_conv;
18796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18797         this_ptr_conv.is_owned = false;
18798         LDKPublicKey val_ref;
18799         CHECK(*((uint32_t*)val) == 33);
18800         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18801         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
18802 }
18803
18804 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
18805         LDKTxCreationKeys this_ptr_conv;
18806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18807         this_ptr_conv.is_owned = false;
18808         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18809         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
18810         return ret_arr;
18811 }
18812
18813 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
18814         LDKTxCreationKeys this_ptr_conv;
18815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18816         this_ptr_conv.is_owned = false;
18817         LDKPublicKey val_ref;
18818         CHECK(*((uint32_t*)val) == 33);
18819         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18820         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
18821 }
18822
18823 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
18824         LDKTxCreationKeys this_ptr_conv;
18825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18826         this_ptr_conv.is_owned = false;
18827         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18828         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
18829         return ret_arr;
18830 }
18831
18832 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
18833         LDKTxCreationKeys this_ptr_conv;
18834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18835         this_ptr_conv.is_owned = false;
18836         LDKPublicKey val_ref;
18837         CHECK(*((uint32_t*)val) == 33);
18838         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18839         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
18840 }
18841
18842 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
18843         LDKTxCreationKeys this_ptr_conv;
18844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18845         this_ptr_conv.is_owned = false;
18846         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18847         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
18848         return ret_arr;
18849 }
18850
18851 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
18852         LDKTxCreationKeys this_ptr_conv;
18853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18854         this_ptr_conv.is_owned = false;
18855         LDKPublicKey val_ref;
18856         CHECK(*((uint32_t*)val) == 33);
18857         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18858         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
18859 }
18860
18861 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) {
18862         LDKPublicKey per_commitment_point_arg_ref;
18863         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
18864         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
18865         LDKPublicKey revocation_key_arg_ref;
18866         CHECK(*((uint32_t*)revocation_key_arg) == 33);
18867         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
18868         LDKPublicKey broadcaster_htlc_key_arg_ref;
18869         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
18870         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
18871         LDKPublicKey countersignatory_htlc_key_arg_ref;
18872         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
18873         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
18874         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
18875         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
18876         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
18877         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);
18878         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18879         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18880         uint64_t ret_ref = (uint64_t)ret_var.inner;
18881         if (ret_var.is_owned) {
18882                 ret_ref |= 1;
18883         }
18884         return ret_ref;
18885 }
18886
18887 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
18888         LDKTxCreationKeys orig_conv;
18889         orig_conv.inner = (void*)(orig & (~1));
18890         orig_conv.is_owned = false;
18891         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
18892         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18893         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18894         uint64_t ret_ref = (uint64_t)ret_var.inner;
18895         if (ret_var.is_owned) {
18896                 ret_ref |= 1;
18897         }
18898         return ret_ref;
18899 }
18900
18901 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
18902         LDKTxCreationKeys obj_conv;
18903         obj_conv.inner = (void*)(obj & (~1));
18904         obj_conv.is_owned = false;
18905         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
18906         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18907         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18908         CVec_u8Z_free(ret_var);
18909         return ret_arr;
18910 }
18911
18912 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
18913         LDKu8slice ser_ref;
18914         ser_ref.datalen = *((uint32_t*)ser);
18915         ser_ref.data = (int8_t*)(ser + 4);
18916         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
18917         *ret_conv = TxCreationKeys_read(ser_ref);
18918         return (uint64_t)ret_conv;
18919 }
18920
18921 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
18922         LDKChannelPublicKeys this_obj_conv;
18923         this_obj_conv.inner = (void*)(this_obj & (~1));
18924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18925         ChannelPublicKeys_free(this_obj_conv);
18926 }
18927
18928 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
18929         LDKChannelPublicKeys this_ptr_conv;
18930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18931         this_ptr_conv.is_owned = false;
18932         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18933         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
18934         return ret_arr;
18935 }
18936
18937 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
18938         LDKChannelPublicKeys this_ptr_conv;
18939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18940         this_ptr_conv.is_owned = false;
18941         LDKPublicKey val_ref;
18942         CHECK(*((uint32_t*)val) == 33);
18943         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18944         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
18945 }
18946
18947 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
18948         LDKChannelPublicKeys this_ptr_conv;
18949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18950         this_ptr_conv.is_owned = false;
18951         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18952         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
18953         return ret_arr;
18954 }
18955
18956 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
18957         LDKChannelPublicKeys this_ptr_conv;
18958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18959         this_ptr_conv.is_owned = false;
18960         LDKPublicKey val_ref;
18961         CHECK(*((uint32_t*)val) == 33);
18962         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18963         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
18964 }
18965
18966 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
18967         LDKChannelPublicKeys this_ptr_conv;
18968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18969         this_ptr_conv.is_owned = false;
18970         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18971         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
18972         return ret_arr;
18973 }
18974
18975 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
18976         LDKChannelPublicKeys this_ptr_conv;
18977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18978         this_ptr_conv.is_owned = false;
18979         LDKPublicKey val_ref;
18980         CHECK(*((uint32_t*)val) == 33);
18981         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18982         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
18983 }
18984
18985 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
18986         LDKChannelPublicKeys this_ptr_conv;
18987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18988         this_ptr_conv.is_owned = false;
18989         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18990         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
18991         return ret_arr;
18992 }
18993
18994 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
18995         LDKChannelPublicKeys this_ptr_conv;
18996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18997         this_ptr_conv.is_owned = false;
18998         LDKPublicKey val_ref;
18999         CHECK(*((uint32_t*)val) == 33);
19000         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19001         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
19002 }
19003
19004 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
19005         LDKChannelPublicKeys this_ptr_conv;
19006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19007         this_ptr_conv.is_owned = false;
19008         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19009         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
19010         return ret_arr;
19011 }
19012
19013 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
19014         LDKChannelPublicKeys this_ptr_conv;
19015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19016         this_ptr_conv.is_owned = false;
19017         LDKPublicKey val_ref;
19018         CHECK(*((uint32_t*)val) == 33);
19019         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19020         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
19021 }
19022
19023 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) {
19024         LDKPublicKey funding_pubkey_arg_ref;
19025         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
19026         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
19027         LDKPublicKey revocation_basepoint_arg_ref;
19028         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
19029         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
19030         LDKPublicKey payment_point_arg_ref;
19031         CHECK(*((uint32_t*)payment_point_arg) == 33);
19032         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
19033         LDKPublicKey delayed_payment_basepoint_arg_ref;
19034         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
19035         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
19036         LDKPublicKey htlc_basepoint_arg_ref;
19037         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
19038         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
19039         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);
19040         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19041         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19042         uint64_t ret_ref = (uint64_t)ret_var.inner;
19043         if (ret_var.is_owned) {
19044                 ret_ref |= 1;
19045         }
19046         return ret_ref;
19047 }
19048
19049 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
19050         LDKChannelPublicKeys orig_conv;
19051         orig_conv.inner = (void*)(orig & (~1));
19052         orig_conv.is_owned = false;
19053         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
19054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19056         uint64_t ret_ref = (uint64_t)ret_var.inner;
19057         if (ret_var.is_owned) {
19058                 ret_ref |= 1;
19059         }
19060         return ret_ref;
19061 }
19062
19063 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
19064         LDKChannelPublicKeys obj_conv;
19065         obj_conv.inner = (void*)(obj & (~1));
19066         obj_conv.is_owned = false;
19067         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
19068         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19069         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19070         CVec_u8Z_free(ret_var);
19071         return ret_arr;
19072 }
19073
19074 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
19075         LDKu8slice ser_ref;
19076         ser_ref.datalen = *((uint32_t*)ser);
19077         ser_ref.data = (int8_t*)(ser + 4);
19078         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
19079         *ret_conv = ChannelPublicKeys_read(ser_ref);
19080         return (uint64_t)ret_conv;
19081 }
19082
19083 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) {
19084         LDKPublicKey per_commitment_point_ref;
19085         CHECK(*((uint32_t*)per_commitment_point) == 33);
19086         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
19087         LDKPublicKey broadcaster_delayed_payment_base_ref;
19088         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
19089         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
19090         LDKPublicKey broadcaster_htlc_base_ref;
19091         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
19092         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
19093         LDKPublicKey countersignatory_revocation_base_ref;
19094         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
19095         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
19096         LDKPublicKey countersignatory_htlc_base_ref;
19097         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
19098         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
19099         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
19100         *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);
19101         return (uint64_t)ret_conv;
19102 }
19103
19104 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
19105         LDKPublicKey per_commitment_point_ref;
19106         CHECK(*((uint32_t*)per_commitment_point) == 33);
19107         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
19108         LDKChannelPublicKeys broadcaster_keys_conv;
19109         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
19110         broadcaster_keys_conv.is_owned = false;
19111         LDKChannelPublicKeys countersignatory_keys_conv;
19112         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
19113         countersignatory_keys_conv.is_owned = false;
19114         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
19115         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
19116         return (uint64_t)ret_conv;
19117 }
19118
19119 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
19120         LDKPublicKey revocation_key_ref;
19121         CHECK(*((uint32_t*)revocation_key) == 33);
19122         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
19123         LDKPublicKey broadcaster_delayed_payment_key_ref;
19124         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
19125         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
19126         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
19127         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19128         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19129         CVec_u8Z_free(ret_var);
19130         return ret_arr;
19131 }
19132
19133 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
19134         LDKHTLCOutputInCommitment this_obj_conv;
19135         this_obj_conv.inner = (void*)(this_obj & (~1));
19136         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19137         HTLCOutputInCommitment_free(this_obj_conv);
19138 }
19139
19140 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
19141         LDKHTLCOutputInCommitment this_ptr_conv;
19142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19143         this_ptr_conv.is_owned = false;
19144         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
19145         return ret_val;
19146 }
19147
19148 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
19149         LDKHTLCOutputInCommitment this_ptr_conv;
19150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19151         this_ptr_conv.is_owned = false;
19152         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
19153 }
19154
19155 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
19156         LDKHTLCOutputInCommitment this_ptr_conv;
19157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19158         this_ptr_conv.is_owned = false;
19159         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
19160         return ret_val;
19161 }
19162
19163 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
19164         LDKHTLCOutputInCommitment this_ptr_conv;
19165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19166         this_ptr_conv.is_owned = false;
19167         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
19168 }
19169
19170 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
19171         LDKHTLCOutputInCommitment this_ptr_conv;
19172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19173         this_ptr_conv.is_owned = false;
19174         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
19175         return ret_val;
19176 }
19177
19178 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
19179         LDKHTLCOutputInCommitment this_ptr_conv;
19180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19181         this_ptr_conv.is_owned = false;
19182         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
19183 }
19184
19185 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
19186         LDKHTLCOutputInCommitment this_ptr_conv;
19187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19188         this_ptr_conv.is_owned = false;
19189         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19190         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
19191         return ret_arr;
19192 }
19193
19194 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
19195         LDKHTLCOutputInCommitment this_ptr_conv;
19196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19197         this_ptr_conv.is_owned = false;
19198         LDKThirtyTwoBytes val_ref;
19199         CHECK(*((uint32_t*)val) == 32);
19200         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19201         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
19202 }
19203
19204 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
19205         LDKHTLCOutputInCommitment this_ptr_conv;
19206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19207         this_ptr_conv.is_owned = false;
19208         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
19209         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
19210         uint64_t ret_ref = (uint64_t)ret_copy;
19211         return ret_ref;
19212 }
19213
19214 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
19215         LDKHTLCOutputInCommitment this_ptr_conv;
19216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19217         this_ptr_conv.is_owned = false;
19218         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
19219         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
19220 }
19221
19222 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) {
19223         LDKThirtyTwoBytes payment_hash_arg_ref;
19224         CHECK(*((uint32_t*)payment_hash_arg) == 32);
19225         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
19226         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
19227         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
19228         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19229         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19230         uint64_t ret_ref = (uint64_t)ret_var.inner;
19231         if (ret_var.is_owned) {
19232                 ret_ref |= 1;
19233         }
19234         return ret_ref;
19235 }
19236
19237 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
19238         LDKHTLCOutputInCommitment orig_conv;
19239         orig_conv.inner = (void*)(orig & (~1));
19240         orig_conv.is_owned = false;
19241         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
19242         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19243         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19244         uint64_t ret_ref = (uint64_t)ret_var.inner;
19245         if (ret_var.is_owned) {
19246                 ret_ref |= 1;
19247         }
19248         return ret_ref;
19249 }
19250
19251 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
19252         LDKHTLCOutputInCommitment obj_conv;
19253         obj_conv.inner = (void*)(obj & (~1));
19254         obj_conv.is_owned = false;
19255         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
19256         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19257         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19258         CVec_u8Z_free(ret_var);
19259         return ret_arr;
19260 }
19261
19262 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
19263         LDKu8slice ser_ref;
19264         ser_ref.datalen = *((uint32_t*)ser);
19265         ser_ref.data = (int8_t*)(ser + 4);
19266         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
19267         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
19268         return (uint64_t)ret_conv;
19269 }
19270
19271 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
19272         LDKHTLCOutputInCommitment htlc_conv;
19273         htlc_conv.inner = (void*)(htlc & (~1));
19274         htlc_conv.is_owned = false;
19275         LDKTxCreationKeys keys_conv;
19276         keys_conv.inner = (void*)(keys & (~1));
19277         keys_conv.is_owned = false;
19278         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
19279         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19280         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19281         CVec_u8Z_free(ret_var);
19282         return ret_arr;
19283 }
19284
19285 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
19286         LDKPublicKey broadcaster_ref;
19287         CHECK(*((uint32_t*)broadcaster) == 33);
19288         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
19289         LDKPublicKey countersignatory_ref;
19290         CHECK(*((uint32_t*)countersignatory) == 33);
19291         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
19292         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
19293         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19294         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19295         CVec_u8Z_free(ret_var);
19296         return ret_arr;
19297 }
19298
19299 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) {
19300         unsigned char commitment_txid_arr[32];
19301         CHECK(*((uint32_t*)commitment_txid) == 32);
19302         memcpy(commitment_txid_arr, (uint8_t*)(commitment_txid + 4), 32);
19303         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
19304         LDKHTLCOutputInCommitment htlc_conv;
19305         htlc_conv.inner = (void*)(htlc & (~1));
19306         htlc_conv.is_owned = false;
19307         LDKPublicKey broadcaster_delayed_payment_key_ref;
19308         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
19309         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
19310         LDKPublicKey revocation_key_ref;
19311         CHECK(*((uint32_t*)revocation_key) == 33);
19312         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
19313         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
19314         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19315         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19316         Transaction_free(ret_var);
19317         return ret_arr;
19318 }
19319
19320 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
19321         LDKChannelTransactionParameters this_obj_conv;
19322         this_obj_conv.inner = (void*)(this_obj & (~1));
19323         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19324         ChannelTransactionParameters_free(this_obj_conv);
19325 }
19326
19327 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
19328         LDKChannelTransactionParameters this_ptr_conv;
19329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19330         this_ptr_conv.is_owned = false;
19331         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
19332         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19333         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19334         uint64_t ret_ref = (uint64_t)ret_var.inner;
19335         if (ret_var.is_owned) {
19336                 ret_ref |= 1;
19337         }
19338         return ret_ref;
19339 }
19340
19341 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
19342         LDKChannelTransactionParameters this_ptr_conv;
19343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19344         this_ptr_conv.is_owned = false;
19345         LDKChannelPublicKeys val_conv;
19346         val_conv.inner = (void*)(val & (~1));
19347         val_conv.is_owned = (val & 1) || (val == 0);
19348         val_conv = ChannelPublicKeys_clone(&val_conv);
19349         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
19350 }
19351
19352 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
19353         LDKChannelTransactionParameters this_ptr_conv;
19354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19355         this_ptr_conv.is_owned = false;
19356         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
19357         return ret_val;
19358 }
19359
19360 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
19361         LDKChannelTransactionParameters this_ptr_conv;
19362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19363         this_ptr_conv.is_owned = false;
19364         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
19365 }
19366
19367 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
19368         LDKChannelTransactionParameters this_ptr_conv;
19369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19370         this_ptr_conv.is_owned = false;
19371         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
19372         return ret_val;
19373 }
19374
19375 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
19376         LDKChannelTransactionParameters this_ptr_conv;
19377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19378         this_ptr_conv.is_owned = false;
19379         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
19380 }
19381
19382 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
19383         LDKChannelTransactionParameters this_ptr_conv;
19384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19385         this_ptr_conv.is_owned = false;
19386         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
19387         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19388         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19389         uint64_t ret_ref = (uint64_t)ret_var.inner;
19390         if (ret_var.is_owned) {
19391                 ret_ref |= 1;
19392         }
19393         return ret_ref;
19394 }
19395
19396 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
19397         LDKChannelTransactionParameters this_ptr_conv;
19398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19399         this_ptr_conv.is_owned = false;
19400         LDKCounterpartyChannelTransactionParameters val_conv;
19401         val_conv.inner = (void*)(val & (~1));
19402         val_conv.is_owned = (val & 1) || (val == 0);
19403         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
19404         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
19405 }
19406
19407 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
19408         LDKChannelTransactionParameters this_ptr_conv;
19409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19410         this_ptr_conv.is_owned = false;
19411         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
19412         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19413         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19414         uint64_t ret_ref = (uint64_t)ret_var.inner;
19415         if (ret_var.is_owned) {
19416                 ret_ref |= 1;
19417         }
19418         return ret_ref;
19419 }
19420
19421 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
19422         LDKChannelTransactionParameters this_ptr_conv;
19423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19424         this_ptr_conv.is_owned = false;
19425         LDKOutPoint val_conv;
19426         val_conv.inner = (void*)(val & (~1));
19427         val_conv.is_owned = (val & 1) || (val == 0);
19428         val_conv = OutPoint_clone(&val_conv);
19429         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
19430 }
19431
19432 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) {
19433         LDKChannelPublicKeys holder_pubkeys_arg_conv;
19434         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
19435         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
19436         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
19437         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
19438         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
19439         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
19440         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
19441         LDKOutPoint funding_outpoint_arg_conv;
19442         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
19443         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
19444         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
19445         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);
19446         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19447         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19448         uint64_t ret_ref = (uint64_t)ret_var.inner;
19449         if (ret_var.is_owned) {
19450                 ret_ref |= 1;
19451         }
19452         return ret_ref;
19453 }
19454
19455 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
19456         LDKChannelTransactionParameters orig_conv;
19457         orig_conv.inner = (void*)(orig & (~1));
19458         orig_conv.is_owned = false;
19459         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
19460         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19461         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19462         uint64_t ret_ref = (uint64_t)ret_var.inner;
19463         if (ret_var.is_owned) {
19464                 ret_ref |= 1;
19465         }
19466         return ret_ref;
19467 }
19468
19469 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
19470         LDKCounterpartyChannelTransactionParameters this_obj_conv;
19471         this_obj_conv.inner = (void*)(this_obj & (~1));
19472         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19473         CounterpartyChannelTransactionParameters_free(this_obj_conv);
19474 }
19475
19476 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
19477         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19479         this_ptr_conv.is_owned = false;
19480         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
19481         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19482         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19483         uint64_t ret_ref = (uint64_t)ret_var.inner;
19484         if (ret_var.is_owned) {
19485                 ret_ref |= 1;
19486         }
19487         return ret_ref;
19488 }
19489
19490 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
19491         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19493         this_ptr_conv.is_owned = false;
19494         LDKChannelPublicKeys val_conv;
19495         val_conv.inner = (void*)(val & (~1));
19496         val_conv.is_owned = (val & 1) || (val == 0);
19497         val_conv = ChannelPublicKeys_clone(&val_conv);
19498         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
19499 }
19500
19501 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
19502         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19504         this_ptr_conv.is_owned = false;
19505         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
19506         return ret_val;
19507 }
19508
19509 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
19510         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19512         this_ptr_conv.is_owned = false;
19513         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
19514 }
19515
19516 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
19517         LDKChannelPublicKeys pubkeys_arg_conv;
19518         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
19519         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
19520         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
19521         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
19522         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19523         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19524         uint64_t ret_ref = (uint64_t)ret_var.inner;
19525         if (ret_var.is_owned) {
19526                 ret_ref |= 1;
19527         }
19528         return ret_ref;
19529 }
19530
19531 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
19532         LDKCounterpartyChannelTransactionParameters orig_conv;
19533         orig_conv.inner = (void*)(orig & (~1));
19534         orig_conv.is_owned = false;
19535         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
19536         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19537         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19538         uint64_t ret_ref = (uint64_t)ret_var.inner;
19539         if (ret_var.is_owned) {
19540                 ret_ref |= 1;
19541         }
19542         return ret_ref;
19543 }
19544
19545 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
19546         LDKChannelTransactionParameters this_arg_conv;
19547         this_arg_conv.inner = (void*)(this_arg & (~1));
19548         this_arg_conv.is_owned = false;
19549         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
19550         return ret_val;
19551 }
19552
19553 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
19554         LDKChannelTransactionParameters this_arg_conv;
19555         this_arg_conv.inner = (void*)(this_arg & (~1));
19556         this_arg_conv.is_owned = false;
19557         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
19558         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19559         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19560         uint64_t ret_ref = (uint64_t)ret_var.inner;
19561         if (ret_var.is_owned) {
19562                 ret_ref |= 1;
19563         }
19564         return ret_ref;
19565 }
19566
19567 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
19568         LDKChannelTransactionParameters this_arg_conv;
19569         this_arg_conv.inner = (void*)(this_arg & (~1));
19570         this_arg_conv.is_owned = false;
19571         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
19572         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19573         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19574         uint64_t ret_ref = (uint64_t)ret_var.inner;
19575         if (ret_var.is_owned) {
19576                 ret_ref |= 1;
19577         }
19578         return ret_ref;
19579 }
19580
19581 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
19582         LDKCounterpartyChannelTransactionParameters obj_conv;
19583         obj_conv.inner = (void*)(obj & (~1));
19584         obj_conv.is_owned = false;
19585         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
19586         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19587         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19588         CVec_u8Z_free(ret_var);
19589         return ret_arr;
19590 }
19591
19592 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
19593         LDKu8slice ser_ref;
19594         ser_ref.datalen = *((uint32_t*)ser);
19595         ser_ref.data = (int8_t*)(ser + 4);
19596         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
19597         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
19598         return (uint64_t)ret_conv;
19599 }
19600
19601 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
19602         LDKChannelTransactionParameters obj_conv;
19603         obj_conv.inner = (void*)(obj & (~1));
19604         obj_conv.is_owned = false;
19605         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
19606         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19607         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19608         CVec_u8Z_free(ret_var);
19609         return ret_arr;
19610 }
19611
19612 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
19613         LDKu8slice ser_ref;
19614         ser_ref.datalen = *((uint32_t*)ser);
19615         ser_ref.data = (int8_t*)(ser + 4);
19616         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
19617         *ret_conv = ChannelTransactionParameters_read(ser_ref);
19618         return (uint64_t)ret_conv;
19619 }
19620
19621 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
19622         LDKDirectedChannelTransactionParameters this_obj_conv;
19623         this_obj_conv.inner = (void*)(this_obj & (~1));
19624         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19625         DirectedChannelTransactionParameters_free(this_obj_conv);
19626 }
19627
19628 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
19629         LDKDirectedChannelTransactionParameters this_arg_conv;
19630         this_arg_conv.inner = (void*)(this_arg & (~1));
19631         this_arg_conv.is_owned = false;
19632         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
19633         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19634         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19635         uint64_t ret_ref = (uint64_t)ret_var.inner;
19636         if (ret_var.is_owned) {
19637                 ret_ref |= 1;
19638         }
19639         return ret_ref;
19640 }
19641
19642 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
19643         LDKDirectedChannelTransactionParameters this_arg_conv;
19644         this_arg_conv.inner = (void*)(this_arg & (~1));
19645         this_arg_conv.is_owned = false;
19646         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
19647         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19648         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19649         uint64_t ret_ref = (uint64_t)ret_var.inner;
19650         if (ret_var.is_owned) {
19651                 ret_ref |= 1;
19652         }
19653         return ret_ref;
19654 }
19655
19656 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
19657         LDKDirectedChannelTransactionParameters this_arg_conv;
19658         this_arg_conv.inner = (void*)(this_arg & (~1));
19659         this_arg_conv.is_owned = false;
19660         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
19661         return ret_val;
19662 }
19663
19664 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
19665         LDKDirectedChannelTransactionParameters this_arg_conv;
19666         this_arg_conv.inner = (void*)(this_arg & (~1));
19667         this_arg_conv.is_owned = false;
19668         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
19669         return ret_val;
19670 }
19671
19672 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
19673         LDKDirectedChannelTransactionParameters this_arg_conv;
19674         this_arg_conv.inner = (void*)(this_arg & (~1));
19675         this_arg_conv.is_owned = false;
19676         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
19677         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19678         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19679         uint64_t ret_ref = (uint64_t)ret_var.inner;
19680         if (ret_var.is_owned) {
19681                 ret_ref |= 1;
19682         }
19683         return ret_ref;
19684 }
19685
19686 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
19687         LDKHolderCommitmentTransaction this_obj_conv;
19688         this_obj_conv.inner = (void*)(this_obj & (~1));
19689         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19690         HolderCommitmentTransaction_free(this_obj_conv);
19691 }
19692
19693 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
19694         LDKHolderCommitmentTransaction this_ptr_conv;
19695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19696         this_ptr_conv.is_owned = false;
19697         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19698         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
19699         return ret_arr;
19700 }
19701
19702 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
19703         LDKHolderCommitmentTransaction this_ptr_conv;
19704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19705         this_ptr_conv.is_owned = false;
19706         LDKSignature val_ref;
19707         CHECK(*((uint32_t*)val) == 64);
19708         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19709         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
19710 }
19711
19712 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
19713         LDKHolderCommitmentTransaction this_ptr_conv;
19714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19715         this_ptr_conv.is_owned = false;
19716         LDKCVec_SignatureZ val_constr;
19717         val_constr.datalen = *((uint32_t*)val);
19718         if (val_constr.datalen > 0)
19719                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19720         else
19721                 val_constr.data = NULL;
19722         int8_tArray* val_vals = (int8_tArray*)(val + 4);
19723         for (size_t m = 0; m < val_constr.datalen; m++) {
19724                 int8_tArray val_conv_12 = val_vals[m];
19725                 LDKSignature val_conv_12_ref;
19726                 CHECK(*((uint32_t*)val_conv_12) == 64);
19727                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
19728                 val_constr.data[m] = val_conv_12_ref;
19729         }
19730         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
19731 }
19732
19733 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
19734         LDKHolderCommitmentTransaction orig_conv;
19735         orig_conv.inner = (void*)(orig & (~1));
19736         orig_conv.is_owned = false;
19737         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
19738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19740         uint64_t ret_ref = (uint64_t)ret_var.inner;
19741         if (ret_var.is_owned) {
19742                 ret_ref |= 1;
19743         }
19744         return ret_ref;
19745 }
19746
19747 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
19748         LDKHolderCommitmentTransaction obj_conv;
19749         obj_conv.inner = (void*)(obj & (~1));
19750         obj_conv.is_owned = false;
19751         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
19752         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19753         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19754         CVec_u8Z_free(ret_var);
19755         return ret_arr;
19756 }
19757
19758 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
19759         LDKu8slice ser_ref;
19760         ser_ref.datalen = *((uint32_t*)ser);
19761         ser_ref.data = (int8_t*)(ser + 4);
19762         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
19763         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
19764         return (uint64_t)ret_conv;
19765 }
19766
19767 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) {
19768         LDKCommitmentTransaction commitment_tx_conv;
19769         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
19770         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
19771         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
19772         LDKSignature counterparty_sig_ref;
19773         CHECK(*((uint32_t*)counterparty_sig) == 64);
19774         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
19775         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
19776         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
19777         if (counterparty_htlc_sigs_constr.datalen > 0)
19778                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19779         else
19780                 counterparty_htlc_sigs_constr.data = NULL;
19781         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
19782         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
19783                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
19784                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
19785                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
19786                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
19787                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
19788         }
19789         LDKPublicKey holder_funding_key_ref;
19790         CHECK(*((uint32_t*)holder_funding_key) == 33);
19791         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
19792         LDKPublicKey counterparty_funding_key_ref;
19793         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
19794         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
19795         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
19796         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19797         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19798         uint64_t ret_ref = (uint64_t)ret_var.inner;
19799         if (ret_var.is_owned) {
19800                 ret_ref |= 1;
19801         }
19802         return ret_ref;
19803 }
19804
19805 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
19806         LDKBuiltCommitmentTransaction this_obj_conv;
19807         this_obj_conv.inner = (void*)(this_obj & (~1));
19808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19809         BuiltCommitmentTransaction_free(this_obj_conv);
19810 }
19811
19812 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
19813         LDKBuiltCommitmentTransaction this_ptr_conv;
19814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19815         this_ptr_conv.is_owned = false;
19816         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
19817         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19818         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19819         Transaction_free(ret_var);
19820         return ret_arr;
19821 }
19822
19823 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
19824         LDKBuiltCommitmentTransaction this_ptr_conv;
19825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19826         this_ptr_conv.is_owned = false;
19827         LDKTransaction val_ref;
19828         val_ref.datalen = *((uint32_t*)val);
19829         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
19830         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
19831         val_ref.data_is_owned = true;
19832         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
19833 }
19834
19835 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
19836         LDKBuiltCommitmentTransaction this_ptr_conv;
19837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19838         this_ptr_conv.is_owned = false;
19839         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19840         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
19841         return ret_arr;
19842 }
19843
19844 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
19845         LDKBuiltCommitmentTransaction this_ptr_conv;
19846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19847         this_ptr_conv.is_owned = false;
19848         LDKThirtyTwoBytes val_ref;
19849         CHECK(*((uint32_t*)val) == 32);
19850         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19851         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
19852 }
19853
19854 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
19855         LDKTransaction transaction_arg_ref;
19856         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
19857         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
19858         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
19859         transaction_arg_ref.data_is_owned = true;
19860         LDKThirtyTwoBytes txid_arg_ref;
19861         CHECK(*((uint32_t*)txid_arg) == 32);
19862         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
19863         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
19864         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19865         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19866         uint64_t ret_ref = (uint64_t)ret_var.inner;
19867         if (ret_var.is_owned) {
19868                 ret_ref |= 1;
19869         }
19870         return ret_ref;
19871 }
19872
19873 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
19874         LDKBuiltCommitmentTransaction orig_conv;
19875         orig_conv.inner = (void*)(orig & (~1));
19876         orig_conv.is_owned = false;
19877         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
19878         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19879         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19880         uint64_t ret_ref = (uint64_t)ret_var.inner;
19881         if (ret_var.is_owned) {
19882                 ret_ref |= 1;
19883         }
19884         return ret_ref;
19885 }
19886
19887 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
19888         LDKBuiltCommitmentTransaction obj_conv;
19889         obj_conv.inner = (void*)(obj & (~1));
19890         obj_conv.is_owned = false;
19891         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
19892         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19893         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19894         CVec_u8Z_free(ret_var);
19895         return ret_arr;
19896 }
19897
19898 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
19899         LDKu8slice ser_ref;
19900         ser_ref.datalen = *((uint32_t*)ser);
19901         ser_ref.data = (int8_t*)(ser + 4);
19902         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
19903         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
19904         return (uint64_t)ret_conv;
19905 }
19906
19907 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
19908         LDKBuiltCommitmentTransaction this_arg_conv;
19909         this_arg_conv.inner = (void*)(this_arg & (~1));
19910         this_arg_conv.is_owned = false;
19911         LDKu8slice funding_redeemscript_ref;
19912         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
19913         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
19914         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19915         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
19916         return ret_arr;
19917 }
19918
19919 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) {
19920         LDKBuiltCommitmentTransaction this_arg_conv;
19921         this_arg_conv.inner = (void*)(this_arg & (~1));
19922         this_arg_conv.is_owned = false;
19923         unsigned char funding_key_arr[32];
19924         CHECK(*((uint32_t*)funding_key) == 32);
19925         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
19926         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
19927         LDKu8slice funding_redeemscript_ref;
19928         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
19929         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
19930         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19931         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
19932         return ret_arr;
19933 }
19934
19935 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
19936         LDKCommitmentTransaction this_obj_conv;
19937         this_obj_conv.inner = (void*)(this_obj & (~1));
19938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19939         CommitmentTransaction_free(this_obj_conv);
19940 }
19941
19942 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
19943         LDKCommitmentTransaction orig_conv;
19944         orig_conv.inner = (void*)(orig & (~1));
19945         orig_conv.is_owned = false;
19946         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
19947         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19948         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19949         uint64_t ret_ref = (uint64_t)ret_var.inner;
19950         if (ret_var.is_owned) {
19951                 ret_ref |= 1;
19952         }
19953         return ret_ref;
19954 }
19955
19956 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
19957         LDKCommitmentTransaction obj_conv;
19958         obj_conv.inner = (void*)(obj & (~1));
19959         obj_conv.is_owned = false;
19960         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
19961         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19962         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19963         CVec_u8Z_free(ret_var);
19964         return ret_arr;
19965 }
19966
19967 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
19968         LDKu8slice ser_ref;
19969         ser_ref.datalen = *((uint32_t*)ser);
19970         ser_ref.data = (int8_t*)(ser + 4);
19971         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
19972         *ret_conv = CommitmentTransaction_read(ser_ref);
19973         return (uint64_t)ret_conv;
19974 }
19975
19976 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
19977         LDKCommitmentTransaction this_arg_conv;
19978         this_arg_conv.inner = (void*)(this_arg & (~1));
19979         this_arg_conv.is_owned = false;
19980         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
19981         return ret_val;
19982 }
19983
19984 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
19985         LDKCommitmentTransaction this_arg_conv;
19986         this_arg_conv.inner = (void*)(this_arg & (~1));
19987         this_arg_conv.is_owned = false;
19988         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
19989         return ret_val;
19990 }
19991
19992 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
19993         LDKCommitmentTransaction this_arg_conv;
19994         this_arg_conv.inner = (void*)(this_arg & (~1));
19995         this_arg_conv.is_owned = false;
19996         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
19997         return ret_val;
19998 }
19999
20000 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
20001         LDKCommitmentTransaction this_arg_conv;
20002         this_arg_conv.inner = (void*)(this_arg & (~1));
20003         this_arg_conv.is_owned = false;
20004         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
20005         return ret_val;
20006 }
20007
20008 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
20009         LDKCommitmentTransaction this_arg_conv;
20010         this_arg_conv.inner = (void*)(this_arg & (~1));
20011         this_arg_conv.is_owned = false;
20012         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
20013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20015         uint64_t ret_ref = (uint64_t)ret_var.inner;
20016         if (ret_var.is_owned) {
20017                 ret_ref |= 1;
20018         }
20019         return ret_ref;
20020 }
20021
20022 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
20023         LDKCommitmentTransaction this_arg_conv;
20024         this_arg_conv.inner = (void*)(this_arg & (~1));
20025         this_arg_conv.is_owned = false;
20026         LDKDirectedChannelTransactionParameters channel_parameters_conv;
20027         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
20028         channel_parameters_conv.is_owned = false;
20029         LDKChannelPublicKeys broadcaster_keys_conv;
20030         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
20031         broadcaster_keys_conv.is_owned = false;
20032         LDKChannelPublicKeys countersignatory_keys_conv;
20033         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
20034         countersignatory_keys_conv.is_owned = false;
20035         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
20036         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
20037         return (uint64_t)ret_conv;
20038 }
20039
20040 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
20041         LDKTrustedCommitmentTransaction this_obj_conv;
20042         this_obj_conv.inner = (void*)(this_obj & (~1));
20043         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20044         TrustedCommitmentTransaction_free(this_obj_conv);
20045 }
20046
20047 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
20048         LDKTrustedCommitmentTransaction this_arg_conv;
20049         this_arg_conv.inner = (void*)(this_arg & (~1));
20050         this_arg_conv.is_owned = false;
20051         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20052         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
20053         return ret_arr;
20054 }
20055
20056 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
20057         LDKTrustedCommitmentTransaction this_arg_conv;
20058         this_arg_conv.inner = (void*)(this_arg & (~1));
20059         this_arg_conv.is_owned = false;
20060         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
20061         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20062         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20063         uint64_t ret_ref = (uint64_t)ret_var.inner;
20064         if (ret_var.is_owned) {
20065                 ret_ref |= 1;
20066         }
20067         return ret_ref;
20068 }
20069
20070 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
20071         LDKTrustedCommitmentTransaction this_arg_conv;
20072         this_arg_conv.inner = (void*)(this_arg & (~1));
20073         this_arg_conv.is_owned = false;
20074         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
20075         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20076         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20077         uint64_t ret_ref = (uint64_t)ret_var.inner;
20078         if (ret_var.is_owned) {
20079                 ret_ref |= 1;
20080         }
20081         return ret_ref;
20082 }
20083
20084 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
20085         LDKTrustedCommitmentTransaction this_arg_conv;
20086         this_arg_conv.inner = (void*)(this_arg & (~1));
20087         this_arg_conv.is_owned = false;
20088         unsigned char htlc_base_key_arr[32];
20089         CHECK(*((uint32_t*)htlc_base_key) == 32);
20090         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
20091         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
20092         LDKDirectedChannelTransactionParameters channel_parameters_conv;
20093         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
20094         channel_parameters_conv.is_owned = false;
20095         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
20096         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
20097         return (uint64_t)ret_conv;
20098 }
20099
20100 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) {
20101         LDKPublicKey broadcaster_payment_basepoint_ref;
20102         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
20103         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
20104         LDKPublicKey countersignatory_payment_basepoint_ref;
20105         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
20106         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
20107         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
20108         return ret_val;
20109 }
20110
20111 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
20112         LDKInitFeatures a_conv;
20113         a_conv.inner = (void*)(a & (~1));
20114         a_conv.is_owned = false;
20115         LDKInitFeatures b_conv;
20116         b_conv.inner = (void*)(b & (~1));
20117         b_conv.is_owned = false;
20118         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
20119         return ret_val;
20120 }
20121
20122 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
20123         LDKNodeFeatures a_conv;
20124         a_conv.inner = (void*)(a & (~1));
20125         a_conv.is_owned = false;
20126         LDKNodeFeatures b_conv;
20127         b_conv.inner = (void*)(b & (~1));
20128         b_conv.is_owned = false;
20129         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
20130         return ret_val;
20131 }
20132
20133 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
20134         LDKChannelFeatures a_conv;
20135         a_conv.inner = (void*)(a & (~1));
20136         a_conv.is_owned = false;
20137         LDKChannelFeatures b_conv;
20138         b_conv.inner = (void*)(b & (~1));
20139         b_conv.is_owned = false;
20140         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
20141         return ret_val;
20142 }
20143
20144 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
20145         LDKInvoiceFeatures a_conv;
20146         a_conv.inner = (void*)(a & (~1));
20147         a_conv.is_owned = false;
20148         LDKInvoiceFeatures b_conv;
20149         b_conv.inner = (void*)(b & (~1));
20150         b_conv.is_owned = false;
20151         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
20152         return ret_val;
20153 }
20154
20155 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
20156         LDKInitFeatures orig_conv;
20157         orig_conv.inner = (void*)(orig & (~1));
20158         orig_conv.is_owned = false;
20159         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
20160         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20161         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20162         uint64_t ret_ref = (uint64_t)ret_var.inner;
20163         if (ret_var.is_owned) {
20164                 ret_ref |= 1;
20165         }
20166         return ret_ref;
20167 }
20168
20169 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
20170         LDKNodeFeatures orig_conv;
20171         orig_conv.inner = (void*)(orig & (~1));
20172         orig_conv.is_owned = false;
20173         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
20174         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20175         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20176         uint64_t ret_ref = (uint64_t)ret_var.inner;
20177         if (ret_var.is_owned) {
20178                 ret_ref |= 1;
20179         }
20180         return ret_ref;
20181 }
20182
20183 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
20184         LDKChannelFeatures orig_conv;
20185         orig_conv.inner = (void*)(orig & (~1));
20186         orig_conv.is_owned = false;
20187         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
20188         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20189         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20190         uint64_t ret_ref = (uint64_t)ret_var.inner;
20191         if (ret_var.is_owned) {
20192                 ret_ref |= 1;
20193         }
20194         return ret_ref;
20195 }
20196
20197 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
20198         LDKInvoiceFeatures orig_conv;
20199         orig_conv.inner = (void*)(orig & (~1));
20200         orig_conv.is_owned = false;
20201         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
20202         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20203         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20204         uint64_t ret_ref = (uint64_t)ret_var.inner;
20205         if (ret_var.is_owned) {
20206                 ret_ref |= 1;
20207         }
20208         return ret_ref;
20209 }
20210
20211 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
20212         LDKInitFeatures this_obj_conv;
20213         this_obj_conv.inner = (void*)(this_obj & (~1));
20214         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20215         InitFeatures_free(this_obj_conv);
20216 }
20217
20218 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
20219         LDKNodeFeatures this_obj_conv;
20220         this_obj_conv.inner = (void*)(this_obj & (~1));
20221         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20222         NodeFeatures_free(this_obj_conv);
20223 }
20224
20225 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
20226         LDKChannelFeatures this_obj_conv;
20227         this_obj_conv.inner = (void*)(this_obj & (~1));
20228         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20229         ChannelFeatures_free(this_obj_conv);
20230 }
20231
20232 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
20233         LDKInvoiceFeatures this_obj_conv;
20234         this_obj_conv.inner = (void*)(this_obj & (~1));
20235         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20236         InvoiceFeatures_free(this_obj_conv);
20237 }
20238
20239 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
20240         LDKInitFeatures ret_var = InitFeatures_empty();
20241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20243         uint64_t ret_ref = (uint64_t)ret_var.inner;
20244         if (ret_var.is_owned) {
20245                 ret_ref |= 1;
20246         }
20247         return ret_ref;
20248 }
20249
20250 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
20251         LDKInitFeatures ret_var = InitFeatures_known();
20252         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20253         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20254         uint64_t ret_ref = (uint64_t)ret_var.inner;
20255         if (ret_var.is_owned) {
20256                 ret_ref |= 1;
20257         }
20258         return ret_ref;
20259 }
20260
20261 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
20262         LDKNodeFeatures ret_var = NodeFeatures_empty();
20263         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20264         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20265         uint64_t ret_ref = (uint64_t)ret_var.inner;
20266         if (ret_var.is_owned) {
20267                 ret_ref |= 1;
20268         }
20269         return ret_ref;
20270 }
20271
20272 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
20273         LDKNodeFeatures ret_var = NodeFeatures_known();
20274         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20275         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20276         uint64_t ret_ref = (uint64_t)ret_var.inner;
20277         if (ret_var.is_owned) {
20278                 ret_ref |= 1;
20279         }
20280         return ret_ref;
20281 }
20282
20283 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
20284         LDKChannelFeatures ret_var = ChannelFeatures_empty();
20285         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20286         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20287         uint64_t ret_ref = (uint64_t)ret_var.inner;
20288         if (ret_var.is_owned) {
20289                 ret_ref |= 1;
20290         }
20291         return ret_ref;
20292 }
20293
20294 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
20295         LDKChannelFeatures ret_var = ChannelFeatures_known();
20296         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20297         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20298         uint64_t ret_ref = (uint64_t)ret_var.inner;
20299         if (ret_var.is_owned) {
20300                 ret_ref |= 1;
20301         }
20302         return ret_ref;
20303 }
20304
20305 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
20306         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
20307         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20308         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20309         uint64_t ret_ref = (uint64_t)ret_var.inner;
20310         if (ret_var.is_owned) {
20311                 ret_ref |= 1;
20312         }
20313         return ret_ref;
20314 }
20315
20316 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
20317         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
20318         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20319         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20320         uint64_t ret_ref = (uint64_t)ret_var.inner;
20321         if (ret_var.is_owned) {
20322                 ret_ref |= 1;
20323         }
20324         return ret_ref;
20325 }
20326
20327 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
20328         LDKInitFeatures this_arg_conv;
20329         this_arg_conv.inner = (void*)(this_arg & (~1));
20330         this_arg_conv.is_owned = false;
20331         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
20332         return ret_val;
20333 }
20334
20335 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
20336         LDKNodeFeatures this_arg_conv;
20337         this_arg_conv.inner = (void*)(this_arg & (~1));
20338         this_arg_conv.is_owned = false;
20339         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
20340         return ret_val;
20341 }
20342
20343 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
20344         LDKInvoiceFeatures this_arg_conv;
20345         this_arg_conv.inner = (void*)(this_arg & (~1));
20346         this_arg_conv.is_owned = false;
20347         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
20348         return ret_val;
20349 }
20350
20351 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
20352         LDKInitFeatures obj_conv;
20353         obj_conv.inner = (void*)(obj & (~1));
20354         obj_conv.is_owned = false;
20355         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
20356         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20357         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20358         CVec_u8Z_free(ret_var);
20359         return ret_arr;
20360 }
20361
20362 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
20363         LDKNodeFeatures obj_conv;
20364         obj_conv.inner = (void*)(obj & (~1));
20365         obj_conv.is_owned = false;
20366         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
20367         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20368         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20369         CVec_u8Z_free(ret_var);
20370         return ret_arr;
20371 }
20372
20373 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
20374         LDKChannelFeatures obj_conv;
20375         obj_conv.inner = (void*)(obj & (~1));
20376         obj_conv.is_owned = false;
20377         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
20378         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20379         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20380         CVec_u8Z_free(ret_var);
20381         return ret_arr;
20382 }
20383
20384 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
20385         LDKInvoiceFeatures obj_conv;
20386         obj_conv.inner = (void*)(obj & (~1));
20387         obj_conv.is_owned = false;
20388         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
20389         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20390         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20391         CVec_u8Z_free(ret_var);
20392         return ret_arr;
20393 }
20394
20395 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
20396         LDKu8slice ser_ref;
20397         ser_ref.datalen = *((uint32_t*)ser);
20398         ser_ref.data = (int8_t*)(ser + 4);
20399         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
20400         *ret_conv = InitFeatures_read(ser_ref);
20401         return (uint64_t)ret_conv;
20402 }
20403
20404 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
20405         LDKu8slice ser_ref;
20406         ser_ref.datalen = *((uint32_t*)ser);
20407         ser_ref.data = (int8_t*)(ser + 4);
20408         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
20409         *ret_conv = NodeFeatures_read(ser_ref);
20410         return (uint64_t)ret_conv;
20411 }
20412
20413 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
20414         LDKu8slice ser_ref;
20415         ser_ref.datalen = *((uint32_t*)ser);
20416         ser_ref.data = (int8_t*)(ser + 4);
20417         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
20418         *ret_conv = ChannelFeatures_read(ser_ref);
20419         return (uint64_t)ret_conv;
20420 }
20421
20422 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
20423         LDKu8slice ser_ref;
20424         ser_ref.datalen = *((uint32_t*)ser);
20425         ser_ref.data = (int8_t*)(ser + 4);
20426         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
20427         *ret_conv = InvoiceFeatures_read(ser_ref);
20428         return (uint64_t)ret_conv;
20429 }
20430
20431 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
20432         LDKRouteHop this_obj_conv;
20433         this_obj_conv.inner = (void*)(this_obj & (~1));
20434         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20435         RouteHop_free(this_obj_conv);
20436 }
20437
20438 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
20439         LDKRouteHop this_ptr_conv;
20440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20441         this_ptr_conv.is_owned = false;
20442         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20443         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
20444         return ret_arr;
20445 }
20446
20447 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
20448         LDKRouteHop this_ptr_conv;
20449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20450         this_ptr_conv.is_owned = false;
20451         LDKPublicKey val_ref;
20452         CHECK(*((uint32_t*)val) == 33);
20453         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20454         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
20455 }
20456
20457 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
20458         LDKRouteHop this_ptr_conv;
20459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20460         this_ptr_conv.is_owned = false;
20461         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
20462         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20463         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20464         uint64_t ret_ref = (uint64_t)ret_var.inner;
20465         if (ret_var.is_owned) {
20466                 ret_ref |= 1;
20467         }
20468         return ret_ref;
20469 }
20470
20471 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
20472         LDKRouteHop this_ptr_conv;
20473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20474         this_ptr_conv.is_owned = false;
20475         LDKNodeFeatures val_conv;
20476         val_conv.inner = (void*)(val & (~1));
20477         val_conv.is_owned = (val & 1) || (val == 0);
20478         val_conv = NodeFeatures_clone(&val_conv);
20479         RouteHop_set_node_features(&this_ptr_conv, val_conv);
20480 }
20481
20482 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
20483         LDKRouteHop this_ptr_conv;
20484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20485         this_ptr_conv.is_owned = false;
20486         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
20487         return ret_val;
20488 }
20489
20490 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
20491         LDKRouteHop this_ptr_conv;
20492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20493         this_ptr_conv.is_owned = false;
20494         RouteHop_set_short_channel_id(&this_ptr_conv, val);
20495 }
20496
20497 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
20498         LDKRouteHop this_ptr_conv;
20499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20500         this_ptr_conv.is_owned = false;
20501         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
20502         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20503         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20504         uint64_t ret_ref = (uint64_t)ret_var.inner;
20505         if (ret_var.is_owned) {
20506                 ret_ref |= 1;
20507         }
20508         return ret_ref;
20509 }
20510
20511 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
20512         LDKRouteHop this_ptr_conv;
20513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20514         this_ptr_conv.is_owned = false;
20515         LDKChannelFeatures val_conv;
20516         val_conv.inner = (void*)(val & (~1));
20517         val_conv.is_owned = (val & 1) || (val == 0);
20518         val_conv = ChannelFeatures_clone(&val_conv);
20519         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
20520 }
20521
20522 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
20523         LDKRouteHop this_ptr_conv;
20524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20525         this_ptr_conv.is_owned = false;
20526         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
20527         return ret_val;
20528 }
20529
20530 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
20531         LDKRouteHop this_ptr_conv;
20532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20533         this_ptr_conv.is_owned = false;
20534         RouteHop_set_fee_msat(&this_ptr_conv, val);
20535 }
20536
20537 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
20538         LDKRouteHop this_ptr_conv;
20539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20540         this_ptr_conv.is_owned = false;
20541         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
20542         return ret_val;
20543 }
20544
20545 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
20546         LDKRouteHop this_ptr_conv;
20547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20548         this_ptr_conv.is_owned = false;
20549         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
20550 }
20551
20552 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) {
20553         LDKPublicKey pubkey_arg_ref;
20554         CHECK(*((uint32_t*)pubkey_arg) == 33);
20555         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
20556         LDKNodeFeatures node_features_arg_conv;
20557         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
20558         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
20559         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
20560         LDKChannelFeatures channel_features_arg_conv;
20561         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
20562         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
20563         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
20564         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);
20565         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20566         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20567         uint64_t ret_ref = (uint64_t)ret_var.inner;
20568         if (ret_var.is_owned) {
20569                 ret_ref |= 1;
20570         }
20571         return ret_ref;
20572 }
20573
20574 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
20575         LDKRouteHop orig_conv;
20576         orig_conv.inner = (void*)(orig & (~1));
20577         orig_conv.is_owned = false;
20578         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
20579         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20580         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20581         uint64_t ret_ref = (uint64_t)ret_var.inner;
20582         if (ret_var.is_owned) {
20583                 ret_ref |= 1;
20584         }
20585         return ret_ref;
20586 }
20587
20588 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) {
20589         LDKRouteHop obj_conv;
20590         obj_conv.inner = (void*)(obj & (~1));
20591         obj_conv.is_owned = false;
20592         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
20593         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20594         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20595         CVec_u8Z_free(ret_var);
20596         return ret_arr;
20597 }
20598
20599 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_read(int8_tArray ser) {
20600         LDKu8slice ser_ref;
20601         ser_ref.datalen = *((uint32_t*)ser);
20602         ser_ref.data = (int8_t*)(ser + 4);
20603         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
20604         *ret_conv = RouteHop_read(ser_ref);
20605         return (uint64_t)ret_conv;
20606 }
20607
20608 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
20609         LDKRoute this_obj_conv;
20610         this_obj_conv.inner = (void*)(this_obj & (~1));
20611         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20612         Route_free(this_obj_conv);
20613 }
20614
20615 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
20616         LDKRoute this_ptr_conv;
20617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20618         this_ptr_conv.is_owned = false;
20619         LDKCVec_CVec_RouteHopZZ val_constr;
20620         val_constr.datalen = *((uint32_t*)val);
20621         if (val_constr.datalen > 0)
20622                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
20623         else
20624                 val_constr.data = NULL;
20625         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
20626         for (size_t m = 0; m < val_constr.datalen; m++) {
20627                 uint32_tArray val_conv_12 = val_vals[m];
20628                 LDKCVec_RouteHopZ val_conv_12_constr;
20629                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
20630                 if (val_conv_12_constr.datalen > 0)
20631                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20632                 else
20633                         val_conv_12_constr.data = NULL;
20634                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
20635                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
20636                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
20637                         LDKRouteHop val_conv_12_conv_10_conv;
20638                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
20639                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
20640                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
20641                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
20642                 }
20643                 val_constr.data[m] = val_conv_12_constr;
20644         }
20645         Route_set_paths(&this_ptr_conv, val_constr);
20646 }
20647
20648 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
20649         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
20650         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
20651         if (paths_arg_constr.datalen > 0)
20652                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
20653         else
20654                 paths_arg_constr.data = NULL;
20655         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
20656         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
20657                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
20658                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
20659                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
20660                 if (paths_arg_conv_12_constr.datalen > 0)
20661                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20662                 else
20663                         paths_arg_conv_12_constr.data = NULL;
20664                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
20665                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
20666                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
20667                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
20668                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
20669                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
20670                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
20671                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
20672                 }
20673                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
20674         }
20675         LDKRoute ret_var = Route_new(paths_arg_constr);
20676         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20677         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20678         uint64_t ret_ref = (uint64_t)ret_var.inner;
20679         if (ret_var.is_owned) {
20680                 ret_ref |= 1;
20681         }
20682         return ret_ref;
20683 }
20684
20685 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
20686         LDKRoute orig_conv;
20687         orig_conv.inner = (void*)(orig & (~1));
20688         orig_conv.is_owned = false;
20689         LDKRoute ret_var = Route_clone(&orig_conv);
20690         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20691         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20692         uint64_t ret_ref = (uint64_t)ret_var.inner;
20693         if (ret_var.is_owned) {
20694                 ret_ref |= 1;
20695         }
20696         return ret_ref;
20697 }
20698
20699 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
20700         LDKRoute obj_conv;
20701         obj_conv.inner = (void*)(obj & (~1));
20702         obj_conv.is_owned = false;
20703         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
20704         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20705         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20706         CVec_u8Z_free(ret_var);
20707         return ret_arr;
20708 }
20709
20710 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
20711         LDKu8slice ser_ref;
20712         ser_ref.datalen = *((uint32_t*)ser);
20713         ser_ref.data = (int8_t*)(ser + 4);
20714         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
20715         *ret_conv = Route_read(ser_ref);
20716         return (uint64_t)ret_conv;
20717 }
20718
20719 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
20720         LDKRouteHint this_obj_conv;
20721         this_obj_conv.inner = (void*)(this_obj & (~1));
20722         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20723         RouteHint_free(this_obj_conv);
20724 }
20725
20726 jboolean  __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
20727         LDKRouteHint a_conv;
20728         a_conv.inner = (void*)(a & (~1));
20729         a_conv.is_owned = false;
20730         LDKRouteHint b_conv;
20731         b_conv.inner = (void*)(b & (~1));
20732         b_conv.is_owned = false;
20733         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
20734         return ret_val;
20735 }
20736
20737 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
20738         LDKRouteHint orig_conv;
20739         orig_conv.inner = (void*)(orig & (~1));
20740         orig_conv.is_owned = false;
20741         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
20742         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20743         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20744         uint64_t ret_ref = (uint64_t)ret_var.inner;
20745         if (ret_var.is_owned) {
20746                 ret_ref |= 1;
20747         }
20748         return ret_ref;
20749 }
20750
20751 void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
20752         LDKRouteHintHop this_obj_conv;
20753         this_obj_conv.inner = (void*)(this_obj & (~1));
20754         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20755         RouteHintHop_free(this_obj_conv);
20756 }
20757
20758 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
20759         LDKRouteHintHop this_ptr_conv;
20760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20761         this_ptr_conv.is_owned = false;
20762         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20763         memcpy((uint8_t*)(ret_arr + 4), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
20764         return ret_arr;
20765 }
20766
20767 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
20768         LDKRouteHintHop this_ptr_conv;
20769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20770         this_ptr_conv.is_owned = false;
20771         LDKPublicKey val_ref;
20772         CHECK(*((uint32_t*)val) == 33);
20773         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20774         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
20775 }
20776
20777 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
20778         LDKRouteHintHop this_ptr_conv;
20779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20780         this_ptr_conv.is_owned = false;
20781         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
20782         return ret_val;
20783 }
20784
20785 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
20786         LDKRouteHintHop this_ptr_conv;
20787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20788         this_ptr_conv.is_owned = false;
20789         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
20790 }
20791
20792 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
20793         LDKRouteHintHop this_ptr_conv;
20794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20795         this_ptr_conv.is_owned = false;
20796         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
20797         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20798         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20799         uint64_t ret_ref = (uint64_t)ret_var.inner;
20800         if (ret_var.is_owned) {
20801                 ret_ref |= 1;
20802         }
20803         return ret_ref;
20804 }
20805
20806 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
20807         LDKRouteHintHop this_ptr_conv;
20808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20809         this_ptr_conv.is_owned = false;
20810         LDKRoutingFees val_conv;
20811         val_conv.inner = (void*)(val & (~1));
20812         val_conv.is_owned = (val & 1) || (val == 0);
20813         val_conv = RoutingFees_clone(&val_conv);
20814         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
20815 }
20816
20817 int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
20818         LDKRouteHintHop this_ptr_conv;
20819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20820         this_ptr_conv.is_owned = false;
20821         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
20822         return ret_val;
20823 }
20824
20825 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20826         LDKRouteHintHop this_ptr_conv;
20827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20828         this_ptr_conv.is_owned = false;
20829         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
20830 }
20831
20832 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
20833         LDKRouteHintHop this_ptr_conv;
20834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20835         this_ptr_conv.is_owned = false;
20836         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20837         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
20838         uint64_t ret_ref = (uint64_t)ret_copy;
20839         return ret_ref;
20840 }
20841
20842 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
20843         LDKRouteHintHop this_ptr_conv;
20844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20845         this_ptr_conv.is_owned = false;
20846         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20847         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
20848 }
20849
20850 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
20851         LDKRouteHintHop this_ptr_conv;
20852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20853         this_ptr_conv.is_owned = false;
20854         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20855         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
20856         uint64_t ret_ref = (uint64_t)ret_copy;
20857         return ret_ref;
20858 }
20859
20860 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
20861         LDKRouteHintHop this_ptr_conv;
20862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20863         this_ptr_conv.is_owned = false;
20864         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20865         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
20866 }
20867
20868 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) {
20869         LDKPublicKey src_node_id_arg_ref;
20870         CHECK(*((uint32_t*)src_node_id_arg) == 33);
20871         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
20872         LDKRoutingFees fees_arg_conv;
20873         fees_arg_conv.inner = (void*)(fees_arg & (~1));
20874         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
20875         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
20876         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
20877         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
20878         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);
20879         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20880         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20881         uint64_t ret_ref = (uint64_t)ret_var.inner;
20882         if (ret_var.is_owned) {
20883                 ret_ref |= 1;
20884         }
20885         return ret_ref;
20886 }
20887
20888 jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
20889         LDKRouteHintHop a_conv;
20890         a_conv.inner = (void*)(a & (~1));
20891         a_conv.is_owned = false;
20892         LDKRouteHintHop b_conv;
20893         b_conv.inner = (void*)(b & (~1));
20894         b_conv.is_owned = false;
20895         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
20896         return ret_val;
20897 }
20898
20899 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) {
20900         LDKRouteHintHop orig_conv;
20901         orig_conv.inner = (void*)(orig & (~1));
20902         orig_conv.is_owned = false;
20903         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
20904         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20905         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20906         uint64_t ret_ref = (uint64_t)ret_var.inner;
20907         if (ret_var.is_owned) {
20908                 ret_ref |= 1;
20909         }
20910         return ret_ref;
20911 }
20912
20913 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) {
20914         LDKPublicKey our_node_id_ref;
20915         CHECK(*((uint32_t*)our_node_id) == 33);
20916         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
20917         LDKNetworkGraph network_conv;
20918         network_conv.inner = (void*)(network & (~1));
20919         network_conv.is_owned = false;
20920         LDKPublicKey payee_ref;
20921         CHECK(*((uint32_t*)payee) == 33);
20922         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
20923         LDKInvoiceFeatures payee_features_conv;
20924         payee_features_conv.inner = (void*)(payee_features & (~1));
20925         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
20926         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
20927         LDKCVec_ChannelDetailsZ first_hops_constr;
20928         first_hops_constr.datalen = *((uint32_t*)first_hops);
20929         if (first_hops_constr.datalen > 0)
20930                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
20931         else
20932                 first_hops_constr.data = NULL;
20933         uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
20934         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
20935                 uint32_t first_hops_conv_16 = first_hops_vals[q];
20936                 LDKChannelDetails first_hops_conv_16_conv;
20937                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
20938                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
20939                 first_hops_constr.data[q] = first_hops_conv_16_conv;
20940         }
20941         LDKCVec_RouteHintZ last_hops_constr;
20942         last_hops_constr.datalen = *((uint32_t*)last_hops);
20943         if (last_hops_constr.datalen > 0)
20944                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
20945         else
20946                 last_hops_constr.data = NULL;
20947         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
20948         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
20949                 uint32_t last_hops_conv_11 = last_hops_vals[l];
20950                 LDKRouteHint last_hops_conv_11_conv;
20951                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
20952                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
20953                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
20954                 last_hops_constr.data[l] = last_hops_conv_11_conv;
20955         }
20956         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20957         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
20958         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
20959         FREE(first_hops_constr.data);
20960         return (uint64_t)ret_conv;
20961 }
20962
20963 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
20964         LDKNetworkGraph this_obj_conv;
20965         this_obj_conv.inner = (void*)(this_obj & (~1));
20966         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20967         NetworkGraph_free(this_obj_conv);
20968 }
20969
20970 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
20971         LDKNetworkGraph orig_conv;
20972         orig_conv.inner = (void*)(orig & (~1));
20973         orig_conv.is_owned = false;
20974         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
20975         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20976         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20977         uint64_t ret_ref = (uint64_t)ret_var.inner;
20978         if (ret_var.is_owned) {
20979                 ret_ref |= 1;
20980         }
20981         return ret_ref;
20982 }
20983
20984 void  __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_obj) {
20985         LDKLockedNetworkGraph this_obj_conv;
20986         this_obj_conv.inner = (void*)(this_obj & (~1));
20987         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20988         LockedNetworkGraph_free(this_obj_conv);
20989 }
20990
20991 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
20992         LDKNetGraphMsgHandler this_obj_conv;
20993         this_obj_conv.inner = (void*)(this_obj & (~1));
20994         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20995         NetGraphMsgHandler_free(this_obj_conv);
20996 }
20997
20998 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
20999         LDKThirtyTwoBytes genesis_hash_ref;
21000         CHECK(*((uint32_t*)genesis_hash) == 32);
21001         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
21002         LDKAccess *chain_access_conv_ptr = NULL;
21003         if (chain_access != 0) {
21004                 LDKAccess chain_access_conv;
21005                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21006                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21007                 *chain_access_conv_ptr = chain_access_conv;
21008         }
21009         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
21010         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
21011         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21012         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21013         uint64_t ret_ref = (uint64_t)ret_var.inner;
21014         if (ret_var.is_owned) {
21015                 ret_ref |= 1;
21016         }
21017         return ret_ref;
21018 }
21019
21020 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
21021         LDKAccess *chain_access_conv_ptr = NULL;
21022         if (chain_access != 0) {
21023                 LDKAccess chain_access_conv;
21024                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21025                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21026                 *chain_access_conv_ptr = chain_access_conv;
21027         }
21028         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
21029         LDKNetworkGraph network_graph_conv;
21030         network_graph_conv.inner = (void*)(network_graph & (~1));
21031         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
21032         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
21033         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
21034         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21035         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21036         uint64_t ret_ref = (uint64_t)ret_var.inner;
21037         if (ret_var.is_owned) {
21038                 ret_ref |= 1;
21039         }
21040         return ret_ref;
21041 }
21042
21043 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
21044         LDKNetGraphMsgHandler this_arg_conv;
21045         this_arg_conv.inner = (void*)(this_arg & (~1));
21046         this_arg_conv.is_owned = false;
21047         LDKAccess *chain_access_conv_ptr = NULL;
21048         if (chain_access != 0) {
21049                 LDKAccess chain_access_conv;
21050                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21051                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21052                 *chain_access_conv_ptr = chain_access_conv;
21053         }
21054         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
21055 }
21056
21057 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) {
21058         LDKNetGraphMsgHandler this_arg_conv;
21059         this_arg_conv.inner = (void*)(this_arg & (~1));
21060         this_arg_conv.is_owned = false;
21061         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
21062         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21063         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21064         uint64_t ret_ref = (uint64_t)ret_var.inner;
21065         if (ret_var.is_owned) {
21066                 ret_ref |= 1;
21067         }
21068         return ret_ref;
21069 }
21070
21071 uint32_t  __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) {
21072         LDKLockedNetworkGraph this_arg_conv;
21073         this_arg_conv.inner = (void*)(this_arg & (~1));
21074         this_arg_conv.is_owned = false;
21075         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
21076         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21077         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21078         uint64_t ret_ref = (uint64_t)ret_var.inner;
21079         if (ret_var.is_owned) {
21080                 ret_ref |= 1;
21081         }
21082         return ret_ref;
21083 }
21084
21085 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
21086         LDKNetGraphMsgHandler this_arg_conv;
21087         this_arg_conv.inner = (void*)(this_arg & (~1));
21088         this_arg_conv.is_owned = false;
21089         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
21090         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
21091         return (uint64_t)ret;
21092 }
21093
21094 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
21095         LDKNetGraphMsgHandler this_arg_conv;
21096         this_arg_conv.inner = (void*)(this_arg & (~1));
21097         this_arg_conv.is_owned = false;
21098         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21099         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
21100         return (uint64_t)ret;
21101 }
21102
21103 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
21104         LDKDirectionalChannelInfo this_obj_conv;
21105         this_obj_conv.inner = (void*)(this_obj & (~1));
21106         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21107         DirectionalChannelInfo_free(this_obj_conv);
21108 }
21109
21110 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
21111         LDKDirectionalChannelInfo this_ptr_conv;
21112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21113         this_ptr_conv.is_owned = false;
21114         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
21115         return ret_val;
21116 }
21117
21118 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
21119         LDKDirectionalChannelInfo this_ptr_conv;
21120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21121         this_ptr_conv.is_owned = false;
21122         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
21123 }
21124
21125 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
21126         LDKDirectionalChannelInfo this_ptr_conv;
21127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21128         this_ptr_conv.is_owned = false;
21129         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
21130         return ret_val;
21131 }
21132
21133 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
21134         LDKDirectionalChannelInfo this_ptr_conv;
21135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21136         this_ptr_conv.is_owned = false;
21137         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
21138 }
21139
21140 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
21141         LDKDirectionalChannelInfo this_ptr_conv;
21142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21143         this_ptr_conv.is_owned = false;
21144         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
21145         return ret_val;
21146 }
21147
21148 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
21149         LDKDirectionalChannelInfo this_ptr_conv;
21150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21151         this_ptr_conv.is_owned = false;
21152         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
21153 }
21154
21155 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
21156         LDKDirectionalChannelInfo this_ptr_conv;
21157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21158         this_ptr_conv.is_owned = false;
21159         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
21160         return ret_val;
21161 }
21162
21163 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
21164         LDKDirectionalChannelInfo this_ptr_conv;
21165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21166         this_ptr_conv.is_owned = false;
21167         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
21168 }
21169
21170 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
21171         LDKDirectionalChannelInfo this_ptr_conv;
21172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21173         this_ptr_conv.is_owned = false;
21174         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21175         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
21176         uint64_t ret_ref = (uint64_t)ret_copy;
21177         return ret_ref;
21178 }
21179
21180 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
21181         LDKDirectionalChannelInfo this_ptr_conv;
21182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21183         this_ptr_conv.is_owned = false;
21184         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
21185         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
21186 }
21187
21188 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
21189         LDKDirectionalChannelInfo this_ptr_conv;
21190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21191         this_ptr_conv.is_owned = false;
21192         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
21193         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21194         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21195         uint64_t ret_ref = (uint64_t)ret_var.inner;
21196         if (ret_var.is_owned) {
21197                 ret_ref |= 1;
21198         }
21199         return ret_ref;
21200 }
21201
21202 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
21203         LDKDirectionalChannelInfo this_ptr_conv;
21204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21205         this_ptr_conv.is_owned = false;
21206         LDKRoutingFees val_conv;
21207         val_conv.inner = (void*)(val & (~1));
21208         val_conv.is_owned = (val & 1) || (val == 0);
21209         val_conv = RoutingFees_clone(&val_conv);
21210         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
21211 }
21212
21213 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
21214         LDKDirectionalChannelInfo this_ptr_conv;
21215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21216         this_ptr_conv.is_owned = false;
21217         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
21218         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21219         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21220         uint64_t ret_ref = (uint64_t)ret_var.inner;
21221         if (ret_var.is_owned) {
21222                 ret_ref |= 1;
21223         }
21224         return ret_ref;
21225 }
21226
21227 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
21228         LDKDirectionalChannelInfo this_ptr_conv;
21229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21230         this_ptr_conv.is_owned = false;
21231         LDKChannelUpdate val_conv;
21232         val_conv.inner = (void*)(val & (~1));
21233         val_conv.is_owned = (val & 1) || (val == 0);
21234         val_conv = ChannelUpdate_clone(&val_conv);
21235         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
21236 }
21237
21238 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) {
21239         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
21240         LDKRoutingFees fees_arg_conv;
21241         fees_arg_conv.inner = (void*)(fees_arg & (~1));
21242         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
21243         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
21244         LDKChannelUpdate last_update_message_arg_conv;
21245         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
21246         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
21247         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
21248         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);
21249         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21250         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21251         uint64_t ret_ref = (uint64_t)ret_var.inner;
21252         if (ret_var.is_owned) {
21253                 ret_ref |= 1;
21254         }
21255         return ret_ref;
21256 }
21257
21258 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
21259         LDKDirectionalChannelInfo orig_conv;
21260         orig_conv.inner = (void*)(orig & (~1));
21261         orig_conv.is_owned = false;
21262         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
21263         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21264         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21265         uint64_t ret_ref = (uint64_t)ret_var.inner;
21266         if (ret_var.is_owned) {
21267                 ret_ref |= 1;
21268         }
21269         return ret_ref;
21270 }
21271
21272 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
21273         LDKDirectionalChannelInfo obj_conv;
21274         obj_conv.inner = (void*)(obj & (~1));
21275         obj_conv.is_owned = false;
21276         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
21277         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21278         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21279         CVec_u8Z_free(ret_var);
21280         return ret_arr;
21281 }
21282
21283 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
21284         LDKu8slice ser_ref;
21285         ser_ref.datalen = *((uint32_t*)ser);
21286         ser_ref.data = (int8_t*)(ser + 4);
21287         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
21288         *ret_conv = DirectionalChannelInfo_read(ser_ref);
21289         return (uint64_t)ret_conv;
21290 }
21291
21292 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
21293         LDKChannelInfo this_obj_conv;
21294         this_obj_conv.inner = (void*)(this_obj & (~1));
21295         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21296         ChannelInfo_free(this_obj_conv);
21297 }
21298
21299 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
21300         LDKChannelInfo this_ptr_conv;
21301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21302         this_ptr_conv.is_owned = false;
21303         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
21304         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21305         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21306         uint64_t ret_ref = (uint64_t)ret_var.inner;
21307         if (ret_var.is_owned) {
21308                 ret_ref |= 1;
21309         }
21310         return ret_ref;
21311 }
21312
21313 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
21314         LDKChannelInfo this_ptr_conv;
21315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21316         this_ptr_conv.is_owned = false;
21317         LDKChannelFeatures val_conv;
21318         val_conv.inner = (void*)(val & (~1));
21319         val_conv.is_owned = (val & 1) || (val == 0);
21320         val_conv = ChannelFeatures_clone(&val_conv);
21321         ChannelInfo_set_features(&this_ptr_conv, val_conv);
21322 }
21323
21324 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
21325         LDKChannelInfo this_ptr_conv;
21326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21327         this_ptr_conv.is_owned = false;
21328         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21329         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
21330         return ret_arr;
21331 }
21332
21333 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
21334         LDKChannelInfo this_ptr_conv;
21335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21336         this_ptr_conv.is_owned = false;
21337         LDKPublicKey val_ref;
21338         CHECK(*((uint32_t*)val) == 33);
21339         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21340         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
21341 }
21342
21343 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
21344         LDKChannelInfo this_ptr_conv;
21345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21346         this_ptr_conv.is_owned = false;
21347         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
21348         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21349         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21350         uint64_t ret_ref = (uint64_t)ret_var.inner;
21351         if (ret_var.is_owned) {
21352                 ret_ref |= 1;
21353         }
21354         return ret_ref;
21355 }
21356
21357 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
21358         LDKChannelInfo this_ptr_conv;
21359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21360         this_ptr_conv.is_owned = false;
21361         LDKDirectionalChannelInfo val_conv;
21362         val_conv.inner = (void*)(val & (~1));
21363         val_conv.is_owned = (val & 1) || (val == 0);
21364         val_conv = DirectionalChannelInfo_clone(&val_conv);
21365         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
21366 }
21367
21368 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
21369         LDKChannelInfo this_ptr_conv;
21370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21371         this_ptr_conv.is_owned = false;
21372         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21373         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
21374         return ret_arr;
21375 }
21376
21377 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
21378         LDKChannelInfo this_ptr_conv;
21379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21380         this_ptr_conv.is_owned = false;
21381         LDKPublicKey val_ref;
21382         CHECK(*((uint32_t*)val) == 33);
21383         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21384         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
21385 }
21386
21387 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
21388         LDKChannelInfo this_ptr_conv;
21389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21390         this_ptr_conv.is_owned = false;
21391         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
21392         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21393         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21394         uint64_t ret_ref = (uint64_t)ret_var.inner;
21395         if (ret_var.is_owned) {
21396                 ret_ref |= 1;
21397         }
21398         return ret_ref;
21399 }
21400
21401 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
21402         LDKChannelInfo this_ptr_conv;
21403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21404         this_ptr_conv.is_owned = false;
21405         LDKDirectionalChannelInfo val_conv;
21406         val_conv.inner = (void*)(val & (~1));
21407         val_conv.is_owned = (val & 1) || (val == 0);
21408         val_conv = DirectionalChannelInfo_clone(&val_conv);
21409         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
21410 }
21411
21412 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
21413         LDKChannelInfo this_ptr_conv;
21414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21415         this_ptr_conv.is_owned = false;
21416         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21417         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
21418         uint64_t ret_ref = (uint64_t)ret_copy;
21419         return ret_ref;
21420 }
21421
21422 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
21423         LDKChannelInfo this_ptr_conv;
21424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21425         this_ptr_conv.is_owned = false;
21426         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
21427         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
21428 }
21429
21430 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
21431         LDKChannelInfo this_ptr_conv;
21432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21433         this_ptr_conv.is_owned = false;
21434         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
21435         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21436         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21437         uint64_t ret_ref = (uint64_t)ret_var.inner;
21438         if (ret_var.is_owned) {
21439                 ret_ref |= 1;
21440         }
21441         return ret_ref;
21442 }
21443
21444 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
21445         LDKChannelInfo this_ptr_conv;
21446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21447         this_ptr_conv.is_owned = false;
21448         LDKChannelAnnouncement val_conv;
21449         val_conv.inner = (void*)(val & (~1));
21450         val_conv.is_owned = (val & 1) || (val == 0);
21451         val_conv = ChannelAnnouncement_clone(&val_conv);
21452         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
21453 }
21454
21455 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) {
21456         LDKChannelFeatures features_arg_conv;
21457         features_arg_conv.inner = (void*)(features_arg & (~1));
21458         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21459         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
21460         LDKPublicKey node_one_arg_ref;
21461         CHECK(*((uint32_t*)node_one_arg) == 33);
21462         memcpy(node_one_arg_ref.compressed_form, (uint8_t*)(node_one_arg + 4), 33);
21463         LDKDirectionalChannelInfo one_to_two_arg_conv;
21464         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
21465         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
21466         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
21467         LDKPublicKey node_two_arg_ref;
21468         CHECK(*((uint32_t*)node_two_arg) == 33);
21469         memcpy(node_two_arg_ref.compressed_form, (uint8_t*)(node_two_arg + 4), 33);
21470         LDKDirectionalChannelInfo two_to_one_arg_conv;
21471         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
21472         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
21473         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
21474         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
21475         LDKChannelAnnouncement announcement_message_arg_conv;
21476         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
21477         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
21478         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
21479         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);
21480         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21481         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21482         uint64_t ret_ref = (uint64_t)ret_var.inner;
21483         if (ret_var.is_owned) {
21484                 ret_ref |= 1;
21485         }
21486         return ret_ref;
21487 }
21488
21489 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
21490         LDKChannelInfo orig_conv;
21491         orig_conv.inner = (void*)(orig & (~1));
21492         orig_conv.is_owned = false;
21493         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
21494         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21495         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21496         uint64_t ret_ref = (uint64_t)ret_var.inner;
21497         if (ret_var.is_owned) {
21498                 ret_ref |= 1;
21499         }
21500         return ret_ref;
21501 }
21502
21503 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
21504         LDKChannelInfo obj_conv;
21505         obj_conv.inner = (void*)(obj & (~1));
21506         obj_conv.is_owned = false;
21507         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
21508         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21509         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21510         CVec_u8Z_free(ret_var);
21511         return ret_arr;
21512 }
21513
21514 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
21515         LDKu8slice ser_ref;
21516         ser_ref.datalen = *((uint32_t*)ser);
21517         ser_ref.data = (int8_t*)(ser + 4);
21518         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
21519         *ret_conv = ChannelInfo_read(ser_ref);
21520         return (uint64_t)ret_conv;
21521 }
21522
21523 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
21524         LDKRoutingFees this_obj_conv;
21525         this_obj_conv.inner = (void*)(this_obj & (~1));
21526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21527         RoutingFees_free(this_obj_conv);
21528 }
21529
21530 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
21531         LDKRoutingFees this_ptr_conv;
21532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21533         this_ptr_conv.is_owned = false;
21534         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
21535         return ret_val;
21536 }
21537
21538 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
21539         LDKRoutingFees this_ptr_conv;
21540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21541         this_ptr_conv.is_owned = false;
21542         RoutingFees_set_base_msat(&this_ptr_conv, val);
21543 }
21544
21545 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
21546         LDKRoutingFees this_ptr_conv;
21547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21548         this_ptr_conv.is_owned = false;
21549         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
21550         return ret_val;
21551 }
21552
21553 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
21554         LDKRoutingFees this_ptr_conv;
21555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21556         this_ptr_conv.is_owned = false;
21557         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
21558 }
21559
21560 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
21561         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
21562         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21563         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21564         uint64_t ret_ref = (uint64_t)ret_var.inner;
21565         if (ret_var.is_owned) {
21566                 ret_ref |= 1;
21567         }
21568         return ret_ref;
21569 }
21570
21571 jboolean  __attribute__((visibility("default"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
21572         LDKRoutingFees a_conv;
21573         a_conv.inner = (void*)(a & (~1));
21574         a_conv.is_owned = false;
21575         LDKRoutingFees b_conv;
21576         b_conv.inner = (void*)(b & (~1));
21577         b_conv.is_owned = false;
21578         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
21579         return ret_val;
21580 }
21581
21582 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
21583         LDKRoutingFees orig_conv;
21584         orig_conv.inner = (void*)(orig & (~1));
21585         orig_conv.is_owned = false;
21586         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
21587         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21588         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21589         uint64_t ret_ref = (uint64_t)ret_var.inner;
21590         if (ret_var.is_owned) {
21591                 ret_ref |= 1;
21592         }
21593         return ret_ref;
21594 }
21595
21596 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
21597         LDKRoutingFees obj_conv;
21598         obj_conv.inner = (void*)(obj & (~1));
21599         obj_conv.is_owned = false;
21600         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
21601         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21602         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21603         CVec_u8Z_free(ret_var);
21604         return ret_arr;
21605 }
21606
21607 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
21608         LDKu8slice ser_ref;
21609         ser_ref.datalen = *((uint32_t*)ser);
21610         ser_ref.data = (int8_t*)(ser + 4);
21611         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
21612         *ret_conv = RoutingFees_read(ser_ref);
21613         return (uint64_t)ret_conv;
21614 }
21615
21616 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
21617         LDKNodeAnnouncementInfo this_obj_conv;
21618         this_obj_conv.inner = (void*)(this_obj & (~1));
21619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21620         NodeAnnouncementInfo_free(this_obj_conv);
21621 }
21622
21623 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
21624         LDKNodeAnnouncementInfo this_ptr_conv;
21625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21626         this_ptr_conv.is_owned = false;
21627         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
21628         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21629         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21630         uint64_t ret_ref = (uint64_t)ret_var.inner;
21631         if (ret_var.is_owned) {
21632                 ret_ref |= 1;
21633         }
21634         return ret_ref;
21635 }
21636
21637 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
21638         LDKNodeAnnouncementInfo this_ptr_conv;
21639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21640         this_ptr_conv.is_owned = false;
21641         LDKNodeFeatures val_conv;
21642         val_conv.inner = (void*)(val & (~1));
21643         val_conv.is_owned = (val & 1) || (val == 0);
21644         val_conv = NodeFeatures_clone(&val_conv);
21645         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
21646 }
21647
21648 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
21649         LDKNodeAnnouncementInfo this_ptr_conv;
21650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21651         this_ptr_conv.is_owned = false;
21652         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
21653         return ret_val;
21654 }
21655
21656 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
21657         LDKNodeAnnouncementInfo this_ptr_conv;
21658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21659         this_ptr_conv.is_owned = false;
21660         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
21661 }
21662
21663 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
21664         LDKNodeAnnouncementInfo this_ptr_conv;
21665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21666         this_ptr_conv.is_owned = false;
21667         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
21668         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
21669         return ret_arr;
21670 }
21671
21672 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
21673         LDKNodeAnnouncementInfo this_ptr_conv;
21674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21675         this_ptr_conv.is_owned = false;
21676         LDKThreeBytes val_ref;
21677         CHECK(*((uint32_t*)val) == 3);
21678         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
21679         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
21680 }
21681
21682 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
21683         LDKNodeAnnouncementInfo this_ptr_conv;
21684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21685         this_ptr_conv.is_owned = false;
21686         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21687         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
21688         return ret_arr;
21689 }
21690
21691 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
21692         LDKNodeAnnouncementInfo this_ptr_conv;
21693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21694         this_ptr_conv.is_owned = false;
21695         LDKThirtyTwoBytes val_ref;
21696         CHECK(*((uint32_t*)val) == 32);
21697         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
21698         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
21699 }
21700
21701 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
21702         LDKNodeAnnouncementInfo this_ptr_conv;
21703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21704         this_ptr_conv.is_owned = false;
21705         LDKCVec_NetAddressZ val_constr;
21706         val_constr.datalen = *((uint32_t*)val);
21707         if (val_constr.datalen > 0)
21708                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21709         else
21710                 val_constr.data = NULL;
21711         uint32_t* val_vals = (uint32_t*)(val + 4);
21712         for (size_t m = 0; m < val_constr.datalen; m++) {
21713                 uint32_t val_conv_12 = val_vals[m];
21714                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
21715                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
21716                 val_constr.data[m] = val_conv_12_conv;
21717         }
21718         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
21719 }
21720
21721 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
21722         LDKNodeAnnouncementInfo this_ptr_conv;
21723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21724         this_ptr_conv.is_owned = false;
21725         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
21726         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21727         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21728         uint64_t ret_ref = (uint64_t)ret_var.inner;
21729         if (ret_var.is_owned) {
21730                 ret_ref |= 1;
21731         }
21732         return ret_ref;
21733 }
21734
21735 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
21736         LDKNodeAnnouncementInfo this_ptr_conv;
21737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21738         this_ptr_conv.is_owned = false;
21739         LDKNodeAnnouncement val_conv;
21740         val_conv.inner = (void*)(val & (~1));
21741         val_conv.is_owned = (val & 1) || (val == 0);
21742         val_conv = NodeAnnouncement_clone(&val_conv);
21743         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
21744 }
21745
21746 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) {
21747         LDKNodeFeatures features_arg_conv;
21748         features_arg_conv.inner = (void*)(features_arg & (~1));
21749         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21750         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
21751         LDKThreeBytes rgb_arg_ref;
21752         CHECK(*((uint32_t*)rgb_arg) == 3);
21753         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
21754         LDKThirtyTwoBytes alias_arg_ref;
21755         CHECK(*((uint32_t*)alias_arg) == 32);
21756         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
21757         LDKCVec_NetAddressZ addresses_arg_constr;
21758         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
21759         if (addresses_arg_constr.datalen > 0)
21760                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21761         else
21762                 addresses_arg_constr.data = NULL;
21763         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
21764         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
21765                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
21766                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
21767                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
21768         }
21769         LDKNodeAnnouncement announcement_message_arg_conv;
21770         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
21771         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
21772         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
21773         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
21774         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21775         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21776         uint64_t ret_ref = (uint64_t)ret_var.inner;
21777         if (ret_var.is_owned) {
21778                 ret_ref |= 1;
21779         }
21780         return ret_ref;
21781 }
21782
21783 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
21784         LDKNodeAnnouncementInfo orig_conv;
21785         orig_conv.inner = (void*)(orig & (~1));
21786         orig_conv.is_owned = false;
21787         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
21788         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21789         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21790         uint64_t ret_ref = (uint64_t)ret_var.inner;
21791         if (ret_var.is_owned) {
21792                 ret_ref |= 1;
21793         }
21794         return ret_ref;
21795 }
21796
21797 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
21798         LDKNodeAnnouncementInfo obj_conv;
21799         obj_conv.inner = (void*)(obj & (~1));
21800         obj_conv.is_owned = false;
21801         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
21802         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21803         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21804         CVec_u8Z_free(ret_var);
21805         return ret_arr;
21806 }
21807
21808 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
21809         LDKu8slice ser_ref;
21810         ser_ref.datalen = *((uint32_t*)ser);
21811         ser_ref.data = (int8_t*)(ser + 4);
21812         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
21813         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
21814         return (uint64_t)ret_conv;
21815 }
21816
21817 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
21818         LDKNodeInfo this_obj_conv;
21819         this_obj_conv.inner = (void*)(this_obj & (~1));
21820         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21821         NodeInfo_free(this_obj_conv);
21822 }
21823
21824 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
21825         LDKNodeInfo this_ptr_conv;
21826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21827         this_ptr_conv.is_owned = false;
21828         LDKCVec_u64Z val_constr;
21829         val_constr.datalen = *((uint32_t*)val);
21830         if (val_constr.datalen > 0)
21831                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21832         else
21833                 val_constr.data = NULL;
21834         int64_t* val_vals = (int64_t*)(val + 4);
21835         for (size_t i = 0; i < val_constr.datalen; i++) {
21836                 int64_t val_conv_8 = val_vals[i];
21837                 val_constr.data[i] = val_conv_8;
21838         }
21839         NodeInfo_set_channels(&this_ptr_conv, val_constr);
21840 }
21841
21842 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
21843         LDKNodeInfo this_ptr_conv;
21844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21845         this_ptr_conv.is_owned = false;
21846         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
21847         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21848         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21849         uint64_t ret_ref = (uint64_t)ret_var.inner;
21850         if (ret_var.is_owned) {
21851                 ret_ref |= 1;
21852         }
21853         return ret_ref;
21854 }
21855
21856 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
21857         LDKNodeInfo this_ptr_conv;
21858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21859         this_ptr_conv.is_owned = false;
21860         LDKRoutingFees val_conv;
21861         val_conv.inner = (void*)(val & (~1));
21862         val_conv.is_owned = (val & 1) || (val == 0);
21863         val_conv = RoutingFees_clone(&val_conv);
21864         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
21865 }
21866
21867 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
21868         LDKNodeInfo this_ptr_conv;
21869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21870         this_ptr_conv.is_owned = false;
21871         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
21872         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21873         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21874         uint64_t ret_ref = (uint64_t)ret_var.inner;
21875         if (ret_var.is_owned) {
21876                 ret_ref |= 1;
21877         }
21878         return ret_ref;
21879 }
21880
21881 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
21882         LDKNodeInfo this_ptr_conv;
21883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21884         this_ptr_conv.is_owned = false;
21885         LDKNodeAnnouncementInfo val_conv;
21886         val_conv.inner = (void*)(val & (~1));
21887         val_conv.is_owned = (val & 1) || (val == 0);
21888         val_conv = NodeAnnouncementInfo_clone(&val_conv);
21889         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
21890 }
21891
21892 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
21893         LDKCVec_u64Z channels_arg_constr;
21894         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
21895         if (channels_arg_constr.datalen > 0)
21896                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21897         else
21898                 channels_arg_constr.data = NULL;
21899         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
21900         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
21901                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
21902                 channels_arg_constr.data[i] = channels_arg_conv_8;
21903         }
21904         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
21905         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
21906         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
21907         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
21908         LDKNodeAnnouncementInfo announcement_info_arg_conv;
21909         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
21910         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
21911         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
21912         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
21913         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21914         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21915         uint64_t ret_ref = (uint64_t)ret_var.inner;
21916         if (ret_var.is_owned) {
21917                 ret_ref |= 1;
21918         }
21919         return ret_ref;
21920 }
21921
21922 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
21923         LDKNodeInfo orig_conv;
21924         orig_conv.inner = (void*)(orig & (~1));
21925         orig_conv.is_owned = false;
21926         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
21927         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21928         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21929         uint64_t ret_ref = (uint64_t)ret_var.inner;
21930         if (ret_var.is_owned) {
21931                 ret_ref |= 1;
21932         }
21933         return ret_ref;
21934 }
21935
21936 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
21937         LDKNodeInfo obj_conv;
21938         obj_conv.inner = (void*)(obj & (~1));
21939         obj_conv.is_owned = false;
21940         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
21941         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21942         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21943         CVec_u8Z_free(ret_var);
21944         return ret_arr;
21945 }
21946
21947 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
21948         LDKu8slice ser_ref;
21949         ser_ref.datalen = *((uint32_t*)ser);
21950         ser_ref.data = (int8_t*)(ser + 4);
21951         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
21952         *ret_conv = NodeInfo_read(ser_ref);
21953         return (uint64_t)ret_conv;
21954 }
21955
21956 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
21957         LDKNetworkGraph obj_conv;
21958         obj_conv.inner = (void*)(obj & (~1));
21959         obj_conv.is_owned = false;
21960         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
21961         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21962         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21963         CVec_u8Z_free(ret_var);
21964         return ret_arr;
21965 }
21966
21967 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
21968         LDKu8slice ser_ref;
21969         ser_ref.datalen = *((uint32_t*)ser);
21970         ser_ref.data = (int8_t*)(ser + 4);
21971         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
21972         *ret_conv = NetworkGraph_read(ser_ref);
21973         return (uint64_t)ret_conv;
21974 }
21975
21976 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
21977         LDKThirtyTwoBytes genesis_hash_ref;
21978         CHECK(*((uint32_t*)genesis_hash) == 32);
21979         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
21980         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
21981         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21982         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21983         uint64_t ret_ref = (uint64_t)ret_var.inner;
21984         if (ret_var.is_owned) {
21985                 ret_ref |= 1;
21986         }
21987         return ret_ref;
21988 }
21989
21990 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
21991         LDKNetworkGraph this_arg_conv;
21992         this_arg_conv.inner = (void*)(this_arg & (~1));
21993         this_arg_conv.is_owned = false;
21994         LDKNodeAnnouncement msg_conv;
21995         msg_conv.inner = (void*)(msg & (~1));
21996         msg_conv.is_owned = false;
21997         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21998         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
21999         return (uint64_t)ret_conv;
22000 }
22001
22002 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
22003         LDKNetworkGraph this_arg_conv;
22004         this_arg_conv.inner = (void*)(this_arg & (~1));
22005         this_arg_conv.is_owned = false;
22006         LDKUnsignedNodeAnnouncement msg_conv;
22007         msg_conv.inner = (void*)(msg & (~1));
22008         msg_conv.is_owned = false;
22009         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
22010         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
22011         return (uint64_t)ret_conv;
22012 }
22013
22014 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
22015         LDKNetworkGraph this_arg_conv;
22016         this_arg_conv.inner = (void*)(this_arg & (~1));
22017         this_arg_conv.is_owned = false;
22018         LDKChannelAnnouncement msg_conv;
22019         msg_conv.inner = (void*)(msg & (~1));
22020         msg_conv.is_owned = false;
22021         LDKAccess *chain_access_conv_ptr = NULL;
22022         if (chain_access != 0) {
22023                 LDKAccess chain_access_conv;
22024                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
22025                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
22026                 *chain_access_conv_ptr = chain_access_conv;
22027         }
22028         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
22029         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
22030         return (uint64_t)ret_conv;
22031 }
22032
22033 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
22034         LDKNetworkGraph this_arg_conv;
22035         this_arg_conv.inner = (void*)(this_arg & (~1));
22036         this_arg_conv.is_owned = false;
22037         LDKUnsignedChannelAnnouncement msg_conv;
22038         msg_conv.inner = (void*)(msg & (~1));
22039         msg_conv.is_owned = false;
22040         LDKAccess *chain_access_conv_ptr = NULL;
22041         if (chain_access != 0) {
22042                 LDKAccess chain_access_conv;
22043                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
22044                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
22045                 *chain_access_conv_ptr = chain_access_conv;
22046         }
22047         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
22048         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
22049         return (uint64_t)ret_conv;
22050 }
22051
22052 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
22053         LDKNetworkGraph this_arg_conv;
22054         this_arg_conv.inner = (void*)(this_arg & (~1));
22055         this_arg_conv.is_owned = false;
22056         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
22057 }
22058
22059 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
22060         LDKNetworkGraph this_arg_conv;
22061         this_arg_conv.inner = (void*)(this_arg & (~1));
22062         this_arg_conv.is_owned = false;
22063         LDKChannelUpdate msg_conv;
22064         msg_conv.inner = (void*)(msg & (~1));
22065         msg_conv.is_owned = false;
22066         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
22067         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
22068         return (uint64_t)ret_conv;
22069 }
22070
22071 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
22072         LDKNetworkGraph this_arg_conv;
22073         this_arg_conv.inner = (void*)(this_arg & (~1));
22074         this_arg_conv.is_owned = false;
22075         LDKUnsignedChannelUpdate msg_conv;
22076         msg_conv.inner = (void*)(msg & (~1));
22077         msg_conv.is_owned = false;
22078         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
22079         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
22080         return (uint64_t)ret_conv;
22081 }
22082
22083 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
22084         LDKFilesystemPersister this_obj_conv;
22085         this_obj_conv.inner = (void*)(this_obj & (~1));
22086         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22087         FilesystemPersister_free(this_obj_conv);
22088 }
22089
22090 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
22091         LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
22092         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
22093         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22094         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22095         uint64_t ret_ref = (uint64_t)ret_var.inner;
22096         if (ret_var.is_owned) {
22097                 ret_ref |= 1;
22098         }
22099         return ret_ref;
22100 }
22101
22102 jstring  __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_dir(uint32_t this_arg) {
22103         LDKFilesystemPersister this_arg_conv;
22104         this_arg_conv.inner = (void*)(this_arg & (~1));
22105         this_arg_conv.is_owned = false;
22106         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
22107         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22108         return ret_conv;
22109 }
22110
22111 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_persist_manager(jstring data_dir, uint32_t manager) {
22112         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
22113         LDKChannelManager manager_conv;
22114         manager_conv.inner = (void*)(manager & (~1));
22115         manager_conv.is_owned = false;
22116         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
22117         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
22118         return (uint64_t)ret_conv;
22119 }
22120
22121 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_channelmonitors(uint32_t this_arg, uint32_t keys_manager) {
22122         LDKFilesystemPersister this_arg_conv;
22123         this_arg_conv.inner = (void*)(this_arg & (~1));
22124         this_arg_conv.is_owned = false;
22125         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
22126         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
22127         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
22128         return (uint64_t)ret_conv;
22129 }
22130
22131 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persist(uint32_t this_arg) {
22132         LDKFilesystemPersister this_arg_conv;
22133         this_arg_conv.inner = (void*)(this_arg & (~1));
22134         this_arg_conv.is_owned = false;
22135         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
22136         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
22137         return (uint64_t)ret;
22138 }
22139
22140 void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) {
22141         LDKBackgroundProcessor this_obj_conv;
22142         this_obj_conv.inner = (void*)(this_obj & (~1));
22143         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22144         BackgroundProcessor_free(this_obj_conv);
22145 }
22146
22147 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
22148         if ((this_ptr & 1) != 0) return;
22149         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
22150         FREE((void*)this_ptr);
22151         ChannelManagerPersister_free(this_ptr_conv);
22152 }
22153
22154 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) {
22155         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
22156         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
22157         LDKChainMonitor chain_monitor_conv;
22158         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
22159         chain_monitor_conv.is_owned = false;
22160         LDKChannelManager channel_manager_conv;
22161         channel_manager_conv.inner = (void*)(channel_manager & (~1));
22162         channel_manager_conv.is_owned = false;
22163         LDKPeerManager peer_manager_conv;
22164         peer_manager_conv.inner = (void*)(peer_manager & (~1));
22165         peer_manager_conv.is_owned = false;
22166         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
22167         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
22168         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22169         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22170         uint64_t ret_ref = (uint64_t)ret_var.inner;
22171         if (ret_var.is_owned) {
22172                 ret_ref |= 1;
22173         }
22174         return ret_ref;
22175 }
22176
22177 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_stop(uint32_t this_arg) {
22178         LDKBackgroundProcessor this_arg_conv;
22179         this_arg_conv.inner = (void*)(this_arg & (~1));
22180         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22181         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
22182         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
22183         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
22184         return (uint64_t)ret_conv;
22185 }
22186
22187 void  __attribute__((visibility("default"))) TS_check_platform() {
22188         check_platform();
22189 }
22190
22191 void  __attribute__((visibility("default"))) TS_Invoice_free(uint32_t this_obj) {
22192         LDKInvoice this_obj_conv;
22193         this_obj_conv.inner = (void*)(this_obj & (~1));
22194         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22195         Invoice_free(this_obj_conv);
22196 }
22197
22198 jboolean  __attribute__((visibility("default"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
22199         LDKInvoice a_conv;
22200         a_conv.inner = (void*)(a & (~1));
22201         a_conv.is_owned = false;
22202         LDKInvoice b_conv;
22203         b_conv.inner = (void*)(b & (~1));
22204         b_conv.is_owned = false;
22205         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
22206         return ret_val;
22207 }
22208
22209 uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig) {
22210         LDKInvoice orig_conv;
22211         orig_conv.inner = (void*)(orig & (~1));
22212         orig_conv.is_owned = false;
22213         LDKInvoice ret_var = Invoice_clone(&orig_conv);
22214         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22215         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22216         uint64_t ret_ref = (uint64_t)ret_var.inner;
22217         if (ret_var.is_owned) {
22218                 ret_ref |= 1;
22219         }
22220         return ret_ref;
22221 }
22222
22223 void  __attribute__((visibility("default"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
22224         LDKSignedRawInvoice this_obj_conv;
22225         this_obj_conv.inner = (void*)(this_obj & (~1));
22226         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22227         SignedRawInvoice_free(this_obj_conv);
22228 }
22229
22230 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
22231         LDKSignedRawInvoice a_conv;
22232         a_conv.inner = (void*)(a & (~1));
22233         a_conv.is_owned = false;
22234         LDKSignedRawInvoice b_conv;
22235         b_conv.inner = (void*)(b & (~1));
22236         b_conv.is_owned = false;
22237         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
22238         return ret_val;
22239 }
22240
22241 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint32_t orig) {
22242         LDKSignedRawInvoice orig_conv;
22243         orig_conv.inner = (void*)(orig & (~1));
22244         orig_conv.is_owned = false;
22245         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
22246         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22247         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22248         uint64_t ret_ref = (uint64_t)ret_var.inner;
22249         if (ret_var.is_owned) {
22250                 ret_ref |= 1;
22251         }
22252         return ret_ref;
22253 }
22254
22255 void  __attribute__((visibility("default"))) TS_RawInvoice_free(uint32_t this_obj) {
22256         LDKRawInvoice this_obj_conv;
22257         this_obj_conv.inner = (void*)(this_obj & (~1));
22258         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22259         RawInvoice_free(this_obj_conv);
22260 }
22261
22262 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
22263         LDKRawInvoice this_ptr_conv;
22264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22265         this_ptr_conv.is_owned = false;
22266         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
22267         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22268         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22269         uint64_t ret_ref = (uint64_t)ret_var.inner;
22270         if (ret_var.is_owned) {
22271                 ret_ref |= 1;
22272         }
22273         return ret_ref;
22274 }
22275
22276 void  __attribute__((visibility("default"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
22277         LDKRawInvoice this_ptr_conv;
22278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22279         this_ptr_conv.is_owned = false;
22280         LDKRawDataPart val_conv;
22281         val_conv.inner = (void*)(val & (~1));
22282         val_conv.is_owned = (val & 1) || (val == 0);
22283         val_conv = RawDataPart_clone(&val_conv);
22284         RawInvoice_set_data(&this_ptr_conv, val_conv);
22285 }
22286
22287 jboolean  __attribute__((visibility("default"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
22288         LDKRawInvoice a_conv;
22289         a_conv.inner = (void*)(a & (~1));
22290         a_conv.is_owned = false;
22291         LDKRawInvoice b_conv;
22292         b_conv.inner = (void*)(b & (~1));
22293         b_conv.is_owned = false;
22294         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
22295         return ret_val;
22296 }
22297
22298 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t orig) {
22299         LDKRawInvoice orig_conv;
22300         orig_conv.inner = (void*)(orig & (~1));
22301         orig_conv.is_owned = false;
22302         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
22303         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22304         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22305         uint64_t ret_ref = (uint64_t)ret_var.inner;
22306         if (ret_var.is_owned) {
22307                 ret_ref |= 1;
22308         }
22309         return ret_ref;
22310 }
22311
22312 void  __attribute__((visibility("default"))) TS_RawDataPart_free(uint32_t this_obj) {
22313         LDKRawDataPart this_obj_conv;
22314         this_obj_conv.inner = (void*)(this_obj & (~1));
22315         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22316         RawDataPart_free(this_obj_conv);
22317 }
22318
22319 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
22320         LDKRawDataPart this_ptr_conv;
22321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22322         this_ptr_conv.is_owned = false;
22323         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
22324         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22325         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22326         uint64_t ret_ref = (uint64_t)ret_var.inner;
22327         if (ret_var.is_owned) {
22328                 ret_ref |= 1;
22329         }
22330         return ret_ref;
22331 }
22332
22333 void  __attribute__((visibility("default"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
22334         LDKRawDataPart this_ptr_conv;
22335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22336         this_ptr_conv.is_owned = false;
22337         LDKPositiveTimestamp val_conv;
22338         val_conv.inner = (void*)(val & (~1));
22339         val_conv.is_owned = (val & 1) || (val == 0);
22340         val_conv = PositiveTimestamp_clone(&val_conv);
22341         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
22342 }
22343
22344 jboolean  __attribute__((visibility("default"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
22345         LDKRawDataPart a_conv;
22346         a_conv.inner = (void*)(a & (~1));
22347         a_conv.is_owned = false;
22348         LDKRawDataPart b_conv;
22349         b_conv.inner = (void*)(b & (~1));
22350         b_conv.is_owned = false;
22351         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
22352         return ret_val;
22353 }
22354
22355 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t orig) {
22356         LDKRawDataPart orig_conv;
22357         orig_conv.inner = (void*)(orig & (~1));
22358         orig_conv.is_owned = false;
22359         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
22360         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22361         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22362         uint64_t ret_ref = (uint64_t)ret_var.inner;
22363         if (ret_var.is_owned) {
22364                 ret_ref |= 1;
22365         }
22366         return ret_ref;
22367 }
22368
22369 void  __attribute__((visibility("default"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
22370         LDKPositiveTimestamp this_obj_conv;
22371         this_obj_conv.inner = (void*)(this_obj & (~1));
22372         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22373         PositiveTimestamp_free(this_obj_conv);
22374 }
22375
22376 jboolean  __attribute__((visibility("default"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
22377         LDKPositiveTimestamp a_conv;
22378         a_conv.inner = (void*)(a & (~1));
22379         a_conv.is_owned = false;
22380         LDKPositiveTimestamp b_conv;
22381         b_conv.inner = (void*)(b & (~1));
22382         b_conv.is_owned = false;
22383         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
22384         return ret_val;
22385 }
22386
22387 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint32_t orig) {
22388         LDKPositiveTimestamp orig_conv;
22389         orig_conv.inner = (void*)(orig & (~1));
22390         orig_conv.is_owned = false;
22391         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
22392         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22393         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22394         uint64_t ret_ref = (uint64_t)ret_var.inner;
22395         if (ret_var.is_owned) {
22396                 ret_ref |= 1;
22397         }
22398         return ret_ref;
22399 }
22400
22401 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_clone(uint32_t orig) {
22402         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
22403         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
22404         return ret_conv;
22405 }
22406
22407 jboolean  __attribute__((visibility("default"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
22408         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
22409         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
22410         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
22411         return ret_val;
22412 }
22413
22414 int64_t  __attribute__((visibility("default"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
22415         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
22416         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
22417         return ret_val;
22418 }
22419
22420 uint32_t  __attribute__((visibility("default"))) TS_Currency_clone(uint32_t orig) {
22421         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
22422         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
22423         return ret_conv;
22424 }
22425
22426 jboolean  __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) {
22427         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
22428         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
22429         jboolean ret_val = Currency_eq(a_conv, b_conv);
22430         return ret_val;
22431 }
22432
22433 void  __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) {
22434         LDKSha256 this_obj_conv;
22435         this_obj_conv.inner = (void*)(this_obj & (~1));
22436         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22437         Sha256_free(this_obj_conv);
22438 }
22439
22440 jboolean  __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
22441         LDKSha256 a_conv;
22442         a_conv.inner = (void*)(a & (~1));
22443         a_conv.is_owned = false;
22444         LDKSha256 b_conv;
22445         b_conv.inner = (void*)(b & (~1));
22446         b_conv.is_owned = false;
22447         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
22448         return ret_val;
22449 }
22450
22451 uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) {
22452         LDKSha256 orig_conv;
22453         orig_conv.inner = (void*)(orig & (~1));
22454         orig_conv.is_owned = false;
22455         LDKSha256 ret_var = Sha256_clone(&orig_conv);
22456         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22457         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22458         uint64_t ret_ref = (uint64_t)ret_var.inner;
22459         if (ret_var.is_owned) {
22460                 ret_ref |= 1;
22461         }
22462         return ret_ref;
22463 }
22464
22465 void  __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) {
22466         LDKDescription this_obj_conv;
22467         this_obj_conv.inner = (void*)(this_obj & (~1));
22468         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22469         Description_free(this_obj_conv);
22470 }
22471
22472 jboolean  __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) {
22473         LDKDescription a_conv;
22474         a_conv.inner = (void*)(a & (~1));
22475         a_conv.is_owned = false;
22476         LDKDescription b_conv;
22477         b_conv.inner = (void*)(b & (~1));
22478         b_conv.is_owned = false;
22479         jboolean ret_val = Description_eq(&a_conv, &b_conv);
22480         return ret_val;
22481 }
22482
22483 uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) {
22484         LDKDescription orig_conv;
22485         orig_conv.inner = (void*)(orig & (~1));
22486         orig_conv.is_owned = false;
22487         LDKDescription ret_var = Description_clone(&orig_conv);
22488         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22489         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22490         uint64_t ret_ref = (uint64_t)ret_var.inner;
22491         if (ret_var.is_owned) {
22492                 ret_ref |= 1;
22493         }
22494         return ret_ref;
22495 }
22496
22497 void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) {
22498         LDKPayeePubKey this_obj_conv;
22499         this_obj_conv.inner = (void*)(this_obj & (~1));
22500         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22501         PayeePubKey_free(this_obj_conv);
22502 }
22503
22504 jboolean  __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
22505         LDKPayeePubKey a_conv;
22506         a_conv.inner = (void*)(a & (~1));
22507         a_conv.is_owned = false;
22508         LDKPayeePubKey b_conv;
22509         b_conv.inner = (void*)(b & (~1));
22510         b_conv.is_owned = false;
22511         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
22512         return ret_val;
22513 }
22514
22515 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) {
22516         LDKPayeePubKey orig_conv;
22517         orig_conv.inner = (void*)(orig & (~1));
22518         orig_conv.is_owned = false;
22519         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
22520         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22521         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22522         uint64_t ret_ref = (uint64_t)ret_var.inner;
22523         if (ret_var.is_owned) {
22524                 ret_ref |= 1;
22525         }
22526         return ret_ref;
22527 }
22528
22529 void  __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) {
22530         LDKExpiryTime this_obj_conv;
22531         this_obj_conv.inner = (void*)(this_obj & (~1));
22532         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22533         ExpiryTime_free(this_obj_conv);
22534 }
22535
22536 jboolean  __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
22537         LDKExpiryTime a_conv;
22538         a_conv.inner = (void*)(a & (~1));
22539         a_conv.is_owned = false;
22540         LDKExpiryTime b_conv;
22541         b_conv.inner = (void*)(b & (~1));
22542         b_conv.is_owned = false;
22543         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
22544         return ret_val;
22545 }
22546
22547 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) {
22548         LDKExpiryTime orig_conv;
22549         orig_conv.inner = (void*)(orig & (~1));
22550         orig_conv.is_owned = false;
22551         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
22552         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22553         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22554         uint64_t ret_ref = (uint64_t)ret_var.inner;
22555         if (ret_var.is_owned) {
22556                 ret_ref |= 1;
22557         }
22558         return ret_ref;
22559 }
22560
22561 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
22562         LDKMinFinalCltvExpiry this_obj_conv;
22563         this_obj_conv.inner = (void*)(this_obj & (~1));
22564         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22565         MinFinalCltvExpiry_free(this_obj_conv);
22566 }
22567
22568 jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
22569         LDKMinFinalCltvExpiry a_conv;
22570         a_conv.inner = (void*)(a & (~1));
22571         a_conv.is_owned = false;
22572         LDKMinFinalCltvExpiry b_conv;
22573         b_conv.inner = (void*)(b & (~1));
22574         b_conv.is_owned = false;
22575         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
22576         return ret_val;
22577 }
22578
22579 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
22580         LDKMinFinalCltvExpiry orig_conv;
22581         orig_conv.inner = (void*)(orig & (~1));
22582         orig_conv.is_owned = false;
22583         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
22584         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22585         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22586         uint64_t ret_ref = (uint64_t)ret_var.inner;
22587         if (ret_var.is_owned) {
22588                 ret_ref |= 1;
22589         }
22590         return ret_ref;
22591 }
22592
22593 void  __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) {
22594         if ((this_ptr & 1) != 0) return;
22595         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
22596         FREE((void*)this_ptr);
22597         Fallback_free(this_ptr_conv);
22598 }
22599
22600 uint32_t  __attribute__((visibility("default"))) TS_Fallback_clone(uint32_t orig) {
22601         LDKFallback* orig_conv = (LDKFallback*)orig;
22602         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
22603         *ret_copy = Fallback_clone(orig_conv);
22604         uint64_t ret_ref = (uint64_t)ret_copy;
22605         return ret_ref;
22606 }
22607
22608 jboolean  __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
22609         LDKFallback* a_conv = (LDKFallback*)a;
22610         LDKFallback* b_conv = (LDKFallback*)b;
22611         jboolean ret_val = Fallback_eq(a_conv, b_conv);
22612         return ret_val;
22613 }
22614
22615 void  __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t this_obj) {
22616         LDKInvoiceSignature this_obj_conv;
22617         this_obj_conv.inner = (void*)(this_obj & (~1));
22618         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22619         InvoiceSignature_free(this_obj_conv);
22620 }
22621
22622 jboolean  __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
22623         LDKInvoiceSignature a_conv;
22624         a_conv.inner = (void*)(a & (~1));
22625         a_conv.is_owned = false;
22626         LDKInvoiceSignature b_conv;
22627         b_conv.inner = (void*)(b & (~1));
22628         b_conv.is_owned = false;
22629         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
22630         return ret_val;
22631 }
22632
22633 uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) {
22634         LDKInvoiceSignature orig_conv;
22635         orig_conv.inner = (void*)(orig & (~1));
22636         orig_conv.is_owned = false;
22637         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
22638         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22639         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22640         uint64_t ret_ref = (uint64_t)ret_var.inner;
22641         if (ret_var.is_owned) {
22642                 ret_ref |= 1;
22643         }
22644         return ret_ref;
22645 }
22646
22647 void  __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) {
22648         LDKPrivateRoute this_obj_conv;
22649         this_obj_conv.inner = (void*)(this_obj & (~1));
22650         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22651         PrivateRoute_free(this_obj_conv);
22652 }
22653
22654 jboolean  __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
22655         LDKPrivateRoute a_conv;
22656         a_conv.inner = (void*)(a & (~1));
22657         a_conv.is_owned = false;
22658         LDKPrivateRoute b_conv;
22659         b_conv.inner = (void*)(b & (~1));
22660         b_conv.is_owned = false;
22661         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
22662         return ret_val;
22663 }
22664
22665 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) {
22666         LDKPrivateRoute orig_conv;
22667         orig_conv.inner = (void*)(orig & (~1));
22668         orig_conv.is_owned = false;
22669         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
22670         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22671         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22672         uint64_t ret_ref = (uint64_t)ret_var.inner;
22673         if (ret_var.is_owned) {
22674                 ret_ref |= 1;
22675         }
22676         return ret_ref;
22677 }
22678
22679 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
22680         LDKSignedRawInvoice this_arg_conv;
22681         this_arg_conv.inner = (void*)(this_arg & (~1));
22682         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22683         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
22684         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
22685         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
22686         return (uint64_t)ret_ref;
22687 }
22688
22689 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
22690         LDKSignedRawInvoice this_arg_conv;
22691         this_arg_conv.inner = (void*)(this_arg & (~1));
22692         this_arg_conv.is_owned = false;
22693         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
22694         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22695         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22696         uint64_t ret_ref = (uint64_t)ret_var.inner;
22697         if (ret_var.is_owned) {
22698                 ret_ref |= 1;
22699         }
22700         return ret_ref;
22701 }
22702
22703 int8_tArray  __attribute__((visibility("default"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
22704         LDKSignedRawInvoice this_arg_conv;
22705         this_arg_conv.inner = (void*)(this_arg & (~1));
22706         this_arg_conv.is_owned = false;
22707         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22708         memcpy((uint8_t*)(ret_arr + 4), *SignedRawInvoice_hash(&this_arg_conv), 32);
22709         return ret_arr;
22710 }
22711
22712 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
22713         LDKSignedRawInvoice this_arg_conv;
22714         this_arg_conv.inner = (void*)(this_arg & (~1));
22715         this_arg_conv.is_owned = false;
22716         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
22717         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22718         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22719         uint64_t ret_ref = (uint64_t)ret_var.inner;
22720         if (ret_var.is_owned) {
22721                 ret_ref |= 1;
22722         }
22723         return ret_ref;
22724 }
22725
22726 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
22727         LDKSignedRawInvoice this_arg_conv;
22728         this_arg_conv.inner = (void*)(this_arg & (~1));
22729         this_arg_conv.is_owned = false;
22730         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
22731         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
22732         return (uint64_t)ret_conv;
22733 }
22734
22735 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
22736         LDKSignedRawInvoice this_arg_conv;
22737         this_arg_conv.inner = (void*)(this_arg & (~1));
22738         this_arg_conv.is_owned = false;
22739         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
22740         return ret_val;
22741 }
22742
22743 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_hash(uint32_t this_arg) {
22744         LDKRawInvoice this_arg_conv;
22745         this_arg_conv.inner = (void*)(this_arg & (~1));
22746         this_arg_conv.is_owned = false;
22747         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22748         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_hash(&this_arg_conv).data, 32);
22749         return ret_arr;
22750 }
22751
22752 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
22753         LDKRawInvoice this_arg_conv;
22754         this_arg_conv.inner = (void*)(this_arg & (~1));
22755         this_arg_conv.is_owned = false;
22756         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
22757         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22758         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22759         uint64_t ret_ref = (uint64_t)ret_var.inner;
22760         if (ret_var.is_owned) {
22761                 ret_ref |= 1;
22762         }
22763         return ret_ref;
22764 }
22765
22766 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint32_t this_arg) {
22767         LDKRawInvoice this_arg_conv;
22768         this_arg_conv.inner = (void*)(this_arg & (~1));
22769         this_arg_conv.is_owned = false;
22770         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
22771         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22772         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22773         uint64_t ret_ref = (uint64_t)ret_var.inner;
22774         if (ret_var.is_owned) {
22775                 ret_ref |= 1;
22776         }
22777         return ret_ref;
22778 }
22779
22780 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
22781         LDKRawInvoice this_arg_conv;
22782         this_arg_conv.inner = (void*)(this_arg & (~1));
22783         this_arg_conv.is_owned = false;
22784         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
22785         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22786         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22787         uint64_t ret_ref = (uint64_t)ret_var.inner;
22788         if (ret_var.is_owned) {
22789                 ret_ref |= 1;
22790         }
22791         return ret_ref;
22792 }
22793
22794 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
22795         LDKRawInvoice this_arg_conv;
22796         this_arg_conv.inner = (void*)(this_arg & (~1));
22797         this_arg_conv.is_owned = false;
22798         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
22799         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22800         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22801         uint64_t ret_ref = (uint64_t)ret_var.inner;
22802         if (ret_var.is_owned) {
22803                 ret_ref |= 1;
22804         }
22805         return ret_ref;
22806 }
22807
22808 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
22809         LDKRawInvoice this_arg_conv;
22810         this_arg_conv.inner = (void*)(this_arg & (~1));
22811         this_arg_conv.is_owned = false;
22812         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
22813         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22814         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22815         uint64_t ret_ref = (uint64_t)ret_var.inner;
22816         if (ret_var.is_owned) {
22817                 ret_ref |= 1;
22818         }
22819         return ret_ref;
22820 }
22821
22822 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
22823         LDKRawInvoice this_arg_conv;
22824         this_arg_conv.inner = (void*)(this_arg & (~1));
22825         this_arg_conv.is_owned = false;
22826         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
22827         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22828         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22829         uint64_t ret_ref = (uint64_t)ret_var.inner;
22830         if (ret_var.is_owned) {
22831                 ret_ref |= 1;
22832         }
22833         return ret_ref;
22834 }
22835
22836 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
22837         LDKRawInvoice this_arg_conv;
22838         this_arg_conv.inner = (void*)(this_arg & (~1));
22839         this_arg_conv.is_owned = false;
22840         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22841         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_payment_secret(&this_arg_conv).data, 32);
22842         return ret_arr;
22843 }
22844
22845 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t this_arg) {
22846         LDKRawInvoice this_arg_conv;
22847         this_arg_conv.inner = (void*)(this_arg & (~1));
22848         this_arg_conv.is_owned = false;
22849         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
22850         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22851         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22852         uint64_t ret_ref = (uint64_t)ret_var.inner;
22853         if (ret_var.is_owned) {
22854                 ret_ref |= 1;
22855         }
22856         return ret_ref;
22857 }
22858
22859 uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
22860         LDKRawInvoice this_arg_conv;
22861         this_arg_conv.inner = (void*)(this_arg & (~1));
22862         this_arg_conv.is_owned = false;
22863         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
22864         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
22865         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
22866         for (size_t o = 0; o < ret_var.datalen; o++) {
22867                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
22868                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22869                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22870                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
22871                 if (ret_conv_14_var.is_owned) {
22872                         ret_conv_14_ref |= 1;
22873                 }
22874                 ret_arr_ptr[o] = ret_conv_14_ref;
22875         }
22876         FREE(ret_var.data);
22877         return ret_arr;
22878 }
22879
22880 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
22881         LDKRawInvoice this_arg_conv;
22882         this_arg_conv.inner = (void*)(this_arg & (~1));
22883         this_arg_conv.is_owned = false;
22884         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
22885         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
22886         uint64_t ret_ref = (uint64_t)ret_copy;
22887         return ret_ref;
22888 }
22889
22890 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_currency(uint32_t this_arg) {
22891         LDKRawInvoice this_arg_conv;
22892         this_arg_conv.inner = (void*)(this_arg & (~1));
22893         this_arg_conv.is_owned = false;
22894         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
22895         return ret_conv;
22896 }
22897
22898 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
22899         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
22900         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
22901         return (uint64_t)ret_conv;
22902 }
22903
22904 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_system_time(int64_t time) {
22905         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
22906         *ret_conv = PositiveTimestamp_from_system_time(time);
22907         return (uint64_t)ret_conv;
22908 }
22909
22910 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
22911         LDKPositiveTimestamp this_arg_conv;
22912         this_arg_conv.inner = (void*)(this_arg & (~1));
22913         this_arg_conv.is_owned = false;
22914         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
22915         return ret_val;
22916 }
22917
22918 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_time(uint32_t this_arg) {
22919         LDKPositiveTimestamp this_arg_conv;
22920         this_arg_conv.inner = (void*)(this_arg & (~1));
22921         this_arg_conv.is_owned = false;
22922         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
22923         return ret_val;
22924 }
22925
22926 uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
22927         LDKInvoice this_arg_conv;
22928         this_arg_conv.inner = (void*)(this_arg & (~1));
22929         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22930         this_arg_conv = Invoice_clone(&this_arg_conv);
22931         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
22932         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22933         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22934         uint64_t ret_ref = (uint64_t)ret_var.inner;
22935         if (ret_var.is_owned) {
22936                 ret_ref |= 1;
22937         }
22938         return ret_ref;
22939 }
22940
22941 uint32_t  __attribute__((visibility("default"))) TS_Invoice_check_signature(uint32_t this_arg) {
22942         LDKInvoice this_arg_conv;
22943         this_arg_conv.inner = (void*)(this_arg & (~1));
22944         this_arg_conv.is_owned = false;
22945         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
22946         *ret_conv = Invoice_check_signature(&this_arg_conv);
22947         return (uint64_t)ret_conv;
22948 }
22949
22950 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
22951         LDKSignedRawInvoice signed_invoice_conv;
22952         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
22953         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
22954         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
22955         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
22956         *ret_conv = Invoice_from_signed(signed_invoice_conv);
22957         return (uint64_t)ret_conv;
22958 }
22959
22960 int64_t  __attribute__((visibility("default"))) TS_Invoice_timestamp(uint32_t this_arg) {
22961         LDKInvoice this_arg_conv;
22962         this_arg_conv.inner = (void*)(this_arg & (~1));
22963         this_arg_conv.is_owned = false;
22964         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
22965         return ret_val;
22966 }
22967
22968 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_hash(uint32_t this_arg) {
22969         LDKInvoice this_arg_conv;
22970         this_arg_conv.inner = (void*)(this_arg & (~1));
22971         this_arg_conv.is_owned = false;
22972         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22973         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_hash(&this_arg_conv), 32);
22974         return ret_arr;
22975 }
22976
22977 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
22978         LDKInvoice this_arg_conv;
22979         this_arg_conv.inner = (void*)(this_arg & (~1));
22980         this_arg_conv.is_owned = false;
22981         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22982         memcpy((uint8_t*)(ret_arr + 4), Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
22983         return ret_arr;
22984 }
22985
22986 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(uint32_t this_arg) {
22987         LDKInvoice this_arg_conv;
22988         this_arg_conv.inner = (void*)(this_arg & (~1));
22989         this_arg_conv.is_owned = false;
22990         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22991         memcpy((uint8_t*)(ret_arr + 4), Invoice_payment_secret(&this_arg_conv).data, 32);
22992         return ret_arr;
22993 }
22994
22995 uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t this_arg) {
22996         LDKInvoice this_arg_conv;
22997         this_arg_conv.inner = (void*)(this_arg & (~1));
22998         this_arg_conv.is_owned = false;
22999         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
23000         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23001         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23002         uint64_t ret_ref = (uint64_t)ret_var.inner;
23003         if (ret_var.is_owned) {
23004                 ret_ref |= 1;
23005         }
23006         return ret_ref;
23007 }
23008
23009 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
23010         LDKInvoice this_arg_conv;
23011         this_arg_conv.inner = (void*)(this_arg & (~1));
23012         this_arg_conv.is_owned = false;
23013         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23014         memcpy((uint8_t*)(ret_arr + 4), Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
23015         return ret_arr;
23016 }
23017
23018 int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t this_arg) {
23019         LDKInvoice this_arg_conv;
23020         this_arg_conv.inner = (void*)(this_arg & (~1));
23021         this_arg_conv.is_owned = false;
23022         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
23023         return ret_val;
23024 }
23025
23026 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
23027         LDKInvoice this_arg_conv;
23028         this_arg_conv.inner = (void*)(this_arg & (~1));
23029         this_arg_conv.is_owned = false;
23030         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
23031         return ret_val;
23032 }
23033
23034 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(uint32_t this_arg) {
23035         LDKInvoice this_arg_conv;
23036         this_arg_conv.inner = (void*)(this_arg & (~1));
23037         this_arg_conv.is_owned = false;
23038         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
23039         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
23040         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
23041         for (size_t o = 0; o < ret_var.datalen; o++) {
23042                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
23043                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23044                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23045                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
23046                 if (ret_conv_14_var.is_owned) {
23047                         ret_conv_14_ref |= 1;
23048                 }
23049                 ret_arr_ptr[o] = ret_conv_14_ref;
23050         }
23051         FREE(ret_var.data);
23052         return ret_arr;
23053 }
23054
23055 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uint32_t this_arg) {
23056         LDKInvoice this_arg_conv;
23057         this_arg_conv.inner = (void*)(this_arg & (~1));
23058         this_arg_conv.is_owned = false;
23059         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
23060         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
23061         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
23062         for (size_t l = 0; l < ret_var.datalen; l++) {
23063                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
23064                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23065                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23066                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
23067                 if (ret_conv_11_var.is_owned) {
23068                         ret_conv_11_ref |= 1;
23069                 }
23070                 ret_arr_ptr[l] = ret_conv_11_ref;
23071         }
23072         FREE(ret_var.data);
23073         return ret_arr;
23074 }
23075
23076 uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t this_arg) {
23077         LDKInvoice this_arg_conv;
23078         this_arg_conv.inner = (void*)(this_arg & (~1));
23079         this_arg_conv.is_owned = false;
23080         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
23081         return ret_conv;
23082 }
23083
23084 uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_pico_btc(uint32_t this_arg) {
23085         LDKInvoice this_arg_conv;
23086         this_arg_conv.inner = (void*)(this_arg & (~1));
23087         this_arg_conv.is_owned = false;
23088         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23089         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
23090         uint64_t ret_ref = (uint64_t)ret_copy;
23091         return ret_ref;
23092 }
23093
23094 uint32_t  __attribute__((visibility("default"))) TS_Description_new(jstring description) {
23095         LDKStr description_conv = str_ref_to_owned_c(description);
23096         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23097         *ret_conv = Description_new(description_conv);
23098         return (uint64_t)ret_conv;
23099 }
23100
23101 jstring  __attribute__((visibility("default"))) TS_Description_into_inner(uint32_t this_arg) {
23102         LDKDescription this_arg_conv;
23103         this_arg_conv.inner = (void*)(this_arg & (~1));
23104         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
23105         this_arg_conv = Description_clone(&this_arg_conv);
23106         LDKStr ret_str = Description_into_inner(this_arg_conv);
23107         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23108         return ret_conv;
23109 }
23110
23111 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
23112         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
23113         *ret_conv = ExpiryTime_from_seconds(seconds);
23114         return (uint64_t)ret_conv;
23115 }
23116
23117 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_duration(int64_t duration) {
23118         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
23119         *ret_conv = ExpiryTime_from_duration(duration);
23120         return (uint64_t)ret_conv;
23121 }
23122
23123 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
23124         LDKExpiryTime this_arg_conv;
23125         this_arg_conv.inner = (void*)(this_arg & (~1));
23126         this_arg_conv.is_owned = false;
23127         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
23128         return ret_val;
23129 }
23130
23131 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
23132         LDKExpiryTime this_arg_conv;
23133         this_arg_conv.inner = (void*)(this_arg & (~1));
23134         this_arg_conv.is_owned = false;
23135         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
23136         return ret_val;
23137 }
23138
23139 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_new(uint32_t hops) {
23140         LDKRouteHint hops_conv;
23141         hops_conv.inner = (void*)(hops & (~1));
23142         hops_conv.is_owned = (hops & 1) || (hops == 0);
23143         hops_conv = RouteHint_clone(&hops_conv);
23144         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23145         *ret_conv = PrivateRoute_new(hops_conv);
23146         return (uint64_t)ret_conv;
23147 }
23148
23149 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
23150         LDKPrivateRoute this_arg_conv;
23151         this_arg_conv.inner = (void*)(this_arg & (~1));
23152         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
23153         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
23154         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
23155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23157         uint64_t ret_ref = (uint64_t)ret_var.inner;
23158         if (ret_var.is_owned) {
23159                 ret_ref |= 1;
23160         }
23161         return ret_ref;
23162 }
23163
23164 uint32_t  __attribute__((visibility("default"))) TS_CreationError_clone(uint32_t orig) {
23165         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
23166         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
23167         return ret_conv;
23168 }
23169
23170 jboolean  __attribute__((visibility("default"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
23171         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
23172         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
23173         jboolean ret_val = CreationError_eq(a_conv, b_conv);
23174         return ret_val;
23175 }
23176
23177 jstring  __attribute__((visibility("default"))) TS_CreationError_to_str(uint32_t o) {
23178         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
23179         LDKStr ret_str = CreationError_to_str(o_conv);
23180         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23181         return ret_conv;
23182 }
23183
23184 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_clone(uint32_t orig) {
23185         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
23186         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
23187         return ret_conv;
23188 }
23189
23190 jboolean  __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
23191         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
23192         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
23193         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
23194         return ret_val;
23195 }
23196
23197 jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t o) {
23198         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
23199         LDKStr ret_str = SemanticError_to_str(o_conv);
23200         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23201         return ret_conv;
23202 }
23203
23204 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
23205         if ((this_ptr & 1) != 0) return;
23206         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
23207         FREE((void*)this_ptr);
23208         SignOrCreationError_free(this_ptr_conv);
23209 }
23210
23211 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone(uint32_t orig) {
23212         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
23213         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
23214         *ret_copy = SignOrCreationError_clone(orig_conv);
23215         uint64_t ret_ref = (uint64_t)ret_copy;
23216         return ret_ref;
23217 }
23218
23219 jboolean  __attribute__((visibility("default"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
23220         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
23221         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
23222         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
23223         return ret_val;
23224 }
23225
23226 jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(uint32_t o) {
23227         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
23228         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
23229         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23230         return ret_conv;
23231 }
23232
23233 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) {
23234         LDKChannelManager channelmanager_conv;
23235         channelmanager_conv.inner = (void*)(channelmanager & (~1));
23236         channelmanager_conv.is_owned = false;
23237         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
23238         LDKCurrency network_conv = LDKCurrency_from_js(network);
23239         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
23240         LDKStr description_conv = str_ref_to_owned_c(description);
23241         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23242         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
23243         return (uint64_t)ret_conv;
23244 }
23245
23246 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
23247         LDKStr s_conv = str_ref_to_owned_c(s);
23248         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
23249         *ret_conv = SiPrefix_from_str(s_conv);
23250         return (uint64_t)ret_conv;
23251 }
23252
23253 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_str(jstring s) {
23254         LDKStr s_conv = str_ref_to_owned_c(s);
23255         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
23256         *ret_conv = Invoice_from_str(s_conv);
23257         return (uint64_t)ret_conv;
23258 }
23259
23260 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_from_str(jstring s) {
23261         LDKStr s_conv = str_ref_to_owned_c(s);
23262         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
23263         *ret_conv = SignedRawInvoice_from_str(s_conv);
23264         return (uint64_t)ret_conv;
23265 }
23266
23267 jstring  __attribute__((visibility("default"))) TS_Invoice_to_str(uint32_t o) {
23268         LDKInvoice o_conv;
23269         o_conv.inner = (void*)(o & (~1));
23270         o_conv.is_owned = false;
23271         LDKStr ret_str = Invoice_to_str(&o_conv);
23272         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23273         return ret_conv;
23274 }
23275
23276 jstring  __attribute__((visibility("default"))) TS_SignedRawInvoice_to_str(uint32_t o) {
23277         LDKSignedRawInvoice o_conv;
23278         o_conv.inner = (void*)(o & (~1));
23279         o_conv.is_owned = false;
23280         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
23281         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23282         return ret_conv;
23283 }
23284
23285 jstring  __attribute__((visibility("default"))) TS_Currency_to_str(uint32_t o) {
23286         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
23287         LDKStr ret_str = Currency_to_str(o_conv);
23288         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23289         return ret_conv;
23290 }
23291
23292 jstring  __attribute__((visibility("default"))) TS_SiPrefix_to_str(uint32_t o) {
23293         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
23294         LDKStr ret_str = SiPrefix_to_str(o_conv);
23295         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23296         return ret_conv;
23297 }
23298