e539908ef8e1567a169d5796b7413ab5b0db0578
[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_Off;
203                 case 1: return LDKLevel_Error;
204                 case 2: return LDKLevel_Warn;
205                 case 3: return LDKLevel_Info;
206                 case 4: return LDKLevel_Debug;
207                 case 5: return LDKLevel_Trace;
208         }
209         abort();
210 }
211 static inline int32_t LDKLevel_to_js(LDKLevel val) {
212         switch (val) {
213                 case LDKLevel_Off: return 0;
214                 case LDKLevel_Error: return 1;
215                 case LDKLevel_Warn: return 2;
216                 case LDKLevel_Info: return 3;
217                 case LDKLevel_Debug: return 4;
218                 case LDKLevel_Trace: return 5;
219                 default: abort();
220         }
221 }
222 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
223         switch (ord) {
224                 case 0: return LDKNetwork_Bitcoin;
225                 case 1: return LDKNetwork_Testnet;
226                 case 2: return LDKNetwork_Regtest;
227                 case 3: return LDKNetwork_Signet;
228         }
229         abort();
230 }
231 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
232         switch (val) {
233                 case LDKNetwork_Bitcoin: return 0;
234                 case LDKNetwork_Testnet: return 1;
235                 case LDKNetwork_Regtest: return 2;
236                 case LDKNetwork_Signet: return 3;
237                 default: abort();
238         }
239 }
240 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
241         switch (ord) {
242                 case 0: return LDKSecp256k1Error_IncorrectSignature;
243                 case 1: return LDKSecp256k1Error_InvalidMessage;
244                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
245                 case 3: return LDKSecp256k1Error_InvalidSignature;
246                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
247                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
248                 case 6: return LDKSecp256k1Error_InvalidTweak;
249                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
250                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
251         }
252         abort();
253 }
254 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
255         switch (val) {
256                 case LDKSecp256k1Error_IncorrectSignature: return 0;
257                 case LDKSecp256k1Error_InvalidMessage: return 1;
258                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
259                 case LDKSecp256k1Error_InvalidSignature: return 3;
260                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
261                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
262                 case LDKSecp256k1Error_InvalidTweak: return 6;
263                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
264                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
265                 default: abort();
266         }
267 }
268 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
269         switch (ord) {
270                 case 0: return LDKSemanticError_NoPaymentHash;
271                 case 1: return LDKSemanticError_MultiplePaymentHashes;
272                 case 2: return LDKSemanticError_NoDescription;
273                 case 3: return LDKSemanticError_MultipleDescriptions;
274                 case 4: return LDKSemanticError_MultiplePaymentSecrets;
275                 case 5: return LDKSemanticError_InvalidFeatures;
276                 case 6: return LDKSemanticError_InvalidRecoveryId;
277                 case 7: return LDKSemanticError_InvalidSignature;
278         }
279         abort();
280 }
281 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
282         switch (val) {
283                 case LDKSemanticError_NoPaymentHash: return 0;
284                 case LDKSemanticError_MultiplePaymentHashes: return 1;
285                 case LDKSemanticError_NoDescription: return 2;
286                 case LDKSemanticError_MultipleDescriptions: return 3;
287                 case LDKSemanticError_MultiplePaymentSecrets: return 4;
288                 case LDKSemanticError_InvalidFeatures: return 5;
289                 case LDKSemanticError_InvalidRecoveryId: return 6;
290                 case LDKSemanticError_InvalidSignature: return 7;
291                 default: abort();
292         }
293 }
294 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
295         switch (ord) {
296                 case 0: return LDKSiPrefix_Milli;
297                 case 1: return LDKSiPrefix_Micro;
298                 case 2: return LDKSiPrefix_Nano;
299                 case 3: return LDKSiPrefix_Pico;
300         }
301         abort();
302 }
303 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
304         switch (val) {
305                 case LDKSiPrefix_Milli: return 0;
306                 case LDKSiPrefix_Micro: return 1;
307                 case LDKSiPrefix_Nano: return 2;
308                 case LDKSiPrefix_Pico: return 3;
309                 default: abort();
310         }
311 }
312 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
313         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
314         ret->datalen = *((uint32_t*)elems);
315         if (ret->datalen == 0) {
316                 ret->data = NULL;
317         } else {
318                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
319                 int8_t *java_elems = (int8_t*)(elems + 4);
320                 for (size_t i = 0; i < ret->datalen; i++) {
321                         ret->data[i] = java_elems[i];
322                 }
323         }
324         return (uint64_t)ret;
325 }
326 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
327         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
328         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
329         return ret;
330 }
331 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_result_ok(uint32_t arg) {
332         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
333 }
334 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
335         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
336         CHECK(val->result_ok);
337         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
338         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
339         return res_arr;
340 }
341 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
342         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
343         CHECK(!val->result_ok);
344         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
345         return err_conv;
346 }
347 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_result_ok(uint32_t arg) {
348         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
349 }
350 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
351         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
352         CHECK(val->result_ok);
353         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
354         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
355         return res_arr;
356 }
357 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
358         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
359         CHECK(!val->result_ok);
360         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
361         return err_conv;
362 }
363 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_result_ok(uint32_t arg) {
364         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
365 }
366 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
367         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
368         CHECK(val->result_ok);
369         LDKTxCreationKeys res_var = (*val->contents.result);
370         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
371         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
372         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
373         return res_ref;
374 }
375 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
376         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
377         CHECK(!val->result_ok);
378         LDKDecodeError err_var = (*val->contents.err);
379         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
380         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
381         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
382         return err_ref;
383 }
384 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
385         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
386 }
387 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
388         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
389         CHECK(val->result_ok);
390         LDKChannelPublicKeys res_var = (*val->contents.result);
391         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
392         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
393         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
394         return res_ref;
395 }
396 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
397         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
398         CHECK(!val->result_ok);
399         LDKDecodeError err_var = (*val->contents.err);
400         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
401         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
402         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
403         return err_ref;
404 }
405 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
406         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
407 }
408 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
409         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
410         CHECK(val->result_ok);
411         LDKTxCreationKeys res_var = (*val->contents.result);
412         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
413         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
414         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
415         return res_ref;
416 }
417 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
418         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
419         CHECK(!val->result_ok);
420         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
421         return err_conv;
422 }
423 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u32Z_ref_from_ptr(uint32_t ptr) {
424         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
425         switch(obj->tag) {
426                 case LDKCOption_u32Z_Some: {
427                         return 0 /* LDKCOption_u32Z - Some */; (void) obj->some;
428                 }
429                 case LDKCOption_u32Z_None: {
430                         return 0 /* LDKCOption_u32Z - None */;
431                 }
432                 default: abort();
433         }
434 }
435 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_result_ok(uint32_t arg) {
436         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
437 }
438 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
439         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
440         CHECK(val->result_ok);
441         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
442         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
443         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
444         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
445         return res_ref;
446 }
447 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
448         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
449         CHECK(!val->result_ok);
450         LDKDecodeError err_var = (*val->contents.err);
451         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
452         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
453         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
454         return err_ref;
455 }
456 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
457         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
458 }
459 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
460         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
461         CHECK(val->result_ok);
462         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
463         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
464         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
465         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
466         return res_ref;
467 }
468 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
469         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
470         CHECK(!val->result_ok);
471         LDKDecodeError err_var = (*val->contents.err);
472         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
473         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
474         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
475         return err_ref;
476 }
477 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
478         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
479 }
480 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
481         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
482         CHECK(val->result_ok);
483         LDKChannelTransactionParameters res_var = (*val->contents.result);
484         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
485         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
486         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
487         return res_ref;
488 }
489 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
490         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
491         CHECK(!val->result_ok);
492         LDKDecodeError err_var = (*val->contents.err);
493         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
494         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
495         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
496         return err_ref;
497 }
498 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
499         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
500 }
501 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
502         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
503         CHECK(val->result_ok);
504         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
505         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
506         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
507         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
508         return res_ref;
509 }
510 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
511         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
512         CHECK(!val->result_ok);
513         LDKDecodeError err_var = (*val->contents.err);
514         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
515         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
516         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
517         return err_ref;
518 }
519 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
520         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
521 }
522 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
523         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
524         CHECK(val->result_ok);
525         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
526         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
527         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
528         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
529         return res_ref;
530 }
531 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
532         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
533         CHECK(!val->result_ok);
534         LDKDecodeError err_var = (*val->contents.err);
535         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
536         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
537         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
538         return err_ref;
539 }
540 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
541         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
542 }
543 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
544         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
545         CHECK(val->result_ok);
546         LDKCommitmentTransaction res_var = (*val->contents.result);
547         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
548         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
549         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
550         return res_ref;
551 }
552 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
553         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
554         CHECK(!val->result_ok);
555         LDKDecodeError err_var = (*val->contents.err);
556         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
557         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
558         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
559         return err_ref;
560 }
561 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
562         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
563 }
564 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
565         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
566         CHECK(val->result_ok);
567         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
568         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
569         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
570         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
571         return res_ref;
572 }
573 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
574         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
575         CHECK(!val->result_ok);
576         return *val->contents.err;
577 }
578 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
579         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
580 }
581 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
582         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
583         CHECK(val->result_ok);
584         LDKCVec_SignatureZ res_var = (*val->contents.result);
585         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
586         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
587         for (size_t m = 0; m < res_var.datalen; m++) {
588                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
589                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
590                 res_arr_ptr[m] = res_conv_12_arr;
591         }
592         return res_arr;
593 }
594 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
595         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
596         CHECK(!val->result_ok);
597         return *val->contents.err;
598 }
599 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_result_ok(uint32_t arg) {
600         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
601 }
602 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_ok(uint32_t arg) {
603         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
604         CHECK(val->result_ok);
605         return *val->contents.result;
606 }
607 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_err(uint32_t arg) {
608         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
609         CHECK(!val->result_ok);
610         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
611         return err_conv;
612 }
613 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_result_ok(uint32_t arg) {
614         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
615 }
616 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_ok(uint32_t arg) {
617         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
618         CHECK(val->result_ok);
619         LDKRouteHop res_var = (*val->contents.result);
620         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
621         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
622         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
623         return res_ref;
624 }
625 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_err(uint32_t arg) {
626         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
627         CHECK(!val->result_ok);
628         LDKDecodeError err_var = (*val->contents.err);
629         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
630         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
631         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
632         return err_ref;
633 }
634 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
635         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
636         ret->datalen = *((uint32_t*)elems);
637         if (ret->datalen == 0) {
638                 ret->data = NULL;
639         } else {
640                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
641                 uint32_t *java_elems = (uint32_t*)(elems + 4);
642                 for (size_t i = 0; i < ret->datalen; i++) {
643                         uint32_t arr_elem = java_elems[i];
644                         LDKRouteHop arr_elem_conv;
645                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
646                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
647                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
648                         ret->data[i] = arr_elem_conv;
649                 }
650         }
651         return (uint64_t)ret;
652 }
653 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
654         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
655         for (size_t i = 0; i < ret.datalen; i++) {
656                 ret.data[i] = RouteHop_clone(&orig->data[i]);
657         }
658         return ret;
659 }
660 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
661         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
662         for (size_t i = 0; i < ret.datalen; i++) {
663                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
664         }
665         return ret;
666 }
667 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
668         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
669 }
670 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
671         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
672         CHECK(val->result_ok);
673         LDKRoute res_var = (*val->contents.result);
674         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
675         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
676         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
677         return res_ref;
678 }
679 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
680         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
681         CHECK(!val->result_ok);
682         LDKDecodeError err_var = (*val->contents.err);
683         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
684         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
685         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
686         return err_ref;
687 }
688 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
689         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
690         switch(obj->tag) {
691                 case LDKCOption_u64Z_Some: {
692                         return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
693                 }
694                 case LDKCOption_u64Z_None: {
695                         return 0 /* LDKCOption_u64Z - None */;
696                 }
697                 default: abort();
698         }
699 }
700 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
701         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
702         ret->datalen = *((uint32_t*)elems);
703         if (ret->datalen == 0) {
704                 ret->data = NULL;
705         } else {
706                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
707                 uint32_t *java_elems = (uint32_t*)(elems + 4);
708                 for (size_t i = 0; i < ret->datalen; i++) {
709                         uint32_t arr_elem = java_elems[i];
710                         LDKChannelDetails arr_elem_conv;
711                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
712                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
713                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
714                         ret->data[i] = arr_elem_conv;
715                 }
716         }
717         return (uint64_t)ret;
718 }
719 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
720         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
721         for (size_t i = 0; i < ret.datalen; i++) {
722                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
723         }
724         return ret;
725 }
726 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
727         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
728         ret->datalen = *((uint32_t*)elems);
729         if (ret->datalen == 0) {
730                 ret->data = NULL;
731         } else {
732                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
733                 uint32_t *java_elems = (uint32_t*)(elems + 4);
734                 for (size_t i = 0; i < ret->datalen; i++) {
735                         uint32_t arr_elem = java_elems[i];
736                         LDKRouteHint arr_elem_conv;
737                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
738                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
739                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
740                         ret->data[i] = arr_elem_conv;
741                 }
742         }
743         return (uint64_t)ret;
744 }
745 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
746         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
747         for (size_t i = 0; i < ret.datalen; i++) {
748                 ret.data[i] = RouteHint_clone(&orig->data[i]);
749         }
750         return ret;
751 }
752 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
753         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
754 }
755 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
756         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
757         CHECK(val->result_ok);
758         LDKRoute res_var = (*val->contents.result);
759         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
760         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
761         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
762         return res_ref;
763 }
764 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
765         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
766         CHECK(!val->result_ok);
767         LDKLightningError err_var = (*val->contents.err);
768         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
769         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
770         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
771         return err_ref;
772 }
773 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
774         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
775 }
776 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
777         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
778         CHECK(val->result_ok);
779         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
780         return (uint64_t)res_ref;
781 }
782 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
783         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
784         CHECK(!val->result_ok);
785         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
786         return err_conv;
787 }
788 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
789         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
790         ret->a = a;
791         LDKTransaction b_ref;
792         b_ref.datalen = *((uint32_t*)b);
793         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
794         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
795         b_ref.data_is_owned = false;
796         ret->b = b_ref;
797         return (uint64_t)ret;
798 }
799 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
800         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
801         return tuple->a;
802 }
803 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
804         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
805         LDKTransaction b_var = tuple->b;
806         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
807         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
808         return b_arr;
809 }
810 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
811         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
812         ret->datalen = *((uint32_t*)elems);
813         if (ret->datalen == 0) {
814                 ret->data = NULL;
815         } else {
816                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
817                 uint32_t *java_elems = (uint32_t*)(elems + 4);
818                 for (size_t i = 0; i < ret->datalen; i++) {
819                         uint32_t arr_elem = java_elems[i];
820                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
821                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
822                         ret->data[i] = arr_elem_conv;
823                 }
824         }
825         return (uint64_t)ret;
826 }
827 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
828         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
829         for (size_t i = 0; i < ret.datalen; i++) {
830                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
831         }
832         return ret;
833 }
834 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
835         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
836         for (size_t i = 0; i < ret.datalen; i++) {
837                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
838         }
839         return ret;
840 }
841 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
842         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
843 }
844 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
845         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
846         CHECK(val->result_ok);
847         return *val->contents.result;
848 }
849 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
850         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
851         CHECK(!val->result_ok);
852         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
853         return err_conv;
854 }
855 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
856         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
857         switch(obj->tag) {
858                 case LDKMonitorEvent_HTLCEvent: {
859                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
860                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
861                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
862                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
863                         return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
864                 }
865                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
866                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
867                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
868                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
869                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
870                         return 0 /* LDKMonitorEvent - CommitmentTxBroadcasted */; (void) commitment_tx_broadcasted_ref;
871                 }
872                 default: abort();
873         }
874 }
875 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
876         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
877         ret->datalen = *((uint32_t*)elems);
878         if (ret->datalen == 0) {
879                 ret->data = NULL;
880         } else {
881                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
882                 uint32_t *java_elems = (uint32_t*)(elems + 4);
883                 for (size_t i = 0; i < ret->datalen; i++) {
884                         uint32_t arr_elem = java_elems[i];
885                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
886                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
887                         ret->data[i] = arr_elem_conv;
888                 }
889         }
890         return (uint64_t)ret;
891 }
892 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
893         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
894         for (size_t i = 0; i < ret.datalen; i++) {
895                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
896         }
897         return ret;
898 }
899 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(uint32_t ptr) {
900         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
901         switch(obj->tag) {
902                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
903                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
904                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - Some */; (void) some_ref;
905                 }
906                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
907                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - None */;
908                 }
909                 default: abort();
910         }
911 }
912 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
913         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
914         switch(obj->tag) {
915                 case LDKSpendableOutputDescriptor_StaticOutput: {
916                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
917                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
918                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
919                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
920                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
921                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
922                 }
923                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
924                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
925                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
926                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
927                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
928                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
929                 }
930                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
931                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
932                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
933                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
934                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
935                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
936                 }
937                 default: abort();
938         }
939 }
940 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
941         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
942         ret->datalen = *((uint32_t*)elems);
943         if (ret->datalen == 0) {
944                 ret->data = NULL;
945         } else {
946                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
947                 uint32_t *java_elems = (uint32_t*)(elems + 4);
948                 for (size_t i = 0; i < ret->datalen; i++) {
949                         uint32_t arr_elem = java_elems[i];
950                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
951                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
952                         ret->data[i] = arr_elem_conv;
953                 }
954         }
955         return (uint64_t)ret;
956 }
957 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
958         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
959         for (size_t i = 0; i < ret.datalen; i++) {
960                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
961         }
962         return ret;
963 }
964 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
965         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
966         switch(obj->tag) {
967                 case LDKErrorAction_DisconnectPeer: {
968                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
969                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
970                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
971                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
972                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
973                 }
974                 case LDKErrorAction_IgnoreError: {
975                         return 0 /* LDKErrorAction - IgnoreError */;
976                 }
977                 case LDKErrorAction_SendErrorMessage: {
978                         LDKErrorMessage msg_var = obj->send_error_message.msg;
979                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
980                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
981                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
982                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
983                 }
984                 default: abort();
985         }
986 }
987 uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) {
988         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
989         switch(obj->tag) {
990                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
991                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
992                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
993                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
994                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
995                         return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
996                 }
997                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
998                         return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
999                 }
1000                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1001                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1002                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
1003                         return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
1004                 }
1005                 default: abort();
1006         }
1007 }
1008 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
1009         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1010         switch(obj->tag) {
1011                 case LDKMessageSendEvent_SendAcceptChannel: {
1012                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1013                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
1014                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1015                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1016                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1017                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1018                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
1019                 }
1020                 case LDKMessageSendEvent_SendOpenChannel: {
1021                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1022                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
1023                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1024                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1025                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1026                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1027                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
1028                 }
1029                 case LDKMessageSendEvent_SendFundingCreated: {
1030                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1031                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
1032                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1033                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1034                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1035                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1036                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
1037                 }
1038                 case LDKMessageSendEvent_SendFundingSigned: {
1039                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1040                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
1041                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1042                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1043                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1044                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1045                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
1046                 }
1047                 case LDKMessageSendEvent_SendFundingLocked: {
1048                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1049                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
1050                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1051                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1052                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1053                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1054                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
1055                 }
1056                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1057                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1058                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
1059                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1060                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1061                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1062                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1063                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
1064                 }
1065                 case LDKMessageSendEvent_UpdateHTLCs: {
1066                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1067                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
1068                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1069                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1070                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1071                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1072                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
1073                 }
1074                 case LDKMessageSendEvent_SendRevokeAndACK: {
1075                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1076                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
1077                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1078                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1079                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1080                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1081                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
1082                 }
1083                 case LDKMessageSendEvent_SendClosingSigned: {
1084                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1085                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
1086                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1087                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1088                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1089                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1090                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
1091                 }
1092                 case LDKMessageSendEvent_SendShutdown: {
1093                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1094                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
1095                         LDKShutdown msg_var = obj->send_shutdown.msg;
1096                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1097                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1098                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1099                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
1100                 }
1101                 case LDKMessageSendEvent_SendChannelReestablish: {
1102                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1103                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
1104                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1105                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1106                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1107                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1108                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
1109                 }
1110                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1111                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1112                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1113                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1114                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1115                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1116                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1117                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1118                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1119                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
1120                 }
1121                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1122                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1123                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1124                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1125                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1126                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
1127                 }
1128                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1129                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1130                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1131                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1132                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1133                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
1134                 }
1135                 case LDKMessageSendEvent_HandleError: {
1136                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1137                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
1138                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1139                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
1140                 }
1141                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1142                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1143                         return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref;
1144                 }
1145                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1146                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1147                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
1148                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1149                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1150                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1151                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1152                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
1153                 }
1154                 case LDKMessageSendEvent_SendShortIdsQuery: {
1155                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1156                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
1157                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1158                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1159                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1160                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1161                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
1162                 }
1163                 case LDKMessageSendEvent_SendReplyChannelRange: {
1164                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1165                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
1166                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1167                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1168                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1169                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1170                         return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
1171                 }
1172                 default: abort();
1173         }
1174 }
1175 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
1176         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1177         ret->datalen = *((uint32_t*)elems);
1178         if (ret->datalen == 0) {
1179                 ret->data = NULL;
1180         } else {
1181                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1182                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1183                 for (size_t i = 0; i < ret->datalen; i++) {
1184                         uint32_t arr_elem = java_elems[i];
1185                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1186                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1187                         ret->data[i] = arr_elem_conv;
1188                 }
1189         }
1190         return (uint64_t)ret;
1191 }
1192 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1193         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1194         for (size_t i = 0; i < ret.datalen; i++) {
1195                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1196         }
1197         return ret;
1198 }
1199 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1200         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1201 }
1202 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1203         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1204         CHECK(val->result_ok);
1205         LDKInitFeatures res_var = (*val->contents.result);
1206         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1207         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1208         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1209         return res_ref;
1210 }
1211 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1212         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1213         CHECK(!val->result_ok);
1214         LDKDecodeError err_var = (*val->contents.err);
1215         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1216         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1217         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1218         return err_ref;
1219 }
1220 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1221         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1222 }
1223 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1224         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1225         CHECK(val->result_ok);
1226         LDKNodeFeatures res_var = (*val->contents.result);
1227         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1228         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1229         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1230         return res_ref;
1231 }
1232 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1233         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1234         CHECK(!val->result_ok);
1235         LDKDecodeError err_var = (*val->contents.err);
1236         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1237         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1238         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1239         return err_ref;
1240 }
1241 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1242         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1243 }
1244 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1245         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1246         CHECK(val->result_ok);
1247         LDKChannelFeatures res_var = (*val->contents.result);
1248         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1249         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1250         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1251         return res_ref;
1252 }
1253 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1254         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1255         CHECK(!val->result_ok);
1256         LDKDecodeError err_var = (*val->contents.err);
1257         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1258         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1259         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1260         return err_ref;
1261 }
1262 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1263         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1264 }
1265 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1266         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1267         CHECK(val->result_ok);
1268         LDKInvoiceFeatures res_var = (*val->contents.result);
1269         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1270         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1271         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1272         return res_ref;
1273 }
1274 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1275         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1276         CHECK(!val->result_ok);
1277         LDKDecodeError err_var = (*val->contents.err);
1278         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1279         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1280         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1281         return err_ref;
1282 }
1283 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1284         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1285 }
1286 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1287         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1288         CHECK(val->result_ok);
1289         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1290         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1291         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1292         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1293         return res_ref;
1294 }
1295 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1296         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1297         CHECK(!val->result_ok);
1298         LDKDecodeError err_var = (*val->contents.err);
1299         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1300         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1301         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1302         return err_ref;
1303 }
1304 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1305         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1306 }
1307 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1308         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1309         CHECK(val->result_ok);
1310         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1311         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1312         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1313         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1314         return res_ref;
1315 }
1316 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1317         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1318         CHECK(!val->result_ok);
1319         LDKDecodeError err_var = (*val->contents.err);
1320         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1321         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1322         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1323         return err_ref;
1324 }
1325 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1326         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1327 }
1328 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1329         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1330         CHECK(val->result_ok);
1331         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1332         return res_ref;
1333 }
1334 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1335         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1336         CHECK(!val->result_ok);
1337         LDKDecodeError err_var = (*val->contents.err);
1338         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1339         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1340         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1341         return err_ref;
1342 }
1343 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
1344         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1345         LDKSignature a_ref;
1346         CHECK(*((uint32_t*)a) == 64);
1347         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
1348         ret->a = a_ref;
1349         LDKCVec_SignatureZ b_constr;
1350         b_constr.datalen = *((uint32_t*)b);
1351         if (b_constr.datalen > 0)
1352                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1353         else
1354                 b_constr.data = NULL;
1355         int8_tArray* b_vals = (int8_tArray*)(b + 4);
1356         for (size_t m = 0; m < b_constr.datalen; m++) {
1357                 int8_tArray b_conv_12 = b_vals[m];
1358                 LDKSignature b_conv_12_ref;
1359                 CHECK(*((uint32_t*)b_conv_12) == 64);
1360                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
1361                 b_constr.data[m] = b_conv_12_ref;
1362         }
1363         ret->b = b_constr;
1364         return (uint64_t)ret;
1365 }
1366 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
1367         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1368         int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1369         memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
1370         return a_arr;
1371 }
1372 ptrArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
1373         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1374         LDKCVec_SignatureZ b_var = tuple->b;
1375         ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1376         int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
1377         for (size_t m = 0; m < b_var.datalen; m++) {
1378                 int8_tArray b_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1379                 memcpy((uint8_t*)(b_conv_12_arr + 4), b_var.data[m].compact_form, 64);
1380                 b_arr_ptr[m] = b_conv_12_arr;
1381         }
1382         return b_arr;
1383 }
1384 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
1385         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1386 }
1387 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1388         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1389         CHECK(val->result_ok);
1390         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
1391         return res_ref;
1392 }
1393 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1394         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1395         CHECK(!val->result_ok);
1396         return *val->contents.err;
1397 }
1398 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
1399         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1400 }
1401 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1402         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1403         CHECK(val->result_ok);
1404         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1405         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1406         return res_arr;
1407 }
1408 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1409         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1410         CHECK(!val->result_ok);
1411         return *val->contents.err;
1412 }
1413 typedef struct LDKBaseSign_JCalls {
1414         atomic_size_t refcnt;
1415         uint32_t get_per_commitment_point_meth;
1416         uint32_t release_commitment_secret_meth;
1417         uint32_t channel_keys_id_meth;
1418         uint32_t sign_counterparty_commitment_meth;
1419         uint32_t sign_holder_commitment_and_htlcs_meth;
1420         uint32_t sign_justice_revoked_output_meth;
1421         uint32_t sign_justice_revoked_htlc_meth;
1422         uint32_t sign_counterparty_htlc_transaction_meth;
1423         uint32_t sign_closing_transaction_meth;
1424         uint32_t sign_channel_announcement_meth;
1425         uint32_t ready_channel_meth;
1426 } LDKBaseSign_JCalls;
1427 static void LDKBaseSign_JCalls_free(void* this_arg) {
1428         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1429         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1430                 js_free(j_calls->get_per_commitment_point_meth);
1431                 js_free(j_calls->release_commitment_secret_meth);
1432                 js_free(j_calls->channel_keys_id_meth);
1433                 js_free(j_calls->sign_counterparty_commitment_meth);
1434                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1435                 js_free(j_calls->sign_justice_revoked_output_meth);
1436                 js_free(j_calls->sign_justice_revoked_htlc_meth);
1437                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1438                 js_free(j_calls->sign_closing_transaction_meth);
1439                 js_free(j_calls->sign_channel_announcement_meth);
1440                 js_free(j_calls->ready_channel_meth);
1441                 FREE(j_calls);
1442         }
1443 }
1444 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1445         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1446         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1447         LDKPublicKey ret_ref;
1448         CHECK(*((uint32_t*)ret) == 33);
1449         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1450         return ret_ref;
1451 }
1452 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1453         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1454         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1455         LDKThirtyTwoBytes ret_ref;
1456         CHECK(*((uint32_t*)ret) == 32);
1457         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1458         return ret_ref;
1459 }
1460 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1461         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1462         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1463         LDKThirtyTwoBytes ret_ref;
1464         CHECK(*((uint32_t*)ret) == 32);
1465         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1466         return ret_ref;
1467 }
1468 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1469         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1470         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1471         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1472         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1473         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1474         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1475         if (commitment_tx_var.is_owned) {
1476                 commitment_tx_ref |= 1;
1477         }
1478         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1479         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1480         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1481         return ret_conv;
1482 }
1483 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1484         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1485         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1486         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1487         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1488         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1489         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1490         if (commitment_tx_var.is_owned) {
1491                 commitment_tx_ref |= 1;
1492         }
1493         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1494         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1495         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1496         return ret_conv;
1497 }
1498 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]) {
1499         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1500         LDKTransaction justice_tx_var = justice_tx;
1501         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1502         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1503         Transaction_free(justice_tx_var);
1504         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1505         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1506         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);
1507         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1508         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1509         return ret_conv;
1510 }
1511 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) {
1512         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1513         LDKTransaction justice_tx_var = justice_tx;
1514         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1515         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1516         Transaction_free(justice_tx_var);
1517         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1518         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1519         LDKHTLCOutputInCommitment htlc_var = *htlc;
1520         htlc_var = HTLCOutputInCommitment_clone(htlc);
1521         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1522         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1523         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1524         if (htlc_var.is_owned) {
1525                 htlc_ref |= 1;
1526         }
1527         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);
1528         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1529         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1530         return ret_conv;
1531 }
1532 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) {
1533         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1534         LDKTransaction htlc_tx_var = htlc_tx;
1535         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1536         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1537         Transaction_free(htlc_tx_var);
1538         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1539         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1540         LDKHTLCOutputInCommitment htlc_var = *htlc;
1541         htlc_var = HTLCOutputInCommitment_clone(htlc);
1542         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1543         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1544         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1545         if (htlc_var.is_owned) {
1546                 htlc_ref |= 1;
1547         }
1548         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);
1549         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1550         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1551         return ret_conv;
1552 }
1553 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
1554         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1555         LDKTransaction closing_tx_var = closing_tx;
1556         int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1557         memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
1558         Transaction_free(closing_tx_var);
1559         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
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_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1565         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1566         LDKUnsignedChannelAnnouncement msg_var = *msg;
1567         msg_var = UnsignedChannelAnnouncement_clone(msg);
1568         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1569         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1570         uint64_t msg_ref = (uint64_t)msg_var.inner;
1571         if (msg_var.is_owned) {
1572                 msg_ref |= 1;
1573         }
1574         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1575         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1576         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1577         return ret_conv;
1578 }
1579 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1580         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1581         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1582         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1583         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1584         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1585         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
1586         if (channel_parameters_var.is_owned) {
1587                 channel_parameters_ref |= 1;
1588         }
1589         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1590 }
1591 static void* LDKBaseSign_JCalls_clone(const void* this_arg) {
1592         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1593         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1594         return (void*) this_arg;
1595 }
1596 static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1597         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
1598         atomic_init(&calls->refcnt, 1);
1599         //TODO: Assign calls->o from o
1600
1601         LDKChannelPublicKeys pubkeys_conv;
1602         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1603         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1604         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1605
1606         LDKBaseSign ret = {
1607                 .this_arg = (void*) calls,
1608                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
1609                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
1610                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
1611                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
1612                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
1613                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
1614                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
1615                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
1616                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
1617                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
1618                 .ready_channel = ready_channel_LDKBaseSign_jcall,
1619                 .free = LDKBaseSign_JCalls_free,
1620                 .pubkeys = pubkeys_conv,
1621                 .set_pubkeys = NULL,
1622         };
1623         return ret;
1624 }
1625 long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1626         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
1627         *res_ptr = LDKBaseSign_init(o, pubkeys);
1628         return (long)res_ptr;
1629 }
1630 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1631         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1632         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1633         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1634         return ret_arr;
1635 }
1636
1637 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1638         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1639         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1640         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1641         return ret_arr;
1642 }
1643
1644 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
1645         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1646         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1647         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
1648         return ret_arr;
1649 }
1650
1651 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1652         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1653         LDKCommitmentTransaction commitment_tx_conv;
1654         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1655         commitment_tx_conv.is_owned = false;
1656         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1657         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1658         return (uint64_t)ret_conv;
1659 }
1660
1661 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
1662         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1663         LDKHolderCommitmentTransaction commitment_tx_conv;
1664         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1665         commitment_tx_conv.is_owned = false;
1666         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1667         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1668         return (uint64_t)ret_conv;
1669 }
1670
1671 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) {
1672         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1673         LDKTransaction justice_tx_ref;
1674         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1675         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1676         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1677         justice_tx_ref.data_is_owned = true;
1678         unsigned char per_commitment_key_arr[32];
1679         CHECK(*((uint32_t*)per_commitment_key) == 32);
1680         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1681         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1682         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1683         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
1684         return (uint64_t)ret_conv;
1685 }
1686
1687 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) {
1688         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1689         LDKTransaction justice_tx_ref;
1690         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1691         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1692         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1693         justice_tx_ref.data_is_owned = true;
1694         unsigned char per_commitment_key_arr[32];
1695         CHECK(*((uint32_t*)per_commitment_key) == 32);
1696         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1697         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1698         LDKHTLCOutputInCommitment htlc_conv;
1699         htlc_conv.inner = (void*)(htlc & (~1));
1700         htlc_conv.is_owned = false;
1701         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1702         *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);
1703         return (uint64_t)ret_conv;
1704 }
1705
1706 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) {
1707         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1708         LDKTransaction htlc_tx_ref;
1709         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
1710         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1711         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
1712         htlc_tx_ref.data_is_owned = true;
1713         LDKPublicKey per_commitment_point_ref;
1714         CHECK(*((uint32_t*)per_commitment_point) == 33);
1715         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
1716         LDKHTLCOutputInCommitment htlc_conv;
1717         htlc_conv.inner = (void*)(htlc & (~1));
1718         htlc_conv.is_owned = false;
1719         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1720         *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);
1721         return (uint64_t)ret_conv;
1722 }
1723
1724 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) {
1725         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1726         LDKTransaction closing_tx_ref;
1727         closing_tx_ref.datalen = *((uint32_t*)closing_tx);
1728         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1729         memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen);
1730         closing_tx_ref.data_is_owned = true;
1731         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1732         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1733         return (uint64_t)ret_conv;
1734 }
1735
1736 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
1737         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1738         LDKUnsignedChannelAnnouncement msg_conv;
1739         msg_conv.inner = (void*)(msg & (~1));
1740         msg_conv.is_owned = false;
1741         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1742         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1743         return (uint64_t)ret_conv;
1744 }
1745
1746 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
1747         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1748         LDKChannelTransactionParameters channel_parameters_conv;
1749         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1750         channel_parameters_conv.is_owned = false;
1751         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1752 }
1753
1754 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
1755         if (this_arg->set_pubkeys != NULL)
1756                 this_arg->set_pubkeys(this_arg);
1757         return this_arg->pubkeys;
1758 }
1759 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
1760         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1761         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
1762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1764         uint64_t ret_ref = (uint64_t)ret_var.inner;
1765         if (ret_var.is_owned) {
1766                 ret_ref |= 1;
1767         }
1768         return ret_ref;
1769 }
1770
1771 typedef struct LDKSign_JCalls {
1772         atomic_size_t refcnt;
1773         LDKBaseSign_JCalls* BaseSign;
1774         uint32_t write_meth;
1775 } LDKSign_JCalls;
1776 static void LDKSign_JCalls_free(void* this_arg) {
1777         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1778         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1779                 js_free(j_calls->write_meth);
1780                 FREE(j_calls);
1781         }
1782 }
1783 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
1784         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1785         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
1786         LDKCVec_u8Z ret_ref;
1787         ret_ref.datalen = *((uint32_t*)ret);
1788         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1789         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
1790         return ret_ref;
1791 }
1792 static void* LDKSign_JCalls_clone(const void* this_arg) {
1793         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1794         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1795         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
1796         return (void*) this_arg;
1797 }
1798 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
1799         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1800         atomic_init(&calls->refcnt, 1);
1801         //TODO: Assign calls->o from o
1802
1803         LDKChannelPublicKeys pubkeys_conv;
1804         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1805         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1806         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1807
1808         LDKSign ret = {
1809                 .this_arg = (void*) calls,
1810                 .write = write_LDKSign_jcall,
1811                 .clone = LDKSign_JCalls_clone,
1812                 .free = LDKSign_JCalls_free,
1813                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
1814         };
1815         calls->BaseSign = ret.BaseSign.this_arg;
1816         return ret;
1817 }
1818 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
1819         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
1820         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
1821         return (long)res_ptr;
1822 }
1823 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
1824         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1825         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1826         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1827         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
1828         CVec_u8Z_free(ret_var);
1829         return ret_arr;
1830 }
1831
1832 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
1833         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
1834 }
1835 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
1836         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
1837         CHECK(val->result_ok);
1838         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
1839         *ret = Sign_clone(&(*val->contents.result));
1840         return (uint64_t)ret;
1841 }
1842 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
1843         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
1844         CHECK(!val->result_ok);
1845         LDKDecodeError err_var = (*val->contents.err);
1846         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1847         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1848         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1849         return err_ref;
1850 }
1851 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_result_ok(uint32_t arg) {
1852         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
1853 }
1854 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_ok(uint32_t arg) {
1855         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
1856         CHECK(val->result_ok);
1857         int8_tArray es_arr = init_arr(68, sizeof(uint8_t), "Native int8_tArray Bytes");
1858         memcpy((uint8_t*)(es_arr + 4), (*val->contents.result).serialized_form, 68);
1859         return es_arr;
1860 }
1861 void  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_err(uint32_t arg) {
1862         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
1863         CHECK(!val->result_ok);
1864         return *val->contents.err;
1865 }
1866 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
1867         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
1868         for (size_t i = 0; i < ret.datalen; i++) {
1869                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
1870         }
1871         return ret;
1872 }
1873 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
1874         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
1875 }
1876 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
1877         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
1878         CHECK(val->result_ok);
1879         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
1880         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1881         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
1882         for (size_t m = 0; m < res_var.datalen; m++) {
1883                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
1884                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1885                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
1886                 res_arr_ptr[m] = res_conv_12_arr;
1887         }
1888         return res_arr;
1889 }
1890 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
1891         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
1892         CHECK(!val->result_ok);
1893         return *val->contents.err;
1894 }
1895 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
1896         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
1897 }
1898 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
1899         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
1900         CHECK(val->result_ok);
1901         LDKInMemorySigner res_var = (*val->contents.result);
1902         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1903         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1904         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1905         return res_ref;
1906 }
1907 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
1908         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
1909         CHECK(!val->result_ok);
1910         LDKDecodeError err_var = (*val->contents.err);
1911         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1912         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1913         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1914         return err_ref;
1915 }
1916 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
1917         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
1918         ret->datalen = *((uint32_t*)elems);
1919         if (ret->datalen == 0) {
1920                 ret->data = NULL;
1921         } else {
1922                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
1923                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1924                 for (size_t i = 0; i < ret->datalen; i++) {
1925                         uint32_t arr_elem = java_elems[i];
1926                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
1927                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
1928                         ret->data[i] = arr_elem_conv;
1929                 }
1930         }
1931         return (uint64_t)ret;
1932 }
1933 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
1934         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
1935         for (size_t i = 0; i < ret.datalen; i++) {
1936                 ret.data[i] = TxOut_clone(&orig->data[i]);
1937         }
1938         return ret;
1939 }
1940 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
1941         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
1942 }
1943 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
1944         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
1945         CHECK(val->result_ok);
1946         LDKTransaction res_var = (*val->contents.result);
1947         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1948         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
1949         return res_arr;
1950 }
1951 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
1952         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
1953         CHECK(!val->result_ok);
1954         return *val->contents.err;
1955 }
1956 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
1957         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
1958         LDKThirtyTwoBytes a_ref;
1959         CHECK(*((uint32_t*)a) == 32);
1960         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1961         ret->a = a_ref;
1962         LDKChannelMonitor b_conv;
1963         b_conv.inner = (void*)(b & (~1));
1964         b_conv.is_owned = (b & 1) || (b == 0);
1965         b_conv = ChannelMonitor_clone(&b_conv);
1966         ret->b = b_conv;
1967         return (uint64_t)ret;
1968 }
1969 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
1970         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1971         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1972         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1973         return a_arr;
1974 }
1975 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
1976         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1977         LDKChannelMonitor b_var = tuple->b;
1978         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1979         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1980         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
1981         return b_ref;
1982 }
1983 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_BlockHashChannelMonitorZZ_new(uint32_tArray elems) {
1984         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
1985         ret->datalen = *((uint32_t*)elems);
1986         if (ret->datalen == 0) {
1987                 ret->data = NULL;
1988         } else {
1989                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
1990                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1991                 for (size_t i = 0; i < ret->datalen; i++) {
1992                         uint32_t arr_elem = java_elems[i];
1993                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
1994                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
1995                         ret->data[i] = arr_elem_conv;
1996                 }
1997         }
1998         return (uint64_t)ret;
1999 }
2000 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(uint32_t arg) {
2001         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2002 }
2003 uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(uint32_t arg) {
2004         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2005         CHECK(val->result_ok);
2006         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2007         uint32_tArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2008         uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
2009         for (size_t m = 0; m < res_var.datalen; m++) {
2010                 uint64_t res_conv_38_ref = (uint64_t)(&res_var.data[m]) | 1;
2011                 res_arr_ptr[m] = res_conv_38_ref;
2012         }
2013         return res_arr;
2014 }
2015 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
2016         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2017         CHECK(!val->result_ok);
2018         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
2019         return err_conv;
2020 }
2021 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2022         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2023         switch(obj->tag) {
2024                 case LDKAPIError_APIMisuseError: {
2025                         LDKStr err_str = obj->api_misuse_error.err;
2026                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2027                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_conv;
2028                 }
2029                 case LDKAPIError_FeeRateTooHigh: {
2030                         LDKStr err_str = obj->fee_rate_too_high.err;
2031                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2032                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_conv; (void) obj->fee_rate_too_high.feerate;
2033                 }
2034                 case LDKAPIError_RouteError: {
2035                         LDKStr err_str = obj->route_error.err;
2036                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2037                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2038                 }
2039                 case LDKAPIError_ChannelUnavailable: {
2040                         LDKStr err_str = obj->channel_unavailable.err;
2041                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2042                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_conv;
2043                 }
2044                 case LDKAPIError_MonitorUpdateFailed: {
2045                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2046                 }
2047                 default: abort();
2048         }
2049 }
2050 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
2051         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2052 }
2053 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2054         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2055         CHECK(val->result_ok);
2056         return *val->contents.result;
2057 }
2058 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2059         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2060         CHECK(!val->result_ok);
2061         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2062         return err_ref;
2063 }
2064 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
2065         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2066         ret->datalen = *((uint32_t*)elems);
2067         if (ret->datalen == 0) {
2068                 ret->data = NULL;
2069         } else {
2070                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2071                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2072                 for (size_t i = 0; i < ret->datalen; i++) {
2073                         uint32_t arr_elem = java_elems[i];
2074                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2075                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2076                         ret->data[i] = arr_elem_conv;
2077                 }
2078         }
2079         return (uint64_t)ret;
2080 }
2081 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2082         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2083         for (size_t i = 0; i < ret.datalen; i++) {
2084                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2085         }
2086         return ret;
2087 }
2088 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
2089         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2090         ret->datalen = *((uint32_t*)elems);
2091         if (ret->datalen == 0) {
2092                 ret->data = NULL;
2093         } else {
2094                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2095                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2096                 for (size_t i = 0; i < ret->datalen; i++) {
2097                         uint32_t arr_elem = java_elems[i];
2098                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2099                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
2100                         ret->data[i] = arr_elem_conv;
2101                 }
2102         }
2103         return (uint64_t)ret;
2104 }
2105 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2106         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2107         for (size_t i = 0; i < ret.datalen; i++) {
2108                 ret.data[i] = APIError_clone(&orig->data[i]);
2109         }
2110         return ret;
2111 }
2112 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2113         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
2114         switch(obj->tag) {
2115                 case LDKPaymentSendFailure_ParameterError: {
2116                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
2117                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
2118                 }
2119                 case LDKPaymentSendFailure_PathParameterError: {
2120                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
2121                         uint32_tArray path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2122                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
2123                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
2124                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2125                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
2126                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
2127                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
2128                         }
2129                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
2130                 }
2131                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2132                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
2133                         uint32_tArray all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2134                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
2135                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
2136                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
2137                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
2138                         }
2139                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
2140                 }
2141                 case LDKPaymentSendFailure_PartialFailure: {
2142                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
2143                         uint32_tArray partial_failure_arr = init_arr(partial_failure_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2144                         uint32_t *partial_failure_arr_ptr = (uint32_t*)(partial_failure_arr + 4);
2145                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
2146                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2147                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
2148                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
2149                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
2150                         }
2151                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) partial_failure_arr;
2152                 }
2153                 default: abort();
2154         }
2155 }
2156 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
2157         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2158 }
2159 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2160         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2161         CHECK(val->result_ok);
2162         return *val->contents.result;
2163 }
2164 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2165         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2166         CHECK(!val->result_ok);
2167         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2168         return err_ref;
2169 }
2170 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
2171         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2172         switch(obj->tag) {
2173                 case LDKNetAddress_IPv4: {
2174                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
2175                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
2176                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
2177                 }
2178                 case LDKNetAddress_IPv6: {
2179                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
2180                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
2181                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
2182                 }
2183                 case LDKNetAddress_OnionV2: {
2184                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
2185                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
2186                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
2187                 }
2188                 case LDKNetAddress_OnionV3: {
2189                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2190                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
2191                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
2192                 }
2193                 default: abort();
2194         }
2195 }
2196 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
2197         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
2198         ret->datalen = *((uint32_t*)elems);
2199         if (ret->datalen == 0) {
2200                 ret->data = NULL;
2201         } else {
2202                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
2203                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2204                 for (size_t i = 0; i < ret->datalen; i++) {
2205                         uint32_t arr_elem = java_elems[i];
2206                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
2207                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
2208                         ret->data[i] = arr_elem_conv;
2209                 }
2210         }
2211         return (uint64_t)ret;
2212 }
2213 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2214         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2215         for (size_t i = 0; i < ret.datalen; i++) {
2216                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2217         }
2218         return ret;
2219 }
2220 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
2221         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
2222         LDKThirtyTwoBytes a_ref;
2223         CHECK(*((uint32_t*)a) == 32);
2224         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2225         ret->a = a_ref;
2226         LDKThirtyTwoBytes b_ref;
2227         CHECK(*((uint32_t*)b) == 32);
2228         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2229         ret->b = b_ref;
2230         return (uint64_t)ret;
2231 }
2232 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t ptr) {
2233         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
2234         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2235         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2236         return a_arr;
2237 }
2238 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t ptr) {
2239         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
2240         int8_tArray b_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2241         memcpy((uint8_t*)(b_arr + 4), tuple->b.data, 32);
2242         return b_arr;
2243 }
2244 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_result_ok(uint32_t arg) {
2245         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
2246 }
2247 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_ok(uint32_t arg) {
2248         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2249         CHECK(val->result_ok);
2250         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2251         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2252         return res_arr;
2253 }
2254 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_err(uint32_t arg) {
2255         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2256         CHECK(!val->result_ok);
2257         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2258         return err_ref;
2259 }
2260 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
2261         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2262         ret->datalen = *((uint32_t*)elems);
2263         if (ret->datalen == 0) {
2264                 ret->data = NULL;
2265         } else {
2266                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2267                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2268                 for (size_t i = 0; i < ret->datalen; i++) {
2269                         uint32_t arr_elem = java_elems[i];
2270                         LDKChannelMonitor arr_elem_conv;
2271                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2272                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2273                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2274                         ret->data[i] = arr_elem_conv;
2275                 }
2276         }
2277         return (uint64_t)ret;
2278 }
2279 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2280         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2281         for (size_t i = 0; i < ret.datalen; i++) {
2282                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2283         }
2284         return ret;
2285 }
2286 typedef struct LDKWatch_JCalls {
2287         atomic_size_t refcnt;
2288         uint32_t watch_channel_meth;
2289         uint32_t update_channel_meth;
2290         uint32_t release_pending_monitor_events_meth;
2291 } LDKWatch_JCalls;
2292 static void LDKWatch_JCalls_free(void* this_arg) {
2293         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2294         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2295                 js_free(j_calls->watch_channel_meth);
2296                 js_free(j_calls->update_channel_meth);
2297                 js_free(j_calls->release_pending_monitor_events_meth);
2298                 FREE(j_calls);
2299         }
2300 }
2301 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2302         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2303         LDKOutPoint funding_txo_var = funding_txo;
2304         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2305         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2306         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2307         if (funding_txo_var.is_owned) {
2308                 funding_txo_ref |= 1;
2309         }
2310         LDKChannelMonitor monitor_var = monitor;
2311         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2312         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2313         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
2314         if (monitor_var.is_owned) {
2315                 monitor_ref |= 1;
2316         }
2317         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2318         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2319         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2320         return ret_conv;
2321 }
2322 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2323         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2324         LDKOutPoint funding_txo_var = funding_txo;
2325         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2326         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2327         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2328         if (funding_txo_var.is_owned) {
2329                 funding_txo_ref |= 1;
2330         }
2331         LDKChannelMonitorUpdate update_var = update;
2332         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2333         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2334         uint64_t update_ref = (uint64_t)update_var.inner;
2335         if (update_var.is_owned) {
2336                 update_ref |= 1;
2337         }
2338         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2339         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2340         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2341         return ret_conv;
2342 }
2343 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
2344         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2345         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2346         LDKCVec_MonitorEventZ ret_constr;
2347         ret_constr.datalen = *((uint32_t*)ret);
2348         if (ret_constr.datalen > 0)
2349                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2350         else
2351                 ret_constr.data = NULL;
2352         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2353         for (size_t o = 0; o < ret_constr.datalen; o++) {
2354                 uint32_t ret_conv_14 = ret_vals[o];
2355                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
2356                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
2357                 ret_constr.data[o] = ret_conv_14_conv;
2358         }
2359         return ret_constr;
2360 }
2361 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2362         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2363         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2364         return (void*) this_arg;
2365 }
2366 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2367         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2368         atomic_init(&calls->refcnt, 1);
2369         //TODO: Assign calls->o from o
2370
2371         LDKWatch ret = {
2372                 .this_arg = (void*) calls,
2373                 .watch_channel = watch_channel_LDKWatch_jcall,
2374                 .update_channel = update_channel_LDKWatch_jcall,
2375                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
2376                 .free = LDKWatch_JCalls_free,
2377         };
2378         return ret;
2379 }
2380 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2381         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2382         *res_ptr = LDKWatch_init(o);
2383         return (long)res_ptr;
2384 }
2385 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2386         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2387         LDKOutPoint funding_txo_conv;
2388         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2389         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2390         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2391         LDKChannelMonitor monitor_conv;
2392         monitor_conv.inner = (void*)(monitor & (~1));
2393         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2394         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2395         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2396         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2397         return (uint64_t)ret_conv;
2398 }
2399
2400 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
2401         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2402         LDKOutPoint funding_txo_conv;
2403         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2404         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2405         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2406         LDKChannelMonitorUpdate update_conv;
2407         update_conv.inner = (void*)(update & (~1));
2408         update_conv.is_owned = (update & 1) || (update == 0);
2409         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2410         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2411         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2412         return (uint64_t)ret_conv;
2413 }
2414
2415 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
2416         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2417         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2418         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2419         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2420         for (size_t o = 0; o < ret_var.datalen; o++) {
2421                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2422                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
2423                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
2424                 ret_arr_ptr[o] = ret_conv_14_ref;
2425         }
2426         FREE(ret_var.data);
2427         return ret_arr;
2428 }
2429
2430 typedef struct LDKBroadcasterInterface_JCalls {
2431         atomic_size_t refcnt;
2432         uint32_t broadcast_transaction_meth;
2433 } LDKBroadcasterInterface_JCalls;
2434 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2435         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2436         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2437                 js_free(j_calls->broadcast_transaction_meth);
2438                 FREE(j_calls);
2439         }
2440 }
2441 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
2442         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2443         LDKTransaction tx_var = tx;
2444         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2445         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
2446         Transaction_free(tx_var);
2447         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
2448 }
2449 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2450         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2451         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2452         return (void*) this_arg;
2453 }
2454 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
2455         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2456         atomic_init(&calls->refcnt, 1);
2457         //TODO: Assign calls->o from o
2458
2459         LDKBroadcasterInterface ret = {
2460                 .this_arg = (void*) calls,
2461                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
2462                 .free = LDKBroadcasterInterface_JCalls_free,
2463         };
2464         return ret;
2465 }
2466 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
2467         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2468         *res_ptr = LDKBroadcasterInterface_init(o);
2469         return (long)res_ptr;
2470 }
2471 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
2472         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
2473         LDKTransaction tx_ref;
2474         tx_ref.datalen = *((uint32_t*)tx);
2475         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2476         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
2477         tx_ref.data_is_owned = true;
2478         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2479 }
2480
2481 typedef struct LDKKeysInterface_JCalls {
2482         atomic_size_t refcnt;
2483         uint32_t get_node_secret_meth;
2484         uint32_t get_destination_script_meth;
2485         uint32_t get_shutdown_pubkey_meth;
2486         uint32_t get_channel_signer_meth;
2487         uint32_t get_secure_random_bytes_meth;
2488         uint32_t read_chan_signer_meth;
2489         uint32_t sign_invoice_meth;
2490 } LDKKeysInterface_JCalls;
2491 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2492         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2493         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2494                 js_free(j_calls->get_node_secret_meth);
2495                 js_free(j_calls->get_destination_script_meth);
2496                 js_free(j_calls->get_shutdown_pubkey_meth);
2497                 js_free(j_calls->get_channel_signer_meth);
2498                 js_free(j_calls->get_secure_random_bytes_meth);
2499                 js_free(j_calls->read_chan_signer_meth);
2500                 js_free(j_calls->sign_invoice_meth);
2501                 FREE(j_calls);
2502         }
2503 }
2504 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
2505         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2506         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
2507         LDKSecretKey ret_ref;
2508         CHECK(*((uint32_t*)ret) == 32);
2509         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
2510         return ret_ref;
2511 }
2512 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
2513         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2514         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
2515         LDKCVec_u8Z ret_ref;
2516         ret_ref.datalen = *((uint32_t*)ret);
2517         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2518         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2519         return ret_ref;
2520 }
2521 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
2522         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2523         int8_tArray ret = js_invoke_function_0(j_calls->get_shutdown_pubkey_meth);
2524         LDKPublicKey ret_ref;
2525         CHECK(*((uint32_t*)ret) == 33);
2526         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
2527         return ret_ref;
2528 }
2529 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2530         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2531         LDKSign* ret = (LDKSign*)js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
2532         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
2533         ret_conv = Sign_clone(ret);
2534         return ret_conv;
2535 }
2536 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
2537         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2538         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
2539         LDKThirtyTwoBytes ret_ref;
2540         CHECK(*((uint32_t*)ret) == 32);
2541         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
2542         return ret_ref;
2543 }
2544 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
2545         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2546         LDKu8slice reader_var = reader;
2547         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2548         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
2549         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
2550         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
2551         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
2552         return ret_conv;
2553 }
2554 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
2555         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2556         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
2557         int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2558         memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
2559         CVec_u8Z_free(invoice_preimage_var);
2560         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
2561         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
2562         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
2563         return ret_conv;
2564 }
2565 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2566         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2567         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2568         return (void*) this_arg;
2569 }
2570 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
2571         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2572         atomic_init(&calls->refcnt, 1);
2573         //TODO: Assign calls->o from o
2574
2575         LDKKeysInterface ret = {
2576                 .this_arg = (void*) calls,
2577                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
2578                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
2579                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
2580                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
2581                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
2582                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
2583                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
2584                 .free = LDKKeysInterface_JCalls_free,
2585         };
2586         return ret;
2587 }
2588 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
2589         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2590         *res_ptr = LDKKeysInterface_init(o);
2591         return (long)res_ptr;
2592 }
2593 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
2594         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2595         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2596         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
2597         return ret_arr;
2598 }
2599
2600 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
2601         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2602         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2603         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2604         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2605         CVec_u8Z_free(ret_var);
2606         return ret_arr;
2607 }
2608
2609 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_pubkey(uint32_t this_arg) {
2610         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2611         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2612         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
2613         return ret_arr;
2614 }
2615
2616 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
2617         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2618         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2619         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2620         return (uint64_t)ret;
2621 }
2622
2623 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2624         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2625         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2626         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2627         return ret_arr;
2628 }
2629
2630 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2631         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2632         LDKu8slice reader_ref;
2633         reader_ref.datalen = *((uint32_t*)reader);
2634         reader_ref.data = (int8_t*)(reader + 4);
2635         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
2636         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2637         return (uint64_t)ret_conv;
2638 }
2639
2640 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
2641         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2642         LDKCVec_u8Z invoice_preimage_ref;
2643         invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
2644         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
2645         memcpy(invoice_preimage_ref.data, (uint8_t*)(invoice_preimage + 4), invoice_preimage_ref.datalen);
2646         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
2647         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
2648         return (uint64_t)ret_conv;
2649 }
2650
2651 typedef struct LDKFeeEstimator_JCalls {
2652         atomic_size_t refcnt;
2653         uint32_t get_est_sat_per_1000_weight_meth;
2654 } LDKFeeEstimator_JCalls;
2655 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2656         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2657         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2658                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
2659                 FREE(j_calls);
2660         }
2661 }
2662 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2663         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2664         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
2665         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2666 }
2667 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2668         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2669         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2670         return (void*) this_arg;
2671 }
2672 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
2673         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2674         atomic_init(&calls->refcnt, 1);
2675         //TODO: Assign calls->o from o
2676
2677         LDKFeeEstimator ret = {
2678                 .this_arg = (void*) calls,
2679                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
2680                 .free = LDKFeeEstimator_JCalls_free,
2681         };
2682         return ret;
2683 }
2684 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
2685         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2686         *res_ptr = LDKFeeEstimator_init(o);
2687         return (long)res_ptr;
2688 }
2689 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
2690         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
2691         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
2692         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2693         return ret_val;
2694 }
2695
2696 typedef struct LDKLogger_JCalls {
2697         atomic_size_t refcnt;
2698         uint32_t log_meth;
2699 } LDKLogger_JCalls;
2700 static void LDKLogger_JCalls_free(void* this_arg) {
2701         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2702         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2703                 js_free(j_calls->log_meth);
2704                 FREE(j_calls);
2705         }
2706 }
2707 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
2708         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2709         const char* record_str = record;
2710         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
2711         js_invoke_function_1(j_calls->log_meth, record_conv);
2712 }
2713 static void* LDKLogger_JCalls_clone(const void* this_arg) {
2714         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2715         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2716         return (void*) this_arg;
2717 }
2718 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
2719         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2720         atomic_init(&calls->refcnt, 1);
2721         //TODO: Assign calls->o from o
2722
2723         LDKLogger ret = {
2724                 .this_arg = (void*) calls,
2725                 .log = log_LDKLogger_jcall,
2726                 .free = LDKLogger_JCalls_free,
2727         };
2728         return ret;
2729 }
2730 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
2731         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2732         *res_ptr = LDKLogger_init(o);
2733         return (long)res_ptr;
2734 }
2735 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
2736         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
2737         LDKThirtyTwoBytes a_ref;
2738         CHECK(*((uint32_t*)a) == 32);
2739         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2740         ret->a = a_ref;
2741         LDKChannelManager b_conv;
2742         b_conv.inner = (void*)(b & (~1));
2743         b_conv.is_owned = (b & 1) || (b == 0);
2744         // Warning: we need a move here but no clone is available for LDKChannelManager
2745         ret->b = b_conv;
2746         return (uint64_t)ret;
2747 }
2748 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
2749         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2750         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2751         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2752         return a_arr;
2753 }
2754 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
2755         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2756         LDKChannelManager b_var = tuple->b;
2757         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2758         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2759         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2760         return b_ref;
2761 }
2762 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
2763         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
2764 }
2765 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
2766         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2767         CHECK(val->result_ok);
2768         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2769         return res_ref;
2770 }
2771 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
2772         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2773         CHECK(!val->result_ok);
2774         LDKDecodeError err_var = (*val->contents.err);
2775         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2776         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2777         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2778         return err_ref;
2779 }
2780 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
2781         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
2782 }
2783 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
2784         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
2785         CHECK(val->result_ok);
2786         LDKChannelConfig res_var = (*val->contents.result);
2787         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2788         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2789         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2790         return res_ref;
2791 }
2792 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
2793         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
2794         CHECK(!val->result_ok);
2795         LDKDecodeError err_var = (*val->contents.err);
2796         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2797         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2798         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2799         return err_ref;
2800 }
2801 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
2802         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
2803 }
2804 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
2805         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
2806         CHECK(val->result_ok);
2807         LDKOutPoint res_var = (*val->contents.result);
2808         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2809         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2810         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2811         return res_ref;
2812 }
2813 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
2814         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
2815         CHECK(!val->result_ok);
2816         LDKDecodeError err_var = (*val->contents.err);
2817         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2818         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2819         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2820         return err_ref;
2821 }
2822 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) {
2823         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
2824 }
2825 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_ok(uint32_t arg) {
2826         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
2827         CHECK(val->result_ok);
2828         uint32_t res_conv = LDKSiPrefix_to_js((*val->contents.result));
2829         return res_conv;
2830 }
2831 void  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_err(uint32_t arg) {
2832         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
2833         CHECK(!val->result_ok);
2834         return *val->contents.err;
2835 }
2836 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_result_ok(uint32_t arg) {
2837         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
2838 }
2839 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_ok(uint32_t arg) {
2840         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
2841         CHECK(val->result_ok);
2842         LDKInvoice res_var = (*val->contents.result);
2843         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2844         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2845         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2846         return res_ref;
2847 }
2848 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
2849         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
2850         CHECK(!val->result_ok);
2851         return *val->contents.err;
2852 }
2853 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_result_ok(uint32_t arg) {
2854         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
2855 }
2856 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_ok(uint32_t arg) {
2857         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
2858         CHECK(val->result_ok);
2859         LDKSignedRawInvoice res_var = (*val->contents.result);
2860         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2861         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2862         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2863         return res_ref;
2864 }
2865 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
2866         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
2867         CHECK(!val->result_ok);
2868         return *val->contents.err;
2869 }
2870 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
2871         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
2872         LDKRawInvoice a_conv;
2873         a_conv.inner = (void*)(a & (~1));
2874         a_conv.is_owned = (a & 1) || (a == 0);
2875         a_conv = RawInvoice_clone(&a_conv);
2876         ret->a = a_conv;
2877         LDKThirtyTwoBytes b_ref;
2878         CHECK(*((uint32_t*)b) == 32);
2879         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2880         ret->b = b_ref;
2881         LDKInvoiceSignature c_conv;
2882         c_conv.inner = (void*)(c & (~1));
2883         c_conv.is_owned = (c & 1) || (c == 0);
2884         c_conv = InvoiceSignature_clone(&c_conv);
2885         ret->c = c_conv;
2886         return (uint64_t)ret;
2887 }
2888 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t ptr) {
2889         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2890         LDKRawInvoice a_var = tuple->a;
2891         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2892         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2893         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
2894         return a_ref;
2895 }
2896 int8_tArray  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t ptr) {
2897         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2898         int8_tArray b_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2899         memcpy((uint8_t*)(b_arr + 4), tuple->b.data, 32);
2900         return b_arr;
2901 }
2902 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t ptr) {
2903         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2904         LDKInvoiceSignature c_var = tuple->c;
2905         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2906         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2907         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
2908         return c_ref;
2909 }
2910 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_result_ok(uint32_t arg) {
2911         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
2912 }
2913 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_ok(uint32_t arg) {
2914         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
2915         CHECK(val->result_ok);
2916         LDKPayeePubKey res_var = (*val->contents.result);
2917         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2918         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2919         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2920         return res_ref;
2921 }
2922 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
2923         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
2924         CHECK(!val->result_ok);
2925         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2926         return err_conv;
2927 }
2928 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_PrivateRouteZ_new(uint32_tArray elems) {
2929         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
2930         ret->datalen = *((uint32_t*)elems);
2931         if (ret->datalen == 0) {
2932                 ret->data = NULL;
2933         } else {
2934                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
2935                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2936                 for (size_t i = 0; i < ret->datalen; i++) {
2937                         uint32_t arr_elem = java_elems[i];
2938                         LDKPrivateRoute arr_elem_conv;
2939                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2940                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2941                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
2942                         ret->data[i] = arr_elem_conv;
2943                 }
2944         }
2945         return (uint64_t)ret;
2946 }
2947 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
2948         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
2949         for (size_t i = 0; i < ret.datalen; i++) {
2950                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
2951         }
2952         return ret;
2953 }
2954 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_result_ok(uint32_t arg) {
2955         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
2956 }
2957 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t arg) {
2958         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
2959         CHECK(val->result_ok);
2960         LDKPositiveTimestamp res_var = (*val->contents.result);
2961         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2962         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2963         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2964         return res_ref;
2965 }
2966 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
2967         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
2968         CHECK(!val->result_ok);
2969         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
2970         return err_conv;
2971 }
2972 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_result_ok(uint32_t arg) {
2973         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
2974 }
2975 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_ok(uint32_t arg) {
2976         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
2977         CHECK(val->result_ok);
2978         return *val->contents.result;
2979 }
2980 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_err(uint32_t arg) {
2981         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
2982         CHECK(!val->result_ok);
2983         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
2984         return err_conv;
2985 }
2986 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_result_ok(uint32_t arg) {
2987         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
2988 }
2989 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_ok(uint32_t arg) {
2990         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
2991         CHECK(val->result_ok);
2992         LDKInvoice res_var = (*val->contents.result);
2993         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2994         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2995         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2996         return res_ref;
2997 }
2998 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
2999         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3000         CHECK(!val->result_ok);
3001         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3002         return err_conv;
3003 }
3004 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_result_ok(uint32_t arg) {
3005         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
3006 }
3007 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_ok(uint32_t arg) {
3008         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3009         CHECK(val->result_ok);
3010         LDKDescription res_var = (*val->contents.result);
3011         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3012         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3013         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3014         return res_ref;
3015 }
3016 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
3017         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3018         CHECK(!val->result_ok);
3019         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3020         return err_conv;
3021 }
3022 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_result_ok(uint32_t arg) {
3023         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
3024 }
3025 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_ok(uint32_t arg) {
3026         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3027         CHECK(val->result_ok);
3028         LDKExpiryTime res_var = (*val->contents.result);
3029         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3030         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3031         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3032         return res_ref;
3033 }
3034 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
3035         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3036         CHECK(!val->result_ok);
3037         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3038         return err_conv;
3039 }
3040 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_result_ok(uint32_t arg) {
3041         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
3042 }
3043 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_ok(uint32_t arg) {
3044         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3045         CHECK(val->result_ok);
3046         LDKPrivateRoute res_var = (*val->contents.result);
3047         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3048         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3049         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3050         return res_ref;
3051 }
3052 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
3053         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3054         CHECK(!val->result_ok);
3055         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3056         return err_conv;
3057 }
3058 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_result_ok(uint32_t arg) {
3059         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
3060 }
3061 jstring  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_ok(uint32_t arg) {
3062         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3063         CHECK(val->result_ok);
3064         LDKStr res_str = (*val->contents.result);
3065         jstring res_conv = str_ref_to_ts(res_str.chars, res_str.len);
3066         return res_conv;
3067 }
3068 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_err(uint32_t arg) {
3069         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3070         CHECK(!val->result_ok);
3071         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3072         return err_conv;
3073 }
3074 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3075         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
3076 }
3077 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3078         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3079         CHECK(val->result_ok);
3080         LDKChannelMonitorUpdate res_var = (*val->contents.result);
3081         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3082         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3083         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3084         return res_ref;
3085 }
3086 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
3087         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3088         CHECK(!val->result_ok);
3089         LDKDecodeError err_var = (*val->contents.err);
3090         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3091         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3092         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3093         return err_ref;
3094 }
3095 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3096         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
3097 }
3098 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3099         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3100         CHECK(val->result_ok);
3101         LDKHTLCUpdate res_var = (*val->contents.result);
3102         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3103         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3104         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3105         return res_ref;
3106 }
3107 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
3108         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3109         CHECK(!val->result_ok);
3110         LDKDecodeError err_var = (*val->contents.err);
3111         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3112         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3113         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3114         return err_ref;
3115 }
3116 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
3117         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
3118 }
3119 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
3120         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3121         CHECK(val->result_ok);
3122         return *val->contents.result;
3123 }
3124 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
3125         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3126         CHECK(!val->result_ok);
3127         LDKMonitorUpdateError err_var = (*val->contents.err);
3128         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3129         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3130         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3131         return err_ref;
3132 }
3133 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
3134         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
3135         LDKOutPoint a_conv;
3136         a_conv.inner = (void*)(a & (~1));
3137         a_conv.is_owned = (a & 1) || (a == 0);
3138         a_conv = OutPoint_clone(&a_conv);
3139         ret->a = a_conv;
3140         LDKCVec_u8Z b_ref;
3141         b_ref.datalen = *((uint32_t*)b);
3142         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3143         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3144         ret->b = b_ref;
3145         return (uint64_t)ret;
3146 }
3147 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
3148         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
3149         LDKOutPoint a_var = tuple->a;
3150         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3151         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3152         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3153         return a_ref;
3154 }
3155 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
3156         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
3157         LDKCVec_u8Z b_var = tuple->b;
3158         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3159         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
3160         return b_arr;
3161 }
3162 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
3163         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
3164         ret->a = a;
3165         LDKCVec_u8Z b_ref;
3166         b_ref.datalen = *((uint32_t*)b);
3167         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3168         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3169         ret->b = b_ref;
3170         return (uint64_t)ret;
3171 }
3172 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_a(uint32_t ptr) {
3173         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
3174         return tuple->a;
3175 }
3176 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_b(uint32_t ptr) {
3177         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
3178         LDKCVec_u8Z b_var = tuple->b;
3179         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3180         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
3181         return b_arr;
3182 }
3183 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
3184         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
3185         ret->datalen = *((uint32_t*)elems);
3186         if (ret->datalen == 0) {
3187                 ret->data = NULL;
3188         } else {
3189                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
3190                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3191                 for (size_t i = 0; i < ret->datalen; i++) {
3192                         uint32_t arr_elem = java_elems[i];
3193                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
3194                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
3195                         ret->data[i] = arr_elem_conv;
3196                 }
3197         }
3198         return (uint64_t)ret;
3199 }
3200 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
3201         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
3202         for (size_t i = 0; i < ret.datalen; i++) {
3203                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
3204         }
3205         return ret;
3206 }
3207 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
3208         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
3209         LDKThirtyTwoBytes a_ref;
3210         CHECK(*((uint32_t*)a) == 32);
3211         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3212         ret->a = a_ref;
3213         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
3214         b_constr.datalen = *((uint32_t*)b);
3215         if (b_constr.datalen > 0)
3216                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
3217         else
3218                 b_constr.data = NULL;
3219         uint32_t* b_vals = (uint32_t*)(b + 4);
3220         for (size_t e = 0; e < b_constr.datalen; e++) {
3221                 uint32_t b_conv_30 = b_vals[e];
3222                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
3223                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
3224                 b_constr.data[e] = b_conv_30_conv;
3225         }
3226         ret->b = b_constr;
3227         return (uint64_t)ret;
3228 }
3229 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t ptr) {
3230         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
3231         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3232         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
3233         return a_arr;
3234 }
3235 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t ptr) {
3236         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
3237         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
3238         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3239         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
3240         for (size_t e = 0; e < b_var.datalen; e++) {
3241                 uint64_t b_conv_30_ref = (uint64_t)(&b_var.data[e]) | 1;
3242                 b_arr_ptr[e] = b_conv_30_ref;
3243         }
3244         return b_arr;
3245 }
3246 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
3247         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
3248         ret->datalen = *((uint32_t*)elems);
3249         if (ret->datalen == 0) {
3250                 ret->data = NULL;
3251         } else {
3252                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
3253                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3254                 for (size_t i = 0; i < ret->datalen; i++) {
3255                         uint32_t arr_elem = java_elems[i];
3256                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
3257                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
3258                         ret->data[i] = arr_elem_conv;
3259                 }
3260         }
3261         return (uint64_t)ret;
3262 }
3263 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
3264         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 };
3265         for (size_t i = 0; i < ret.datalen; i++) {
3266                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
3267         }
3268         return ret;
3269 }
3270 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
3271         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
3272         switch(obj->tag) {
3273                 case LDKEvent_FundingGenerationReady: {
3274                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3275                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
3276                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3277                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3278                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
3279                         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;
3280                 }
3281                 case LDKEvent_PaymentReceived: {
3282                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3283                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
3284                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3285                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_received.payment_preimage.data, 32);
3286                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3287                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32);
3288                         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;
3289                 }
3290                 case LDKEvent_PaymentSent: {
3291                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3292                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
3293                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
3294                 }
3295                 case LDKEvent_PaymentFailed: {
3296                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3297                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
3298                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
3299                 }
3300                 case LDKEvent_PendingHTLCsForwardable: {
3301                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
3302                 }
3303                 case LDKEvent_SpendableOutputs: {
3304                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3305                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3306                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
3307                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3308                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
3309                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3310                         }
3311                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
3312                 }
3313                 default: abort();
3314         }
3315 }
3316 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
3317         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
3318         ret->datalen = *((uint32_t*)elems);
3319         if (ret->datalen == 0) {
3320                 ret->data = NULL;
3321         } else {
3322                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
3323                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3324                 for (size_t i = 0; i < ret->datalen; i++) {
3325                         uint32_t arr_elem = java_elems[i];
3326                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
3327                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
3328                         ret->data[i] = arr_elem_conv;
3329                 }
3330         }
3331         return (uint64_t)ret;
3332 }
3333 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
3334         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
3335         for (size_t i = 0; i < ret.datalen; i++) {
3336                 ret.data[i] = Event_clone(&orig->data[i]);
3337         }
3338         return ret;
3339 }
3340 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
3341         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
3342         ret->a = a;
3343         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
3344         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
3345         ret->b = b_conv;
3346         return (uint64_t)ret;
3347 }
3348 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
3349         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
3350         return tuple->a;
3351 }
3352 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
3353         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
3354         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
3355         return (uint64_t)b_ref;
3356 }
3357 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
3358         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
3359         ret->datalen = *((uint32_t*)elems);
3360         if (ret->datalen == 0) {
3361                 ret->data = NULL;
3362         } else {
3363                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
3364                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3365                 for (size_t i = 0; i < ret->datalen; i++) {
3366                         uint32_t arr_elem = java_elems[i];
3367                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
3368                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
3369                         ret->data[i] = arr_elem_conv;
3370                 }
3371         }
3372         return (uint64_t)ret;
3373 }
3374 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
3375         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
3376         for (size_t i = 0; i < ret.datalen; i++) {
3377                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
3378         }
3379         return ret;
3380 }
3381 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
3382         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
3383         LDKThirtyTwoBytes a_ref;
3384         CHECK(*((uint32_t*)a) == 32);
3385         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3386         ret->a = a_ref;
3387         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
3388         b_constr.datalen = *((uint32_t*)b);
3389         if (b_constr.datalen > 0)
3390                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
3391         else
3392                 b_constr.data = NULL;
3393         uint32_t* b_vals = (uint32_t*)(b + 4);
3394         for (size_t z = 0; z < b_constr.datalen; z++) {
3395                 uint32_t b_conv_25 = b_vals[z];
3396                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
3397                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
3398                 b_constr.data[z] = b_conv_25_conv;
3399         }
3400         ret->b = b_constr;
3401         return (uint64_t)ret;
3402 }
3403 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
3404         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
3405         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3406         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
3407         return a_arr;
3408 }
3409 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
3410         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
3411         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
3412         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3413         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
3414         for (size_t z = 0; z < b_var.datalen; z++) {
3415                 uint64_t b_conv_25_ref = (uint64_t)(&b_var.data[z]) | 1;
3416                 b_arr_ptr[z] = b_conv_25_ref;
3417         }
3418         return b_arr;
3419 }
3420 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
3421         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
3422         ret->datalen = *((uint32_t*)elems);
3423         if (ret->datalen == 0) {
3424                 ret->data = NULL;
3425         } else {
3426                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
3427                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3428                 for (size_t i = 0; i < ret->datalen; i++) {
3429                         uint32_t arr_elem = java_elems[i];
3430                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
3431                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
3432                         ret->data[i] = arr_elem_conv;
3433                 }
3434         }
3435         return (uint64_t)ret;
3436 }
3437 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
3438         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 };
3439         for (size_t i = 0; i < ret.datalen; i++) {
3440                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
3441         }
3442         return ret;
3443 }
3444 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
3445         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
3446 }
3447 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
3448         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
3449         CHECK(val->result_ok);
3450         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
3451         return res_ref;
3452 }
3453 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
3454         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
3455         CHECK(!val->result_ok);
3456         LDKDecodeError err_var = (*val->contents.err);
3457         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3458         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3459         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3460         return err_ref;
3461 }
3462 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
3463         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3464 }
3465 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
3466         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
3467         CHECK(val->result_ok);
3468         return *val->contents.result;
3469 }
3470 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
3471         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
3472         CHECK(!val->result_ok);
3473         LDKLightningError err_var = (*val->contents.err);
3474         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3475         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3476         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3477         return err_ref;
3478 }
3479 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
3480         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
3481         LDKChannelAnnouncement a_conv;
3482         a_conv.inner = (void*)(a & (~1));
3483         a_conv.is_owned = (a & 1) || (a == 0);
3484         a_conv = ChannelAnnouncement_clone(&a_conv);
3485         ret->a = a_conv;
3486         LDKChannelUpdate b_conv;
3487         b_conv.inner = (void*)(b & (~1));
3488         b_conv.is_owned = (b & 1) || (b == 0);
3489         b_conv = ChannelUpdate_clone(&b_conv);
3490         ret->b = b_conv;
3491         LDKChannelUpdate c_conv;
3492         c_conv.inner = (void*)(c & (~1));
3493         c_conv.is_owned = (c & 1) || (c == 0);
3494         c_conv = ChannelUpdate_clone(&c_conv);
3495         ret->c = c_conv;
3496         return (uint64_t)ret;
3497 }
3498 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t ptr) {
3499         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3500         LDKChannelAnnouncement a_var = tuple->a;
3501         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3502         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3503         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3504         return a_ref;
3505 }
3506 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t ptr) {
3507         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3508         LDKChannelUpdate b_var = tuple->b;
3509         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3510         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3511         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
3512         return b_ref;
3513 }
3514 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t ptr) {
3515         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3516         LDKChannelUpdate c_var = tuple->c;
3517         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3518         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3519         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
3520         return c_ref;
3521 }
3522 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
3523         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
3524         ret->datalen = *((uint32_t*)elems);
3525         if (ret->datalen == 0) {
3526                 ret->data = NULL;
3527         } else {
3528                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
3529                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3530                 for (size_t i = 0; i < ret->datalen; i++) {
3531                         uint32_t arr_elem = java_elems[i];
3532                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
3533                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
3534                         ret->data[i] = arr_elem_conv;
3535                 }
3536         }
3537         return (uint64_t)ret;
3538 }
3539 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3540         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3541         for (size_t i = 0; i < ret.datalen; i++) {
3542                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3543         }
3544         return ret;
3545 }
3546 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
3547         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
3548         ret->datalen = *((uint32_t*)elems);
3549         if (ret->datalen == 0) {
3550                 ret->data = NULL;
3551         } else {
3552                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
3553                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3554                 for (size_t i = 0; i < ret->datalen; i++) {
3555                         uint32_t arr_elem = java_elems[i];
3556                         LDKNodeAnnouncement arr_elem_conv;
3557                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3558                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3559                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
3560                         ret->data[i] = arr_elem_conv;
3561                 }
3562         }
3563         return (uint64_t)ret;
3564 }
3565 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3566         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3567         for (size_t i = 0; i < ret.datalen; i++) {
3568                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3569         }
3570         return ret;
3571 }
3572 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
3573         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
3574 }
3575 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
3576         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
3577         CHECK(val->result_ok);
3578         return *val->contents.result;
3579 }
3580 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
3581         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
3582         CHECK(!val->result_ok);
3583         LDKLightningError err_var = (*val->contents.err);
3584         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3585         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3586         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3587         return err_ref;
3588 }
3589 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
3590         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
3591 }
3592 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
3593         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
3594         CHECK(val->result_ok);
3595         LDKCVec_u8Z res_var = (*val->contents.result);
3596         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3597         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
3598         return res_arr;
3599 }
3600 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
3601         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
3602         CHECK(!val->result_ok);
3603         LDKPeerHandleError err_var = (*val->contents.err);
3604         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3605         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3606         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3607         return err_ref;
3608 }
3609 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
3610         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
3611 }
3612 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
3613         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
3614         CHECK(val->result_ok);
3615         return *val->contents.result;
3616 }
3617 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
3618         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
3619         CHECK(!val->result_ok);
3620         LDKPeerHandleError err_var = (*val->contents.err);
3621         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3622         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3623         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3624         return err_ref;
3625 }
3626 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
3627         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
3628 }
3629 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
3630         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
3631         CHECK(val->result_ok);
3632         return *val->contents.result;
3633 }
3634 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
3635         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
3636         CHECK(!val->result_ok);
3637         LDKPeerHandleError err_var = (*val->contents.err);
3638         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3639         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3640         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3641         return err_ref;
3642 }
3643 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
3644         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
3645 }
3646 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
3647         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
3648         CHECK(val->result_ok);
3649         LDKDirectionalChannelInfo res_var = (*val->contents.result);
3650         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3651         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3652         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3653         return res_ref;
3654 }
3655 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
3656         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
3657         CHECK(!val->result_ok);
3658         LDKDecodeError err_var = (*val->contents.err);
3659         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3660         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3661         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3662         return err_ref;
3663 }
3664 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
3665         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
3666 }
3667 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
3668         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
3669         CHECK(val->result_ok);
3670         LDKChannelInfo res_var = (*val->contents.result);
3671         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3672         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3673         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3674         return res_ref;
3675 }
3676 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
3677         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
3678         CHECK(!val->result_ok);
3679         LDKDecodeError err_var = (*val->contents.err);
3680         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3681         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3682         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3683         return err_ref;
3684 }
3685 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
3686         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
3687 }
3688 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
3689         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
3690         CHECK(val->result_ok);
3691         LDKRoutingFees res_var = (*val->contents.result);
3692         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3693         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3694         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3695         return res_ref;
3696 }
3697 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
3698         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
3699         CHECK(!val->result_ok);
3700         LDKDecodeError err_var = (*val->contents.err);
3701         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3702         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3703         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3704         return err_ref;
3705 }
3706 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
3707         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
3708 }
3709 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
3710         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
3711         CHECK(val->result_ok);
3712         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
3713         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3714         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3715         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3716         return res_ref;
3717 }
3718 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
3719         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
3720         CHECK(!val->result_ok);
3721         LDKDecodeError err_var = (*val->contents.err);
3722         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3723         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3724         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3725         return err_ref;
3726 }
3727 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
3728         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
3729         ret->datalen = *((uint32_t*)elems);
3730         if (ret->datalen == 0) {
3731                 ret->data = NULL;
3732         } else {
3733                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
3734                 int64_t *java_elems = (int64_t*)(elems + 4);
3735                 for (size_t i = 0; i < ret->datalen; i++) {
3736                         ret->data[i] = java_elems[i];
3737                 }
3738         }
3739         return (uint64_t)ret;
3740 }
3741 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3742         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3743         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3744         return ret;
3745 }
3746 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
3747         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
3748 }
3749 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
3750         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3751         CHECK(val->result_ok);
3752         LDKNodeInfo res_var = (*val->contents.result);
3753         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3754         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3755         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3756         return res_ref;
3757 }
3758 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
3759         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3760         CHECK(!val->result_ok);
3761         LDKDecodeError err_var = (*val->contents.err);
3762         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3763         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3764         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3765         return err_ref;
3766 }
3767 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
3768         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
3769 }
3770 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
3771         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3772         CHECK(val->result_ok);
3773         LDKNetworkGraph res_var = (*val->contents.result);
3774         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3775         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3776         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3777         return res_ref;
3778 }
3779 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
3780         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3781         CHECK(!val->result_ok);
3782         LDKDecodeError err_var = (*val->contents.err);
3783         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3784         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3785         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3786         return err_ref;
3787 }
3788 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
3789         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3790 }
3791 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
3792         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3793         CHECK(val->result_ok);
3794         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3795         return res_ref;
3796 }
3797 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
3798         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3799         CHECK(!val->result_ok);
3800         return *val->contents.err;
3801 }
3802 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
3803         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3804 }
3805 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
3806         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3807         CHECK(val->result_ok);
3808         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3809         *res_conv = (*val->contents.result);
3810         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3811         return (uint64_t)res_conv;
3812 }
3813 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
3814         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3815         CHECK(!val->result_ok);
3816         LDKDecodeError err_var = (*val->contents.err);
3817         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3818         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3819         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3820         return err_ref;
3821 }
3822 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_result_ok(uint32_t arg) {
3823         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
3824 }
3825 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_ok(uint32_t arg) {
3826         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
3827         CHECK(val->result_ok);
3828         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3829         return res_ref;
3830 }
3831 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_err(uint32_t arg) {
3832         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
3833         CHECK(!val->result_ok);
3834         LDKDecodeError err_var = (*val->contents.err);
3835         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3836         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3837         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3838         return err_ref;
3839 }
3840 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
3841         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3842         ret->datalen = *((uint32_t*)elems);
3843         if (ret->datalen == 0) {
3844                 ret->data = NULL;
3845         } else {
3846                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3847                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3848                 for (size_t i = 0; i < ret->datalen; i++) {
3849                         uint32_t arr_elem = java_elems[i];
3850                         LDKUpdateAddHTLC arr_elem_conv;
3851                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3852                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3853                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3854                         ret->data[i] = arr_elem_conv;
3855                 }
3856         }
3857         return (uint64_t)ret;
3858 }
3859 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3860         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3861         for (size_t i = 0; i < ret.datalen; i++) {
3862                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3863         }
3864         return ret;
3865 }
3866 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
3867         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3868         ret->datalen = *((uint32_t*)elems);
3869         if (ret->datalen == 0) {
3870                 ret->data = NULL;
3871         } else {
3872                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3873                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3874                 for (size_t i = 0; i < ret->datalen; i++) {
3875                         uint32_t arr_elem = java_elems[i];
3876                         LDKUpdateFulfillHTLC arr_elem_conv;
3877                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3878                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3879                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3880                         ret->data[i] = arr_elem_conv;
3881                 }
3882         }
3883         return (uint64_t)ret;
3884 }
3885 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
3886         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
3887         for (size_t i = 0; i < ret.datalen; i++) {
3888                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
3889         }
3890         return ret;
3891 }
3892 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
3893         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
3894         ret->datalen = *((uint32_t*)elems);
3895         if (ret->datalen == 0) {
3896                 ret->data = NULL;
3897         } else {
3898                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
3899                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3900                 for (size_t i = 0; i < ret->datalen; i++) {
3901                         uint32_t arr_elem = java_elems[i];
3902                         LDKUpdateFailHTLC arr_elem_conv;
3903                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3904                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3905                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3906                         ret->data[i] = arr_elem_conv;
3907                 }
3908         }
3909         return (uint64_t)ret;
3910 }
3911 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
3912         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
3913         for (size_t i = 0; i < ret.datalen; i++) {
3914                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
3915         }
3916         return ret;
3917 }
3918 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
3919         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
3920         ret->datalen = *((uint32_t*)elems);
3921         if (ret->datalen == 0) {
3922                 ret->data = NULL;
3923         } else {
3924                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
3925                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3926                 for (size_t i = 0; i < ret->datalen; i++) {
3927                         uint32_t arr_elem = java_elems[i];
3928                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3929                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3930                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3931                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3932                         ret->data[i] = arr_elem_conv;
3933                 }
3934         }
3935         return (uint64_t)ret;
3936 }
3937 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
3938         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
3939         for (size_t i = 0; i < ret.datalen; i++) {
3940                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
3941         }
3942         return ret;
3943 }
3944 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
3945         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
3946 }
3947 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
3948         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3949         CHECK(val->result_ok);
3950         LDKAcceptChannel res_var = (*val->contents.result);
3951         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3952         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3953         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3954         return res_ref;
3955 }
3956 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
3957         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3958         CHECK(!val->result_ok);
3959         LDKDecodeError err_var = (*val->contents.err);
3960         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3961         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3962         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3963         return err_ref;
3964 }
3965 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
3966         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
3967 }
3968 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
3969         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3970         CHECK(val->result_ok);
3971         LDKAnnouncementSignatures res_var = (*val->contents.result);
3972         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3973         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3974         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3975         return res_ref;
3976 }
3977 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
3978         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3979         CHECK(!val->result_ok);
3980         LDKDecodeError err_var = (*val->contents.err);
3981         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3982         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3983         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3984         return err_ref;
3985 }
3986 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
3987         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
3988 }
3989 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
3990         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3991         CHECK(val->result_ok);
3992         LDKChannelReestablish res_var = (*val->contents.result);
3993         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3994         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3995         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3996         return res_ref;
3997 }
3998 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
3999         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4000         CHECK(!val->result_ok);
4001         LDKDecodeError err_var = (*val->contents.err);
4002         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4003         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4004         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4005         return err_ref;
4006 }
4007 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4008         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
4009 }
4010 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4011         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4012         CHECK(val->result_ok);
4013         LDKClosingSigned res_var = (*val->contents.result);
4014         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4015         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4016         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4017         return res_ref;
4018 }
4019 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
4020         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4021         CHECK(!val->result_ok);
4022         LDKDecodeError err_var = (*val->contents.err);
4023         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4024         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4025         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4026         return err_ref;
4027 }
4028 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
4029         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
4030 }
4031 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
4032         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4033         CHECK(val->result_ok);
4034         LDKCommitmentSigned res_var = (*val->contents.result);
4035         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4036         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4037         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4038         return res_ref;
4039 }
4040 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
4041         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4042         CHECK(!val->result_ok);
4043         LDKDecodeError err_var = (*val->contents.err);
4044         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4045         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4046         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4047         return err_ref;
4048 }
4049 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
4050         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
4051 }
4052 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
4053         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4054         CHECK(val->result_ok);
4055         LDKFundingCreated res_var = (*val->contents.result);
4056         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4057         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4058         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4059         return res_ref;
4060 }
4061 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
4062         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4063         CHECK(!val->result_ok);
4064         LDKDecodeError err_var = (*val->contents.err);
4065         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4066         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4067         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4068         return err_ref;
4069 }
4070 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4071         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
4072 }
4073 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4074         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4075         CHECK(val->result_ok);
4076         LDKFundingSigned res_var = (*val->contents.result);
4077         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4078         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4079         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4080         return res_ref;
4081 }
4082 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
4083         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4084         CHECK(!val->result_ok);
4085         LDKDecodeError err_var = (*val->contents.err);
4086         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4087         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4088         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4089         return err_ref;
4090 }
4091 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
4092         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
4093 }
4094 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
4095         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4096         CHECK(val->result_ok);
4097         LDKFundingLocked res_var = (*val->contents.result);
4098         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4099         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4100         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4101         return res_ref;
4102 }
4103 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
4104         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4105         CHECK(!val->result_ok);
4106         LDKDecodeError err_var = (*val->contents.err);
4107         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4108         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4109         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4110         return err_ref;
4111 }
4112 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
4113         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
4114 }
4115 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
4116         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4117         CHECK(val->result_ok);
4118         LDKInit res_var = (*val->contents.result);
4119         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4120         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4121         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4122         return res_ref;
4123 }
4124 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
4125         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4126         CHECK(!val->result_ok);
4127         LDKDecodeError err_var = (*val->contents.err);
4128         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4129         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4130         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4131         return err_ref;
4132 }
4133 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
4134         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
4135 }
4136 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
4137         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4138         CHECK(val->result_ok);
4139         LDKOpenChannel res_var = (*val->contents.result);
4140         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4141         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4142         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4143         return res_ref;
4144 }
4145 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
4146         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4147         CHECK(!val->result_ok);
4148         LDKDecodeError err_var = (*val->contents.err);
4149         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4150         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4151         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4152         return err_ref;
4153 }
4154 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
4155         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
4156 }
4157 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
4158         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4159         CHECK(val->result_ok);
4160         LDKRevokeAndACK res_var = (*val->contents.result);
4161         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4162         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4163         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4164         return res_ref;
4165 }
4166 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
4167         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4168         CHECK(!val->result_ok);
4169         LDKDecodeError err_var = (*val->contents.err);
4170         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4171         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4172         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4173         return err_ref;
4174 }
4175 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
4176         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
4177 }
4178 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
4179         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4180         CHECK(val->result_ok);
4181         LDKShutdown res_var = (*val->contents.result);
4182         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4183         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4184         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4185         return res_ref;
4186 }
4187 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
4188         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4189         CHECK(!val->result_ok);
4190         LDKDecodeError err_var = (*val->contents.err);
4191         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4192         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4193         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4194         return err_ref;
4195 }
4196 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4197         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
4198 }
4199 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4200         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4201         CHECK(val->result_ok);
4202         LDKUpdateFailHTLC res_var = (*val->contents.result);
4203         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4204         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4205         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4206         return res_ref;
4207 }
4208 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
4209         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4210         CHECK(!val->result_ok);
4211         LDKDecodeError err_var = (*val->contents.err);
4212         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4213         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4214         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4215         return err_ref;
4216 }
4217 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4218         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
4219 }
4220 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4221         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4222         CHECK(val->result_ok);
4223         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
4224         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4225         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4226         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4227         return res_ref;
4228 }
4229 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
4230         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4231         CHECK(!val->result_ok);
4232         LDKDecodeError err_var = (*val->contents.err);
4233         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4234         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4235         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4236         return err_ref;
4237 }
4238 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
4239         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
4240 }
4241 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
4242         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4243         CHECK(val->result_ok);
4244         LDKUpdateFee res_var = (*val->contents.result);
4245         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4246         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4247         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4248         return res_ref;
4249 }
4250 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
4251         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4252         CHECK(!val->result_ok);
4253         LDKDecodeError err_var = (*val->contents.err);
4254         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4255         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4256         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4257         return err_ref;
4258 }
4259 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4260         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
4261 }
4262 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4263         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4264         CHECK(val->result_ok);
4265         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
4266         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4267         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4268         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4269         return res_ref;
4270 }
4271 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
4272         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4273         CHECK(!val->result_ok);
4274         LDKDecodeError err_var = (*val->contents.err);
4275         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4276         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4277         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4278         return err_ref;
4279 }
4280 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4281         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
4282 }
4283 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4284         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4285         CHECK(val->result_ok);
4286         LDKUpdateAddHTLC res_var = (*val->contents.result);
4287         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4288         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4289         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4290         return res_ref;
4291 }
4292 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
4293         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4294         CHECK(!val->result_ok);
4295         LDKDecodeError err_var = (*val->contents.err);
4296         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4297         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4298         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4299         return err_ref;
4300 }
4301 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
4302         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
4303 }
4304 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
4305         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4306         CHECK(val->result_ok);
4307         LDKPing res_var = (*val->contents.result);
4308         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4309         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4310         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4311         return res_ref;
4312 }
4313 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
4314         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4315         CHECK(!val->result_ok);
4316         LDKDecodeError err_var = (*val->contents.err);
4317         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4318         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4319         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4320         return err_ref;
4321 }
4322 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
4323         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
4324 }
4325 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
4326         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4327         CHECK(val->result_ok);
4328         LDKPong res_var = (*val->contents.result);
4329         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4330         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4331         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4332         return res_ref;
4333 }
4334 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
4335         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4336         CHECK(!val->result_ok);
4337         LDKDecodeError err_var = (*val->contents.err);
4338         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4339         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4340         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4341         return err_ref;
4342 }
4343 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4344         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4345 }
4346 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4347         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4348         CHECK(val->result_ok);
4349         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
4350         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4351         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4352         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4353         return res_ref;
4354 }
4355 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4356         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4357         CHECK(!val->result_ok);
4358         LDKDecodeError err_var = (*val->contents.err);
4359         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4360         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4361         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4362         return err_ref;
4363 }
4364 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4365         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4366 }
4367 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4368         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4369         CHECK(val->result_ok);
4370         LDKChannelAnnouncement res_var = (*val->contents.result);
4371         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4372         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4373         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4374         return res_ref;
4375 }
4376 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4377         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4378         CHECK(!val->result_ok);
4379         LDKDecodeError err_var = (*val->contents.err);
4380         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4381         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4382         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4383         return err_ref;
4384 }
4385 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
4386         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
4387 }
4388 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
4389         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4390         CHECK(val->result_ok);
4391         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
4392         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4393         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4394         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4395         return res_ref;
4396 }
4397 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
4398         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4399         CHECK(!val->result_ok);
4400         LDKDecodeError err_var = (*val->contents.err);
4401         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4402         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4403         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4404         return err_ref;
4405 }
4406 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
4407         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
4408 }
4409 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
4410         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4411         CHECK(val->result_ok);
4412         LDKChannelUpdate res_var = (*val->contents.result);
4413         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4414         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4415         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4416         return res_ref;
4417 }
4418 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
4419         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4420         CHECK(!val->result_ok);
4421         LDKDecodeError err_var = (*val->contents.err);
4422         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4423         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4424         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4425         return err_ref;
4426 }
4427 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
4428         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
4429 }
4430 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
4431         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4432         CHECK(val->result_ok);
4433         LDKErrorMessage res_var = (*val->contents.result);
4434         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4435         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4436         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4437         return res_ref;
4438 }
4439 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
4440         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4441         CHECK(!val->result_ok);
4442         LDKDecodeError err_var = (*val->contents.err);
4443         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4444         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4445         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4446         return err_ref;
4447 }
4448 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4449         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4450 }
4451 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4452         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4453         CHECK(val->result_ok);
4454         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
4455         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4456         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4457         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4458         return res_ref;
4459 }
4460 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4461         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4462         CHECK(!val->result_ok);
4463         LDKDecodeError err_var = (*val->contents.err);
4464         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4465         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4466         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4467         return err_ref;
4468 }
4469 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4470         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4471 }
4472 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4473         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4474         CHECK(val->result_ok);
4475         LDKNodeAnnouncement res_var = (*val->contents.result);
4476         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4477         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4478         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4479         return res_ref;
4480 }
4481 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4482         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4483         CHECK(!val->result_ok);
4484         LDKDecodeError err_var = (*val->contents.err);
4485         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4486         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4487         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4488         return err_ref;
4489 }
4490 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
4491         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
4492 }
4493 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
4494         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4495         CHECK(val->result_ok);
4496         LDKQueryShortChannelIds res_var = (*val->contents.result);
4497         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4498         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4499         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4500         return res_ref;
4501 }
4502 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
4503         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4504         CHECK(!val->result_ok);
4505         LDKDecodeError err_var = (*val->contents.err);
4506         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4507         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4508         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4509         return err_ref;
4510 }
4511 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
4512         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
4513 }
4514 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
4515         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4516         CHECK(val->result_ok);
4517         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
4518         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4519         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4520         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4521         return res_ref;
4522 }
4523 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
4524         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4525         CHECK(!val->result_ok);
4526         LDKDecodeError err_var = (*val->contents.err);
4527         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4528         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4529         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4530         return err_ref;
4531 }
4532 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
4533         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
4534 }
4535 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
4536         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4537         CHECK(val->result_ok);
4538         LDKQueryChannelRange res_var = (*val->contents.result);
4539         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4540         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4541         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4542         return res_ref;
4543 }
4544 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
4545         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4546         CHECK(!val->result_ok);
4547         LDKDecodeError err_var = (*val->contents.err);
4548         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4549         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4550         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4551         return err_ref;
4552 }
4553 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
4554         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
4555 }
4556 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
4557         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4558         CHECK(val->result_ok);
4559         LDKReplyChannelRange res_var = (*val->contents.result);
4560         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4561         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4562         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4563         return res_ref;
4564 }
4565 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
4566         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4567         CHECK(!val->result_ok);
4568         LDKDecodeError err_var = (*val->contents.err);
4569         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4570         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4571         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4572         return err_ref;
4573 }
4574 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
4575         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
4576 }
4577 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
4578         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4579         CHECK(val->result_ok);
4580         LDKGossipTimestampFilter res_var = (*val->contents.result);
4581         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4582         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4583         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4584         return res_ref;
4585 }
4586 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
4587         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4588         CHECK(!val->result_ok);
4589         LDKDecodeError err_var = (*val->contents.err);
4590         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4591         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4592         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4593         return err_ref;
4594 }
4595 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
4596         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
4597         switch(obj->tag) {
4598                 case LDKSignOrCreationError_SignError: {
4599                         return 0 /* LDKSignOrCreationError - SignError */;
4600                 }
4601                 case LDKSignOrCreationError_CreationError: {
4602                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
4603                         return 0 /* LDKSignOrCreationError - CreationError */; (void) creation_error_conv;
4604                 }
4605                 default: abort();
4606         }
4607 }
4608 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_result_ok(uint32_t arg) {
4609         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
4610 }
4611 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t arg) {
4612         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
4613         CHECK(val->result_ok);
4614         LDKInvoice res_var = (*val->contents.result);
4615         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4616         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4617         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4618         return res_ref;
4619 }
4620 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
4621         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
4622         CHECK(!val->result_ok);
4623         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4624         return err_ref;
4625 }
4626 typedef struct LDKMessageSendEventsProvider_JCalls {
4627         atomic_size_t refcnt;
4628         uint32_t get_and_clear_pending_msg_events_meth;
4629 } LDKMessageSendEventsProvider_JCalls;
4630 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
4631         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4632         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4633                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
4634                 FREE(j_calls);
4635         }
4636 }
4637 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
4638         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4639         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
4640         LDKCVec_MessageSendEventZ ret_constr;
4641         ret_constr.datalen = *((uint32_t*)ret);
4642         if (ret_constr.datalen > 0)
4643                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4644         else
4645                 ret_constr.data = NULL;
4646         uint32_t* ret_vals = (uint32_t*)(ret + 4);
4647         for (size_t s = 0; s < ret_constr.datalen; s++) {
4648                 uint32_t ret_conv_18 = ret_vals[s];
4649                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
4650                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
4651                 ret_constr.data[s] = ret_conv_18_conv;
4652         }
4653         return ret_constr;
4654 }
4655 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
4656         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4657         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4658         return (void*) this_arg;
4659 }
4660 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
4661         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
4662         atomic_init(&calls->refcnt, 1);
4663         //TODO: Assign calls->o from o
4664
4665         LDKMessageSendEventsProvider ret = {
4666                 .this_arg = (void*) calls,
4667                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
4668                 .free = LDKMessageSendEventsProvider_JCalls_free,
4669         };
4670         return ret;
4671 }
4672 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4673         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
4674         *res_ptr = LDKMessageSendEventsProvider_init(o);
4675         return (long)res_ptr;
4676 }
4677 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
4678         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
4679         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
4680         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4681         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4682         for (size_t s = 0; s < ret_var.datalen; s++) {
4683                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
4684                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
4685                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
4686                 ret_arr_ptr[s] = ret_conv_18_ref;
4687         }
4688         FREE(ret_var.data);
4689         return ret_arr;
4690 }
4691
4692 typedef struct LDKEventHandler_JCalls {
4693         atomic_size_t refcnt;
4694         uint32_t handle_event_meth;
4695 } LDKEventHandler_JCalls;
4696 static void LDKEventHandler_JCalls_free(void* this_arg) {
4697         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4698         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4699                 js_free(j_calls->handle_event_meth);
4700                 FREE(j_calls);
4701         }
4702 }
4703 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
4704         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4705         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
4706         *event_copy = event;
4707         uint64_t event_ref = (uint64_t)event_copy;
4708         js_invoke_function_1(j_calls->handle_event_meth, event_ref);
4709 }
4710 static void* LDKEventHandler_JCalls_clone(const void* this_arg) {
4711         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4712         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4713         return (void*) this_arg;
4714 }
4715 static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) {
4716         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
4717         atomic_init(&calls->refcnt, 1);
4718         //TODO: Assign calls->o from o
4719
4720         LDKEventHandler ret = {
4721                 .this_arg = (void*) calls,
4722                 .handle_event = handle_event_LDKEventHandler_jcall,
4723                 .free = LDKEventHandler_JCalls_free,
4724         };
4725         return ret;
4726 }
4727 long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS Object Reference */void* o) {
4728         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
4729         *res_ptr = LDKEventHandler_init(o);
4730         return (long)res_ptr;
4731 }
4732 void  __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
4733         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
4734         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
4735         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
4736 }
4737
4738 typedef struct LDKEventsProvider_JCalls {
4739         atomic_size_t refcnt;
4740         uint32_t process_pending_events_meth;
4741 } LDKEventsProvider_JCalls;
4742 static void LDKEventsProvider_JCalls_free(void* this_arg) {
4743         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4744         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4745                 js_free(j_calls->process_pending_events_meth);
4746                 FREE(j_calls);
4747         }
4748 }
4749 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
4750         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4751         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
4752         *ret = handler;
4753         js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)ret);
4754 }
4755 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
4756         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4757         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4758         return (void*) this_arg;
4759 }
4760 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
4761         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
4762         atomic_init(&calls->refcnt, 1);
4763         //TODO: Assign calls->o from o
4764
4765         LDKEventsProvider ret = {
4766                 .this_arg = (void*) calls,
4767                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
4768                 .free = LDKEventsProvider_JCalls_free,
4769         };
4770         return ret;
4771 }
4772 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4773         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4774         *res_ptr = LDKEventsProvider_init(o);
4775         return (long)res_ptr;
4776 }
4777 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
4778         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
4779         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
4780         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
4781 }
4782
4783 typedef struct LDKAccess_JCalls {
4784         atomic_size_t refcnt;
4785         uint32_t get_utxo_meth;
4786 } LDKAccess_JCalls;
4787 static void LDKAccess_JCalls_free(void* this_arg) {
4788         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4789         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4790                 js_free(j_calls->get_utxo_meth);
4791                 FREE(j_calls);
4792         }
4793 }
4794 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4795         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4796         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4797         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4798         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4799         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4800         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
4801         return ret_conv;
4802 }
4803 static void* LDKAccess_JCalls_clone(const void* this_arg) {
4804         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4805         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4806         return (void*) this_arg;
4807 }
4808 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4809         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4810         atomic_init(&calls->refcnt, 1);
4811         //TODO: Assign calls->o from o
4812
4813         LDKAccess ret = {
4814                 .this_arg = (void*) calls,
4815                 .get_utxo = get_utxo_LDKAccess_jcall,
4816                 .free = LDKAccess_JCalls_free,
4817         };
4818         return ret;
4819 }
4820 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4821         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4822         *res_ptr = LDKAccess_init(o);
4823         return (long)res_ptr;
4824 }
4825 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4826         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
4827         unsigned char genesis_hash_arr[32];
4828         CHECK(*((uint32_t*)genesis_hash) == 32);
4829         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4830         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4831         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4832         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4833         return (uint64_t)ret_conv;
4834 }
4835
4836 typedef struct LDKListen_JCalls {
4837         atomic_size_t refcnt;
4838         uint32_t block_connected_meth;
4839         uint32_t block_disconnected_meth;
4840 } LDKListen_JCalls;
4841 static void LDKListen_JCalls_free(void* this_arg) {
4842         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4843         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4844                 js_free(j_calls->block_connected_meth);
4845                 js_free(j_calls->block_disconnected_meth);
4846                 FREE(j_calls);
4847         }
4848 }
4849 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
4850         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4851         LDKu8slice block_var = block;
4852         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4853         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
4854         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
4855 }
4856 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4857         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4858         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4859         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4860         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
4861 }
4862 static void* LDKListen_JCalls_clone(const void* this_arg) {
4863         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4864         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4865         return (void*) this_arg;
4866 }
4867 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
4868         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
4869         atomic_init(&calls->refcnt, 1);
4870         //TODO: Assign calls->o from o
4871
4872         LDKListen ret = {
4873                 .this_arg = (void*) calls,
4874                 .block_connected = block_connected_LDKListen_jcall,
4875                 .block_disconnected = block_disconnected_LDKListen_jcall,
4876                 .free = LDKListen_JCalls_free,
4877         };
4878         return ret;
4879 }
4880 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
4881         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
4882         *res_ptr = LDKListen_init(o);
4883         return (long)res_ptr;
4884 }
4885 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
4886         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4887         LDKu8slice block_ref;
4888         block_ref.datalen = *((uint32_t*)block);
4889         block_ref.data = (int8_t*)(block + 4);
4890         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
4891 }
4892
4893 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
4894         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4895         unsigned char header_arr[80];
4896         CHECK(*((uint32_t*)header) == 80);
4897         memcpy(header_arr, (uint8_t*)(header + 4), 80);
4898         unsigned char (*header_ref)[80] = &header_arr;
4899         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
4900 }
4901
4902 typedef struct LDKConfirm_JCalls {
4903         atomic_size_t refcnt;
4904         uint32_t transactions_confirmed_meth;
4905         uint32_t transaction_unconfirmed_meth;
4906         uint32_t best_block_updated_meth;
4907         uint32_t get_relevant_txids_meth;
4908 } LDKConfirm_JCalls;
4909 static void LDKConfirm_JCalls_free(void* this_arg) {
4910         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4911         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4912                 js_free(j_calls->transactions_confirmed_meth);
4913                 js_free(j_calls->transaction_unconfirmed_meth);
4914                 js_free(j_calls->best_block_updated_meth);
4915                 js_free(j_calls->get_relevant_txids_meth);
4916                 FREE(j_calls);
4917         }
4918 }
4919 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
4920         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4921         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4922         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4923         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
4924         uint32_tArray txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4925         uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
4926         for (size_t e = 0; e < txdata_var.datalen; e++) {
4927                 LDKC2Tuple_usizeTransactionZ* txdata_conv_30_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
4928                 *txdata_conv_30_ref = txdata_var.data[e];
4929                 txdata_arr_ptr[e] = (uint64_t)txdata_conv_30_ref;
4930         }
4931         FREE(txdata_var.data);
4932         js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
4933 }
4934 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
4935         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4936         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4937         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
4938         js_invoke_function_1(j_calls->transaction_unconfirmed_meth, txid_arr);
4939 }
4940 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4941         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4942         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4943         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4944         js_invoke_function_2(j_calls->best_block_updated_meth, header_arr, height);
4945 }
4946 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
4947         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4948         ptrArray ret = js_invoke_function_0(j_calls->get_relevant_txids_meth);
4949         LDKCVec_TxidZ ret_constr;
4950         ret_constr.datalen = *((uint32_t*)ret);
4951         if (ret_constr.datalen > 0)
4952                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
4953         else
4954                 ret_constr.data = NULL;
4955         int8_tArray* ret_vals = (int8_tArray*)(ret + 4);
4956         for (size_t m = 0; m < ret_constr.datalen; m++) {
4957                 int8_tArray ret_conv_12 = ret_vals[m];
4958                 LDKThirtyTwoBytes ret_conv_12_ref;
4959                 CHECK(*((uint32_t*)ret_conv_12) == 32);
4960                 memcpy(ret_conv_12_ref.data, (uint8_t*)(ret_conv_12 + 4), 32);
4961                 ret_constr.data[m] = ret_conv_12_ref;
4962         }
4963         return ret_constr;
4964 }
4965 static void* LDKConfirm_JCalls_clone(const void* this_arg) {
4966         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4967         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4968         return (void*) this_arg;
4969 }
4970 static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) {
4971         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
4972         atomic_init(&calls->refcnt, 1);
4973         //TODO: Assign calls->o from o
4974
4975         LDKConfirm ret = {
4976                 .this_arg = (void*) calls,
4977                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
4978                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
4979                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
4980                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
4981                 .free = LDKConfirm_JCalls_free,
4982         };
4983         return ret;
4984 }
4985 long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object Reference */void* o) {
4986         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
4987         *res_ptr = LDKConfirm_init(o);
4988         return (long)res_ptr;
4989 }
4990 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
4991         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
4992         unsigned char header_arr[80];
4993         CHECK(*((uint32_t*)header) == 80);
4994         memcpy(header_arr, (uint8_t*)(header + 4), 80);
4995         unsigned char (*header_ref)[80] = &header_arr;
4996         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
4997         txdata_constr.datalen = *((uint32_t*)txdata);
4998         if (txdata_constr.datalen > 0)
4999                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5000         else
5001                 txdata_constr.data = NULL;
5002         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
5003         for (size_t e = 0; e < txdata_constr.datalen; e++) {
5004                 uint32_t txdata_conv_30 = txdata_vals[e];
5005                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
5006                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
5007                 txdata_constr.data[e] = txdata_conv_30_conv;
5008         }
5009         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
5010 }
5011
5012 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
5013         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5014         unsigned char txid_arr[32];
5015         CHECK(*((uint32_t*)txid) == 32);
5016         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5017         unsigned char (*txid_ref)[32] = &txid_arr;
5018         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
5019 }
5020
5021 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
5022         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5023         unsigned char header_arr[80];
5024         CHECK(*((uint32_t*)header) == 80);
5025         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5026         unsigned char (*header_ref)[80] = &header_arr;
5027         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
5028 }
5029
5030 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
5031         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5032         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
5033         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
5034         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
5035         for (size_t m = 0; m < ret_var.datalen; m++) {
5036                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5037                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
5038                 ret_arr_ptr[m] = ret_conv_12_arr;
5039         }
5040         FREE(ret_var.data);
5041         return ret_arr;
5042 }
5043
5044 typedef struct LDKFilter_JCalls {
5045         atomic_size_t refcnt;
5046         uint32_t register_tx_meth;
5047         uint32_t register_output_meth;
5048 } LDKFilter_JCalls;
5049 static void LDKFilter_JCalls_free(void* this_arg) {
5050         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5051         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5052                 js_free(j_calls->register_tx_meth);
5053                 js_free(j_calls->register_output_meth);
5054                 FREE(j_calls);
5055         }
5056 }
5057 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5058         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5059         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5060         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5061         LDKu8slice script_pubkey_var = script_pubkey;
5062         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5063         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
5064         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5065 }
5066 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5067         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5068         LDKWatchedOutput output_var = output;
5069         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5070         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5071         uint64_t output_ref = (uint64_t)output_var.inner;
5072         if (output_var.is_owned) {
5073                 output_ref |= 1;
5074         }
5075         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)js_invoke_function_1(j_calls->register_output_meth, output_ref);
5076         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
5077         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
5078         return ret_conv;
5079 }
5080 static void* LDKFilter_JCalls_clone(const void* this_arg) {
5081         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5082         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5083         return (void*) this_arg;
5084 }
5085 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
5086         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5087         atomic_init(&calls->refcnt, 1);
5088         //TODO: Assign calls->o from o
5089
5090         LDKFilter ret = {
5091                 .this_arg = (void*) calls,
5092                 .register_tx = register_tx_LDKFilter_jcall,
5093                 .register_output = register_output_LDKFilter_jcall,
5094                 .free = LDKFilter_JCalls_free,
5095         };
5096         return ret;
5097 }
5098 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
5099         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5100         *res_ptr = LDKFilter_init(o);
5101         return (long)res_ptr;
5102 }
5103 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5104         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5105         unsigned char txid_arr[32];
5106         CHECK(*((uint32_t*)txid) == 32);
5107         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5108         unsigned char (*txid_ref)[32] = &txid_arr;
5109         LDKu8slice script_pubkey_ref;
5110         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
5111         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
5112         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5113 }
5114
5115 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5116         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5117         LDKWatchedOutput output_conv;
5118         output_conv.inner = (void*)(output & (~1));
5119         output_conv.is_owned = (output & 1) || (output == 0);
5120         output_conv = WatchedOutput_clone(&output_conv);
5121         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5122         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5123         uint64_t ret_ref = (uint64_t)ret_copy;
5124         return ret_ref;
5125 }
5126
5127 typedef struct LDKPersist_JCalls {
5128         atomic_size_t refcnt;
5129         uint32_t persist_new_channel_meth;
5130         uint32_t update_persisted_channel_meth;
5131 } LDKPersist_JCalls;
5132 static void LDKPersist_JCalls_free(void* this_arg) {
5133         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5134         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5135                 js_free(j_calls->persist_new_channel_meth);
5136                 js_free(j_calls->update_persisted_channel_meth);
5137                 FREE(j_calls);
5138         }
5139 }
5140 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
5141         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5142         LDKOutPoint id_var = id;
5143         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5144         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5145         uint64_t id_ref = (uint64_t)id_var.inner;
5146         if (id_var.is_owned) {
5147                 id_ref |= 1;
5148         }
5149         LDKChannelMonitor data_var = *data;
5150         data_var = ChannelMonitor_clone(data);
5151         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5152         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5153         uint64_t data_ref = (uint64_t)data_var.inner;
5154         if (data_var.is_owned) {
5155                 data_ref |= 1;
5156         }
5157         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
5158         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5159         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5160         return ret_conv;
5161 }
5162 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
5163         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5164         LDKOutPoint id_var = id;
5165         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5166         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5167         uint64_t id_ref = (uint64_t)id_var.inner;
5168         if (id_var.is_owned) {
5169                 id_ref |= 1;
5170         }
5171         LDKChannelMonitorUpdate update_var = *update;
5172         update_var = ChannelMonitorUpdate_clone(update);
5173         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5174         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5175         uint64_t update_ref = (uint64_t)update_var.inner;
5176         if (update_var.is_owned) {
5177                 update_ref |= 1;
5178         }
5179         LDKChannelMonitor data_var = *data;
5180         data_var = ChannelMonitor_clone(data);
5181         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5182         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5183         uint64_t data_ref = (uint64_t)data_var.inner;
5184         if (data_var.is_owned) {
5185                 data_ref |= 1;
5186         }
5187         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
5188         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5189         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5190         return ret_conv;
5191 }
5192 static void* LDKPersist_JCalls_clone(const void* this_arg) {
5193         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5194         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5195         return (void*) this_arg;
5196 }
5197 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
5198         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5199         atomic_init(&calls->refcnt, 1);
5200         //TODO: Assign calls->o from o
5201
5202         LDKPersist ret = {
5203                 .this_arg = (void*) calls,
5204                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
5205                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
5206                 .free = LDKPersist_JCalls_free,
5207         };
5208         return ret;
5209 }
5210 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
5211         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5212         *res_ptr = LDKPersist_init(o);
5213         return (long)res_ptr;
5214 }
5215 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
5216         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5217         LDKOutPoint id_conv;
5218         id_conv.inner = (void*)(id & (~1));
5219         id_conv.is_owned = (id & 1) || (id == 0);
5220         id_conv = OutPoint_clone(&id_conv);
5221         LDKChannelMonitor data_conv;
5222         data_conv.inner = (void*)(data & (~1));
5223         data_conv.is_owned = false;
5224         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5225         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
5226         return (uint64_t)ret_conv;
5227 }
5228
5229 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
5230         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5231         LDKOutPoint id_conv;
5232         id_conv.inner = (void*)(id & (~1));
5233         id_conv.is_owned = (id & 1) || (id == 0);
5234         id_conv = OutPoint_clone(&id_conv);
5235         LDKChannelMonitorUpdate update_conv;
5236         update_conv.inner = (void*)(update & (~1));
5237         update_conv.is_owned = false;
5238         LDKChannelMonitor data_conv;
5239         data_conv.inner = (void*)(data & (~1));
5240         data_conv.is_owned = false;
5241         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5242         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
5243         return (uint64_t)ret_conv;
5244 }
5245
5246 typedef struct LDKChannelMessageHandler_JCalls {
5247         atomic_size_t refcnt;
5248         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5249         uint32_t handle_open_channel_meth;
5250         uint32_t handle_accept_channel_meth;
5251         uint32_t handle_funding_created_meth;
5252         uint32_t handle_funding_signed_meth;
5253         uint32_t handle_funding_locked_meth;
5254         uint32_t handle_shutdown_meth;
5255         uint32_t handle_closing_signed_meth;
5256         uint32_t handle_update_add_htlc_meth;
5257         uint32_t handle_update_fulfill_htlc_meth;
5258         uint32_t handle_update_fail_htlc_meth;
5259         uint32_t handle_update_fail_malformed_htlc_meth;
5260         uint32_t handle_commitment_signed_meth;
5261         uint32_t handle_revoke_and_ack_meth;
5262         uint32_t handle_update_fee_meth;
5263         uint32_t handle_announcement_signatures_meth;
5264         uint32_t peer_disconnected_meth;
5265         uint32_t peer_connected_meth;
5266         uint32_t handle_channel_reestablish_meth;
5267         uint32_t handle_channel_update_meth;
5268         uint32_t handle_error_meth;
5269 } LDKChannelMessageHandler_JCalls;
5270 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5271         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5272         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5273                 js_free(j_calls->handle_open_channel_meth);
5274                 js_free(j_calls->handle_accept_channel_meth);
5275                 js_free(j_calls->handle_funding_created_meth);
5276                 js_free(j_calls->handle_funding_signed_meth);
5277                 js_free(j_calls->handle_funding_locked_meth);
5278                 js_free(j_calls->handle_shutdown_meth);
5279                 js_free(j_calls->handle_closing_signed_meth);
5280                 js_free(j_calls->handle_update_add_htlc_meth);
5281                 js_free(j_calls->handle_update_fulfill_htlc_meth);
5282                 js_free(j_calls->handle_update_fail_htlc_meth);
5283                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
5284                 js_free(j_calls->handle_commitment_signed_meth);
5285                 js_free(j_calls->handle_revoke_and_ack_meth);
5286                 js_free(j_calls->handle_update_fee_meth);
5287                 js_free(j_calls->handle_announcement_signatures_meth);
5288                 js_free(j_calls->peer_disconnected_meth);
5289                 js_free(j_calls->peer_connected_meth);
5290                 js_free(j_calls->handle_channel_reestablish_meth);
5291                 js_free(j_calls->handle_channel_update_meth);
5292                 js_free(j_calls->handle_error_meth);
5293                 FREE(j_calls);
5294         }
5295 }
5296 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5297         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5298         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5299         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5300         LDKInitFeatures their_features_var = their_features;
5301         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5302         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5303         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5304         if (their_features_var.is_owned) {
5305                 their_features_ref |= 1;
5306         }
5307         LDKOpenChannel msg_var = *msg;
5308         msg_var = OpenChannel_clone(msg);
5309         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5310         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5311         uint64_t msg_ref = (uint64_t)msg_var.inner;
5312         if (msg_var.is_owned) {
5313                 msg_ref |= 1;
5314         }
5315         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5316 }
5317 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
5318         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5319         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5320         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5321         LDKInitFeatures their_features_var = their_features;
5322         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5323         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5324         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5325         if (their_features_var.is_owned) {
5326                 their_features_ref |= 1;
5327         }
5328         LDKAcceptChannel msg_var = *msg;
5329         msg_var = AcceptChannel_clone(msg);
5330         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5331         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5332         uint64_t msg_ref = (uint64_t)msg_var.inner;
5333         if (msg_var.is_owned) {
5334                 msg_ref |= 1;
5335         }
5336         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5337 }
5338 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
5339         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5340         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5341         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5342         LDKFundingCreated msg_var = *msg;
5343         msg_var = FundingCreated_clone(msg);
5344         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5345         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5346         uint64_t msg_ref = (uint64_t)msg_var.inner;
5347         if (msg_var.is_owned) {
5348                 msg_ref |= 1;
5349         }
5350         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
5351 }
5352 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
5353         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5354         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5355         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5356         LDKFundingSigned msg_var = *msg;
5357         msg_var = FundingSigned_clone(msg);
5358         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5359         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5360         uint64_t msg_ref = (uint64_t)msg_var.inner;
5361         if (msg_var.is_owned) {
5362                 msg_ref |= 1;
5363         }
5364         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
5365 }
5366 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
5367         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5368         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5369         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5370         LDKFundingLocked msg_var = *msg;
5371         msg_var = FundingLocked_clone(msg);
5372         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5373         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5374         uint64_t msg_ref = (uint64_t)msg_var.inner;
5375         if (msg_var.is_owned) {
5376                 msg_ref |= 1;
5377         }
5378         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
5379 }
5380 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
5381         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5382         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5383         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5384         LDKInitFeatures their_features_var = *their_features;
5385         their_features_var = InitFeatures_clone(their_features);
5386         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5387         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5388         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5389         if (their_features_var.is_owned) {
5390                 their_features_ref |= 1;
5391         }
5392         LDKShutdown msg_var = *msg;
5393         msg_var = Shutdown_clone(msg);
5394         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5395         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5396         uint64_t msg_ref = (uint64_t)msg_var.inner;
5397         if (msg_var.is_owned) {
5398                 msg_ref |= 1;
5399         }
5400         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
5401 }
5402 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
5403         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5404         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5405         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5406         LDKClosingSigned msg_var = *msg;
5407         msg_var = ClosingSigned_clone(msg);
5408         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5409         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5410         uint64_t msg_ref = (uint64_t)msg_var.inner;
5411         if (msg_var.is_owned) {
5412                 msg_ref |= 1;
5413         }
5414         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
5415 }
5416 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
5417         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5418         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5419         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5420         LDKUpdateAddHTLC msg_var = *msg;
5421         msg_var = UpdateAddHTLC_clone(msg);
5422         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5423         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5424         uint64_t msg_ref = (uint64_t)msg_var.inner;
5425         if (msg_var.is_owned) {
5426                 msg_ref |= 1;
5427         }
5428         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
5429 }
5430 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
5431         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5432         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5433         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5434         LDKUpdateFulfillHTLC msg_var = *msg;
5435         msg_var = UpdateFulfillHTLC_clone(msg);
5436         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5437         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5438         uint64_t msg_ref = (uint64_t)msg_var.inner;
5439         if (msg_var.is_owned) {
5440                 msg_ref |= 1;
5441         }
5442         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
5443 }
5444 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
5445         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5446         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5447         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5448         LDKUpdateFailHTLC msg_var = *msg;
5449         msg_var = UpdateFailHTLC_clone(msg);
5450         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5451         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5452         uint64_t msg_ref = (uint64_t)msg_var.inner;
5453         if (msg_var.is_owned) {
5454                 msg_ref |= 1;
5455         }
5456         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
5457 }
5458 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
5459         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5460         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5461         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5462         LDKUpdateFailMalformedHTLC msg_var = *msg;
5463         msg_var = UpdateFailMalformedHTLC_clone(msg);
5464         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5465         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5466         uint64_t msg_ref = (uint64_t)msg_var.inner;
5467         if (msg_var.is_owned) {
5468                 msg_ref |= 1;
5469         }
5470         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
5471 }
5472 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
5473         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5474         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5475         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5476         LDKCommitmentSigned msg_var = *msg;
5477         msg_var = CommitmentSigned_clone(msg);
5478         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5479         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5480         uint64_t msg_ref = (uint64_t)msg_var.inner;
5481         if (msg_var.is_owned) {
5482                 msg_ref |= 1;
5483         }
5484         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
5485 }
5486 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
5487         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5488         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5489         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5490         LDKRevokeAndACK msg_var = *msg;
5491         msg_var = RevokeAndACK_clone(msg);
5492         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5493         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5494         uint64_t msg_ref = (uint64_t)msg_var.inner;
5495         if (msg_var.is_owned) {
5496                 msg_ref |= 1;
5497         }
5498         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
5499 }
5500 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
5501         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5502         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5503         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5504         LDKUpdateFee msg_var = *msg;
5505         msg_var = UpdateFee_clone(msg);
5506         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5507         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5508         uint64_t msg_ref = (uint64_t)msg_var.inner;
5509         if (msg_var.is_owned) {
5510                 msg_ref |= 1;
5511         }
5512         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
5513 }
5514 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
5515         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5516         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5517         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5518         LDKAnnouncementSignatures msg_var = *msg;
5519         msg_var = AnnouncementSignatures_clone(msg);
5520         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5521         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5522         uint64_t msg_ref = (uint64_t)msg_var.inner;
5523         if (msg_var.is_owned) {
5524                 msg_ref |= 1;
5525         }
5526         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
5527 }
5528 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
5529         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5530         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5531         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5532         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
5533 }
5534 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
5535         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5536         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5537         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5538         LDKInit msg_var = *msg;
5539         msg_var = Init_clone(msg);
5540         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5541         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5542         uint64_t msg_ref = (uint64_t)msg_var.inner;
5543         if (msg_var.is_owned) {
5544                 msg_ref |= 1;
5545         }
5546         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
5547 }
5548 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
5549         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5550         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5551         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5552         LDKChannelReestablish msg_var = *msg;
5553         msg_var = ChannelReestablish_clone(msg);
5554         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5555         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5556         uint64_t msg_ref = (uint64_t)msg_var.inner;
5557         if (msg_var.is_owned) {
5558                 msg_ref |= 1;
5559         }
5560         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
5561 }
5562 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
5563         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5564         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5565         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5566         LDKChannelUpdate msg_var = *msg;
5567         msg_var = ChannelUpdate_clone(msg);
5568         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5569         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5570         uint64_t msg_ref = (uint64_t)msg_var.inner;
5571         if (msg_var.is_owned) {
5572                 msg_ref |= 1;
5573         }
5574         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
5575 }
5576 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
5577         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5578         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5579         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5580         LDKErrorMessage msg_var = *msg;
5581         msg_var = ErrorMessage_clone(msg);
5582         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5583         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5584         uint64_t msg_ref = (uint64_t)msg_var.inner;
5585         if (msg_var.is_owned) {
5586                 msg_ref |= 1;
5587         }
5588         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
5589 }
5590 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
5591         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5592         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5593         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5594         return (void*) this_arg;
5595 }
5596 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
5597         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
5598         atomic_init(&calls->refcnt, 1);
5599         //TODO: Assign calls->o from o
5600
5601         LDKChannelMessageHandler ret = {
5602                 .this_arg = (void*) calls,
5603                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
5604                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
5605                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
5606                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
5607                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
5608                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
5609                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
5610                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
5611                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
5612                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
5613                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
5614                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
5615                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
5616                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
5617                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
5618                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
5619                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
5620                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
5621                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
5622                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
5623                 .free = LDKChannelMessageHandler_JCalls_free,
5624                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
5625         };
5626         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5627         return ret;
5628 }
5629 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
5630         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5631         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
5632         return (long)res_ptr;
5633 }
5634 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) {
5635         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5636         LDKPublicKey their_node_id_ref;
5637         CHECK(*((uint32_t*)their_node_id) == 33);
5638         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5639         LDKInitFeatures their_features_conv;
5640         their_features_conv.inner = (void*)(their_features & (~1));
5641         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5642         their_features_conv = InitFeatures_clone(&their_features_conv);
5643         LDKOpenChannel msg_conv;
5644         msg_conv.inner = (void*)(msg & (~1));
5645         msg_conv.is_owned = false;
5646         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5647 }
5648
5649 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) {
5650         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5651         LDKPublicKey their_node_id_ref;
5652         CHECK(*((uint32_t*)their_node_id) == 33);
5653         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5654         LDKInitFeatures their_features_conv;
5655         their_features_conv.inner = (void*)(their_features & (~1));
5656         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5657         their_features_conv = InitFeatures_clone(&their_features_conv);
5658         LDKAcceptChannel msg_conv;
5659         msg_conv.inner = (void*)(msg & (~1));
5660         msg_conv.is_owned = false;
5661         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5662 }
5663
5664 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5665         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5666         LDKPublicKey their_node_id_ref;
5667         CHECK(*((uint32_t*)their_node_id) == 33);
5668         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5669         LDKFundingCreated msg_conv;
5670         msg_conv.inner = (void*)(msg & (~1));
5671         msg_conv.is_owned = false;
5672         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5673 }
5674
5675 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5676         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5677         LDKPublicKey their_node_id_ref;
5678         CHECK(*((uint32_t*)their_node_id) == 33);
5679         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5680         LDKFundingSigned msg_conv;
5681         msg_conv.inner = (void*)(msg & (~1));
5682         msg_conv.is_owned = false;
5683         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5684 }
5685
5686 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5687         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5688         LDKPublicKey their_node_id_ref;
5689         CHECK(*((uint32_t*)their_node_id) == 33);
5690         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5691         LDKFundingLocked msg_conv;
5692         msg_conv.inner = (void*)(msg & (~1));
5693         msg_conv.is_owned = false;
5694         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5695 }
5696
5697 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
5698         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5699         LDKPublicKey their_node_id_ref;
5700         CHECK(*((uint32_t*)their_node_id) == 33);
5701         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5702         LDKInitFeatures their_features_conv;
5703         their_features_conv.inner = (void*)(their_features & (~1));
5704         their_features_conv.is_owned = false;
5705         LDKShutdown msg_conv;
5706         msg_conv.inner = (void*)(msg & (~1));
5707         msg_conv.is_owned = false;
5708         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
5709 }
5710
5711 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5712         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5713         LDKPublicKey their_node_id_ref;
5714         CHECK(*((uint32_t*)their_node_id) == 33);
5715         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5716         LDKClosingSigned msg_conv;
5717         msg_conv.inner = (void*)(msg & (~1));
5718         msg_conv.is_owned = false;
5719         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5720 }
5721
5722 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5723         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5724         LDKPublicKey their_node_id_ref;
5725         CHECK(*((uint32_t*)their_node_id) == 33);
5726         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5727         LDKUpdateAddHTLC msg_conv;
5728         msg_conv.inner = (void*)(msg & (~1));
5729         msg_conv.is_owned = false;
5730         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5731 }
5732
5733 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5734         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5735         LDKPublicKey their_node_id_ref;
5736         CHECK(*((uint32_t*)their_node_id) == 33);
5737         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5738         LDKUpdateFulfillHTLC msg_conv;
5739         msg_conv.inner = (void*)(msg & (~1));
5740         msg_conv.is_owned = false;
5741         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5742 }
5743
5744 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5745         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5746         LDKPublicKey their_node_id_ref;
5747         CHECK(*((uint32_t*)their_node_id) == 33);
5748         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5749         LDKUpdateFailHTLC msg_conv;
5750         msg_conv.inner = (void*)(msg & (~1));
5751         msg_conv.is_owned = false;
5752         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5753 }
5754
5755 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5756         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5757         LDKPublicKey their_node_id_ref;
5758         CHECK(*((uint32_t*)their_node_id) == 33);
5759         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5760         LDKUpdateFailMalformedHTLC msg_conv;
5761         msg_conv.inner = (void*)(msg & (~1));
5762         msg_conv.is_owned = false;
5763         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5764 }
5765
5766 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5767         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5768         LDKPublicKey their_node_id_ref;
5769         CHECK(*((uint32_t*)their_node_id) == 33);
5770         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5771         LDKCommitmentSigned msg_conv;
5772         msg_conv.inner = (void*)(msg & (~1));
5773         msg_conv.is_owned = false;
5774         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5775 }
5776
5777 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5778         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5779         LDKPublicKey their_node_id_ref;
5780         CHECK(*((uint32_t*)their_node_id) == 33);
5781         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5782         LDKRevokeAndACK msg_conv;
5783         msg_conv.inner = (void*)(msg & (~1));
5784         msg_conv.is_owned = false;
5785         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5786 }
5787
5788 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5789         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5790         LDKPublicKey their_node_id_ref;
5791         CHECK(*((uint32_t*)their_node_id) == 33);
5792         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5793         LDKUpdateFee msg_conv;
5794         msg_conv.inner = (void*)(msg & (~1));
5795         msg_conv.is_owned = false;
5796         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5797 }
5798
5799 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5800         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5801         LDKPublicKey their_node_id_ref;
5802         CHECK(*((uint32_t*)their_node_id) == 33);
5803         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5804         LDKAnnouncementSignatures msg_conv;
5805         msg_conv.inner = (void*)(msg & (~1));
5806         msg_conv.is_owned = false;
5807         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5808 }
5809
5810 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
5811         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5812         LDKPublicKey their_node_id_ref;
5813         CHECK(*((uint32_t*)their_node_id) == 33);
5814         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5815         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
5816 }
5817
5818 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5819         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5820         LDKPublicKey their_node_id_ref;
5821         CHECK(*((uint32_t*)their_node_id) == 33);
5822         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5823         LDKInit msg_conv;
5824         msg_conv.inner = (void*)(msg & (~1));
5825         msg_conv.is_owned = false;
5826         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5827 }
5828
5829 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5830         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5831         LDKPublicKey their_node_id_ref;
5832         CHECK(*((uint32_t*)their_node_id) == 33);
5833         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5834         LDKChannelReestablish msg_conv;
5835         msg_conv.inner = (void*)(msg & (~1));
5836         msg_conv.is_owned = false;
5837         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5838 }
5839
5840 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5841         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5842         LDKPublicKey their_node_id_ref;
5843         CHECK(*((uint32_t*)their_node_id) == 33);
5844         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5845         LDKChannelUpdate msg_conv;
5846         msg_conv.inner = (void*)(msg & (~1));
5847         msg_conv.is_owned = false;
5848         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5849 }
5850
5851 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5852         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5853         LDKPublicKey their_node_id_ref;
5854         CHECK(*((uint32_t*)their_node_id) == 33);
5855         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5856         LDKErrorMessage msg_conv;
5857         msg_conv.inner = (void*)(msg & (~1));
5858         msg_conv.is_owned = false;
5859         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5860 }
5861
5862 typedef struct LDKRoutingMessageHandler_JCalls {
5863         atomic_size_t refcnt;
5864         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5865         uint32_t handle_node_announcement_meth;
5866         uint32_t handle_channel_announcement_meth;
5867         uint32_t handle_channel_update_meth;
5868         uint32_t handle_htlc_fail_channel_update_meth;
5869         uint32_t get_next_channel_announcements_meth;
5870         uint32_t get_next_node_announcements_meth;
5871         uint32_t sync_routing_table_meth;
5872         uint32_t handle_reply_channel_range_meth;
5873         uint32_t handle_reply_short_channel_ids_end_meth;
5874         uint32_t handle_query_channel_range_meth;
5875         uint32_t handle_query_short_channel_ids_meth;
5876 } LDKRoutingMessageHandler_JCalls;
5877 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
5878         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5879         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5880                 js_free(j_calls->handle_node_announcement_meth);
5881                 js_free(j_calls->handle_channel_announcement_meth);
5882                 js_free(j_calls->handle_channel_update_meth);
5883                 js_free(j_calls->handle_htlc_fail_channel_update_meth);
5884                 js_free(j_calls->get_next_channel_announcements_meth);
5885                 js_free(j_calls->get_next_node_announcements_meth);
5886                 js_free(j_calls->sync_routing_table_meth);
5887                 js_free(j_calls->handle_reply_channel_range_meth);
5888                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
5889                 js_free(j_calls->handle_query_channel_range_meth);
5890                 js_free(j_calls->handle_query_short_channel_ids_meth);
5891                 FREE(j_calls);
5892         }
5893 }
5894 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
5895         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5896         LDKNodeAnnouncement msg_var = *msg;
5897         msg_var = NodeAnnouncement_clone(msg);
5898         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5899         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5900         uint64_t msg_ref = (uint64_t)msg_var.inner;
5901         if (msg_var.is_owned) {
5902                 msg_ref |= 1;
5903         }
5904         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
5905         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5906         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5907         return ret_conv;
5908 }
5909 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
5910         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5911         LDKChannelAnnouncement msg_var = *msg;
5912         msg_var = ChannelAnnouncement_clone(msg);
5913         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5914         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5915         uint64_t msg_ref = (uint64_t)msg_var.inner;
5916         if (msg_var.is_owned) {
5917                 msg_ref |= 1;
5918         }
5919         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
5920         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5921         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5922         return ret_conv;
5923 }
5924 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
5925         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5926         LDKChannelUpdate msg_var = *msg;
5927         msg_var = ChannelUpdate_clone(msg);
5928         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5929         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5930         uint64_t msg_ref = (uint64_t)msg_var.inner;
5931         if (msg_var.is_owned) {
5932                 msg_ref |= 1;
5933         }
5934         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
5935         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5936         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5937         return ret_conv;
5938 }
5939 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
5940         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5941         uint64_t ret_update = (uint64_t)update;
5942         js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
5943 }
5944 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
5945         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5946         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
5947         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
5948         ret_constr.datalen = *((uint32_t*)ret);
5949         if (ret_constr.datalen > 0)
5950                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5951         else
5952                 ret_constr.data = NULL;
5953         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5954         for (size_t l = 0; l < ret_constr.datalen; l++) {
5955                 uint32_t ret_conv_63 = ret_vals[l];
5956                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
5957                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
5958                 ret_constr.data[l] = ret_conv_63_conv;
5959         }
5960         return ret_constr;
5961 }
5962 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
5963         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5964         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5965         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
5966         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
5967         LDKCVec_NodeAnnouncementZ ret_constr;
5968         ret_constr.datalen = *((uint32_t*)ret);
5969         if (ret_constr.datalen > 0)
5970                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5971         else
5972                 ret_constr.data = NULL;
5973         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5974         for (size_t s = 0; s < ret_constr.datalen; s++) {
5975                 uint32_t ret_conv_18 = ret_vals[s];
5976                 LDKNodeAnnouncement ret_conv_18_conv;
5977                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
5978                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
5979                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
5980                 ret_constr.data[s] = ret_conv_18_conv;
5981         }
5982         return ret_constr;
5983 }
5984 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
5985         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5986         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5987         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5988         LDKInit init_var = *init;
5989         init_var = Init_clone(init);
5990         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5991         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5992         uint64_t init_ref = (uint64_t)init_var.inner;
5993         if (init_var.is_owned) {
5994                 init_ref |= 1;
5995         }
5996         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
5997 }
5998 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
5999         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6000         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6001         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6002         LDKReplyChannelRange msg_var = msg;
6003         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6004         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6005         uint64_t msg_ref = (uint64_t)msg_var.inner;
6006         if (msg_var.is_owned) {
6007                 msg_ref |= 1;
6008         }
6009         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6010         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6011         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6012         return ret_conv;
6013 }
6014 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6015         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6016         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6017         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6018         LDKReplyShortChannelIdsEnd msg_var = msg;
6019         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6020         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6021         uint64_t msg_ref = (uint64_t)msg_var.inner;
6022         if (msg_var.is_owned) {
6023                 msg_ref |= 1;
6024         }
6025         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6026         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6027         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6028         return ret_conv;
6029 }
6030 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6031         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6032         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6033         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6034         LDKQueryChannelRange msg_var = msg;
6035         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6036         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6037         uint64_t msg_ref = (uint64_t)msg_var.inner;
6038         if (msg_var.is_owned) {
6039                 msg_ref |= 1;
6040         }
6041         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6042         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6043         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6044         return ret_conv;
6045 }
6046 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6047         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6048         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6049         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6050         LDKQueryShortChannelIds msg_var = msg;
6051         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6052         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6053         uint64_t msg_ref = (uint64_t)msg_var.inner;
6054         if (msg_var.is_owned) {
6055                 msg_ref |= 1;
6056         }
6057         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6058         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6059         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6060         return ret_conv;
6061 }
6062 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
6063         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6064         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6065         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6066         return (void*) this_arg;
6067 }
6068 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6069         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6070         atomic_init(&calls->refcnt, 1);
6071         //TODO: Assign calls->o from o
6072
6073         LDKRoutingMessageHandler ret = {
6074                 .this_arg = (void*) calls,
6075                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
6076                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
6077                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
6078                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
6079                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
6080                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
6081                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
6082                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
6083                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
6084                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
6085                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
6086                 .free = LDKRoutingMessageHandler_JCalls_free,
6087                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6088         };
6089         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6090         return ret;
6091 }
6092 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6093         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6094         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
6095         return (long)res_ptr;
6096 }
6097 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
6098         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6099         LDKNodeAnnouncement msg_conv;
6100         msg_conv.inner = (void*)(msg & (~1));
6101         msg_conv.is_owned = false;
6102         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6103         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6104         return (uint64_t)ret_conv;
6105 }
6106
6107 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
6108         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6109         LDKChannelAnnouncement msg_conv;
6110         msg_conv.inner = (void*)(msg & (~1));
6111         msg_conv.is_owned = false;
6112         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6113         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6114         return (uint64_t)ret_conv;
6115 }
6116
6117 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
6118         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6119         LDKChannelUpdate msg_conv;
6120         msg_conv.inner = (void*)(msg & (~1));
6121         msg_conv.is_owned = false;
6122         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6123         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6124         return (uint64_t)ret_conv;
6125 }
6126
6127 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
6128         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6129         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
6130         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
6131 }
6132
6133 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
6134         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6135         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6136         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6137         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6138         for (size_t l = 0; l < ret_var.datalen; l++) {
6139                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6140                 *ret_conv_63_ref = ret_var.data[l];
6141                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
6142         }
6143         FREE(ret_var.data);
6144         return ret_arr;
6145 }
6146
6147 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
6148         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6149         LDKPublicKey starting_point_ref;
6150         CHECK(*((uint32_t*)starting_point) == 33);
6151         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
6152         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6153         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6154         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6155         for (size_t s = 0; s < ret_var.datalen; s++) {
6156                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6157                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6158                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6159                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
6160                 if (ret_conv_18_var.is_owned) {
6161                         ret_conv_18_ref |= 1;
6162                 }
6163                 ret_arr_ptr[s] = ret_conv_18_ref;
6164         }
6165         FREE(ret_var.data);
6166         return ret_arr;
6167 }
6168
6169 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
6170         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6171         LDKPublicKey their_node_id_ref;
6172         CHECK(*((uint32_t*)their_node_id) == 33);
6173         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6174         LDKInit init_conv;
6175         init_conv.inner = (void*)(init & (~1));
6176         init_conv.is_owned = false;
6177         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
6178 }
6179
6180 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6181         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6182         LDKPublicKey their_node_id_ref;
6183         CHECK(*((uint32_t*)their_node_id) == 33);
6184         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6185         LDKReplyChannelRange msg_conv;
6186         msg_conv.inner = (void*)(msg & (~1));
6187         msg_conv.is_owned = (msg & 1) || (msg == 0);
6188         msg_conv = ReplyChannelRange_clone(&msg_conv);
6189         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6190         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6191         return (uint64_t)ret_conv;
6192 }
6193
6194 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) {
6195         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6196         LDKPublicKey their_node_id_ref;
6197         CHECK(*((uint32_t*)their_node_id) == 33);
6198         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6199         LDKReplyShortChannelIdsEnd msg_conv;
6200         msg_conv.inner = (void*)(msg & (~1));
6201         msg_conv.is_owned = (msg & 1) || (msg == 0);
6202         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
6203         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6204         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6205         return (uint64_t)ret_conv;
6206 }
6207
6208 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6209         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6210         LDKPublicKey their_node_id_ref;
6211         CHECK(*((uint32_t*)their_node_id) == 33);
6212         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6213         LDKQueryChannelRange msg_conv;
6214         msg_conv.inner = (void*)(msg & (~1));
6215         msg_conv.is_owned = (msg & 1) || (msg == 0);
6216         msg_conv = QueryChannelRange_clone(&msg_conv);
6217         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6218         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6219         return (uint64_t)ret_conv;
6220 }
6221
6222 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6223         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6224         LDKPublicKey their_node_id_ref;
6225         CHECK(*((uint32_t*)their_node_id) == 33);
6226         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6227         LDKQueryShortChannelIds msg_conv;
6228         msg_conv.inner = (void*)(msg & (~1));
6229         msg_conv.is_owned = (msg & 1) || (msg == 0);
6230         msg_conv = QueryShortChannelIds_clone(&msg_conv);
6231         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6232         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6233         return (uint64_t)ret_conv;
6234 }
6235
6236 typedef struct LDKSocketDescriptor_JCalls {
6237         atomic_size_t refcnt;
6238         uint32_t send_data_meth;
6239         uint32_t disconnect_socket_meth;
6240         uint32_t eq_meth;
6241         uint32_t hash_meth;
6242 } LDKSocketDescriptor_JCalls;
6243 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
6244         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6245         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6246                 js_free(j_calls->send_data_meth);
6247                 js_free(j_calls->disconnect_socket_meth);
6248                 js_free(j_calls->eq_meth);
6249                 js_free(j_calls->hash_meth);
6250                 FREE(j_calls);
6251         }
6252 }
6253 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
6254         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6255         LDKu8slice data_var = data;
6256         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6257         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
6258         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
6259 }
6260 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
6261         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6262         js_invoke_function_0(j_calls->disconnect_socket_meth);
6263 }
6264 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
6265         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6266         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6267         *other_arg_clone = SocketDescriptor_clone(other_arg);
6268         return js_invoke_function_1(j_calls->eq_meth, (uint64_t)other_arg_clone);
6269 }
6270 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
6271         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6272         return js_invoke_function_0(j_calls->hash_meth);
6273 }
6274 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
6275         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6276         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6277         return (void*) this_arg;
6278 }
6279 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
6280         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
6281         atomic_init(&calls->refcnt, 1);
6282         //TODO: Assign calls->o from o
6283
6284         LDKSocketDescriptor ret = {
6285                 .this_arg = (void*) calls,
6286                 .send_data = send_data_LDKSocketDescriptor_jcall,
6287                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
6288                 .eq = eq_LDKSocketDescriptor_jcall,
6289                 .hash = hash_LDKSocketDescriptor_jcall,
6290                 .clone = LDKSocketDescriptor_JCalls_clone,
6291                 .free = LDKSocketDescriptor_JCalls_free,
6292         };
6293         return ret;
6294 }
6295 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
6296         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6297         *res_ptr = LDKSocketDescriptor_init(o);
6298         return (long)res_ptr;
6299 }
6300 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
6301         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6302         LDKu8slice data_ref;
6303         data_ref.datalen = *((uint32_t*)data);
6304         data_ref.data = (int8_t*)(data + 4);
6305         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
6306         return ret_val;
6307 }
6308
6309 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
6310         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6311         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
6312 }
6313
6314 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
6315         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6316         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
6317         return ret_val;
6318 }
6319
6320 typedef struct LDKChannelManagerPersister_JCalls {
6321         atomic_size_t refcnt;
6322         uint32_t persist_manager_meth;
6323 } LDKChannelManagerPersister_JCalls;
6324 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
6325         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6326         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6327                 js_free(j_calls->persist_manager_meth);
6328                 FREE(j_calls);
6329         }
6330 }
6331 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
6332         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6333         LDKChannelManager channel_manager_var = *channel_manager;
6334         // Warning: we may need a move here but no clone is available for LDKChannelManager
6335         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6336         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6337         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
6338         if (channel_manager_var.is_owned) {
6339                 channel_manager_ref |= 1;
6340         }
6341         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
6342         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
6343         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
6344         return ret_conv;
6345 }
6346 static void* LDKChannelManagerPersister_JCalls_clone(const void* this_arg) {
6347         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6348         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6349         return (void*) this_arg;
6350 }
6351 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (/*TODO: JS Object Reference */void* o) {
6352         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
6353         atomic_init(&calls->refcnt, 1);
6354         //TODO: Assign calls->o from o
6355
6356         LDKChannelManagerPersister ret = {
6357                 .this_arg = (void*) calls,
6358                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
6359                 .free = LDKChannelManagerPersister_JCalls_free,
6360         };
6361         return ret;
6362 }
6363 long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/*TODO: JS Object Reference */void* o) {
6364         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
6365         *res_ptr = LDKChannelManagerPersister_init(o);
6366         return (long)res_ptr;
6367 }
6368 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
6369         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
6370         LDKChannelManager channel_manager_conv;
6371         channel_manager_conv.inner = (void*)(channel_manager & (~1));
6372         channel_manager_conv.is_owned = false;
6373         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6374         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
6375         return (uint64_t)ret_conv;
6376 }
6377
6378 uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint32_t ptr) {
6379         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
6380         switch(obj->tag) {
6381                 case LDKFallback_SegWitProgram: {
6382                         uint8_t version_val = obj->seg_wit_program.version._0;
6383                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
6384                         int8_tArray program_arr = init_arr(program_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6385                         memcpy((uint8_t*)(program_arr + 4), program_var.data, program_var.datalen);
6386                         return 0 /* LDKFallback - SegWitProgram */; (void) version_val; (void) program_arr;
6387                 }
6388                 case LDKFallback_PubKeyHash: {
6389                         int8_tArray pub_key_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
6390                         memcpy((uint8_t*)(pub_key_hash_arr + 4), obj->pub_key_hash.data, 20);
6391                         return 0 /* LDKFallback - PubKeyHash */; (void) pub_key_hash_arr;
6392                 }
6393                 case LDKFallback_ScriptHash: {
6394                         int8_tArray script_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
6395                         memcpy((uint8_t*)(script_hash_arr + 4), obj->script_hash.data, 20);
6396                         return 0 /* LDKFallback - ScriptHash */; (void) script_hash_arr;
6397                 }
6398                 default: abort();
6399         }
6400 }
6401 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
6402         LDKStr ret_str = _ldk_get_compiled_version();
6403         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6404         return ret_conv;
6405 }
6406
6407 jstring  __attribute__((visibility("default"))) TS__ldk_c_bindings_get_compiled_version() {
6408         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
6409         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6410         return ret_conv;
6411 }
6412
6413 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
6414         LDKTransaction _res_ref;
6415         _res_ref.datalen = *((uint32_t*)_res);
6416         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
6417         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
6418         _res_ref.data_is_owned = true;
6419         Transaction_free(_res_ref);
6420 }
6421
6422 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
6423         if ((_res & 1) != 0) return;
6424         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
6425         FREE((void*)_res);
6426         TxOut_free(_res_conv);
6427 }
6428
6429 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
6430         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
6431         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6432         *ret_ref = TxOut_clone(orig_conv);
6433         return (uint64_t)ret_ref;
6434 }
6435
6436 void  __attribute__((visibility("default"))) TS_Str_free(jstring _res) {
6437         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
6438         Str_free(dummy);
6439 }
6440
6441 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
6442         LDKSecretKey o_ref;
6443         CHECK(*((uint32_t*)o) == 32);
6444         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
6445         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6446         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
6447         return (uint64_t)ret_conv;
6448 }
6449
6450 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
6451         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6452         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6453         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
6454         return (uint64_t)ret_conv;
6455 }
6456
6457 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
6458         if ((_res & 1) != 0) return;
6459         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
6460         FREE((void*)_res);
6461         CResult_SecretKeyErrorZ_free(_res_conv);
6462 }
6463
6464 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
6465         LDKPublicKey o_ref;
6466         CHECK(*((uint32_t*)o) == 33);
6467         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
6468         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6469         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
6470         return (uint64_t)ret_conv;
6471 }
6472
6473 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
6474         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6475         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6476         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
6477         return (uint64_t)ret_conv;
6478 }
6479
6480 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
6481         if ((_res & 1) != 0) return;
6482         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
6483         FREE((void*)_res);
6484         CResult_PublicKeyErrorZ_free(_res_conv);
6485 }
6486
6487 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
6488         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
6489         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6490         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
6491         return (uint64_t)ret_conv;
6492 }
6493
6494 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
6495         LDKTxCreationKeys o_conv;
6496         o_conv.inner = (void*)(o & (~1));
6497         o_conv.is_owned = (o & 1) || (o == 0);
6498         o_conv = TxCreationKeys_clone(&o_conv);
6499         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6500         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
6501         return (uint64_t)ret_conv;
6502 }
6503
6504 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
6505         LDKDecodeError e_conv;
6506         e_conv.inner = (void*)(e & (~1));
6507         e_conv.is_owned = (e & 1) || (e == 0);
6508         e_conv = DecodeError_clone(&e_conv);
6509         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6510         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
6511         return (uint64_t)ret_conv;
6512 }
6513
6514 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
6515         if ((_res & 1) != 0) return;
6516         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6517         FREE((void*)_res);
6518         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
6519 }
6520
6521 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
6522         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
6523         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6524         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
6525         return (uint64_t)ret_conv;
6526 }
6527
6528 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
6529         LDKChannelPublicKeys o_conv;
6530         o_conv.inner = (void*)(o & (~1));
6531         o_conv.is_owned = (o & 1) || (o == 0);
6532         o_conv = ChannelPublicKeys_clone(&o_conv);
6533         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6534         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
6535         return (uint64_t)ret_conv;
6536 }
6537
6538 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
6539         LDKDecodeError e_conv;
6540         e_conv.inner = (void*)(e & (~1));
6541         e_conv.is_owned = (e & 1) || (e == 0);
6542         e_conv = DecodeError_clone(&e_conv);
6543         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6544         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
6545         return (uint64_t)ret_conv;
6546 }
6547
6548 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
6549         if ((_res & 1) != 0) return;
6550         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6551         FREE((void*)_res);
6552         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
6553 }
6554
6555 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
6556         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
6557         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6558         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
6559         return (uint64_t)ret_conv;
6560 }
6561
6562 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
6563         LDKTxCreationKeys o_conv;
6564         o_conv.inner = (void*)(o & (~1));
6565         o_conv.is_owned = (o & 1) || (o == 0);
6566         o_conv = TxCreationKeys_clone(&o_conv);
6567         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6568         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
6569         return (uint64_t)ret_conv;
6570 }
6571
6572 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
6573         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6574         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6575         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
6576         return (uint64_t)ret_conv;
6577 }
6578
6579 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
6580         if ((_res & 1) != 0) return;
6581         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
6582         FREE((void*)_res);
6583         CResult_TxCreationKeysErrorZ_free(_res_conv);
6584 }
6585
6586 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
6587         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
6588         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6589         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
6590         return (uint64_t)ret_conv;
6591 }
6592
6593 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
6594         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6595         *ret_copy = COption_u32Z_some(o);
6596         uint64_t ret_ref = (uint64_t)ret_copy;
6597         return ret_ref;
6598 }
6599
6600 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
6601         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6602         *ret_copy = COption_u32Z_none();
6603         uint64_t ret_ref = (uint64_t)ret_copy;
6604         return ret_ref;
6605 }
6606
6607 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
6608         if ((_res & 1) != 0) return;
6609         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
6610         FREE((void*)_res);
6611         COption_u32Z_free(_res_conv);
6612 }
6613
6614 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
6615         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
6616         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6617         *ret_copy = COption_u32Z_clone(orig_conv);
6618         uint64_t ret_ref = (uint64_t)ret_copy;
6619         return ret_ref;
6620 }
6621
6622 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
6623         LDKHTLCOutputInCommitment o_conv;
6624         o_conv.inner = (void*)(o & (~1));
6625         o_conv.is_owned = (o & 1) || (o == 0);
6626         o_conv = HTLCOutputInCommitment_clone(&o_conv);
6627         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6628         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
6629         return (uint64_t)ret_conv;
6630 }
6631
6632 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
6633         LDKDecodeError e_conv;
6634         e_conv.inner = (void*)(e & (~1));
6635         e_conv.is_owned = (e & 1) || (e == 0);
6636         e_conv = DecodeError_clone(&e_conv);
6637         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6638         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
6639         return (uint64_t)ret_conv;
6640 }
6641
6642 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
6643         if ((_res & 1) != 0) return;
6644         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
6645         FREE((void*)_res);
6646         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
6647 }
6648
6649 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
6650         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
6651         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6652         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
6653         return (uint64_t)ret_conv;
6654 }
6655
6656 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
6657         LDKCounterpartyChannelTransactionParameters o_conv;
6658         o_conv.inner = (void*)(o & (~1));
6659         o_conv.is_owned = (o & 1) || (o == 0);
6660         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
6661         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6662         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6663         return (uint64_t)ret_conv;
6664 }
6665
6666 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
6667         LDKDecodeError e_conv;
6668         e_conv.inner = (void*)(e & (~1));
6669         e_conv.is_owned = (e & 1) || (e == 0);
6670         e_conv = DecodeError_clone(&e_conv);
6671         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6672         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
6673         return (uint64_t)ret_conv;
6674 }
6675
6676 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
6677         if ((_res & 1) != 0) return;
6678         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6679         FREE((void*)_res);
6680         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6681 }
6682
6683 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
6684         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6685         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6686         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6687         return (uint64_t)ret_conv;
6688 }
6689
6690 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
6691         LDKChannelTransactionParameters o_conv;
6692         o_conv.inner = (void*)(o & (~1));
6693         o_conv.is_owned = (o & 1) || (o == 0);
6694         o_conv = ChannelTransactionParameters_clone(&o_conv);
6695         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6696         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6697         return (uint64_t)ret_conv;
6698 }
6699
6700 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
6701         LDKDecodeError e_conv;
6702         e_conv.inner = (void*)(e & (~1));
6703         e_conv.is_owned = (e & 1) || (e == 0);
6704         e_conv = DecodeError_clone(&e_conv);
6705         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6706         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
6707         return (uint64_t)ret_conv;
6708 }
6709
6710 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
6711         if ((_res & 1) != 0) return;
6712         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6713         FREE((void*)_res);
6714         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6715 }
6716
6717 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
6718         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6719         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6720         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6721         return (uint64_t)ret_conv;
6722 }
6723
6724 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
6725         LDKCVec_SignatureZ _res_constr;
6726         _res_constr.datalen = *((uint32_t*)_res);
6727         if (_res_constr.datalen > 0)
6728                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6729         else
6730                 _res_constr.data = NULL;
6731         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
6732         for (size_t m = 0; m < _res_constr.datalen; m++) {
6733                 int8_tArray _res_conv_12 = _res_vals[m];
6734                 LDKSignature _res_conv_12_ref;
6735                 CHECK(*((uint32_t*)_res_conv_12) == 64);
6736                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
6737                 _res_constr.data[m] = _res_conv_12_ref;
6738         }
6739         CVec_SignatureZ_free(_res_constr);
6740 }
6741
6742 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6743         LDKHolderCommitmentTransaction o_conv;
6744         o_conv.inner = (void*)(o & (~1));
6745         o_conv.is_owned = (o & 1) || (o == 0);
6746         o_conv = HolderCommitmentTransaction_clone(&o_conv);
6747         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6748         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
6749         return (uint64_t)ret_conv;
6750 }
6751
6752 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6753         LDKDecodeError e_conv;
6754         e_conv.inner = (void*)(e & (~1));
6755         e_conv.is_owned = (e & 1) || (e == 0);
6756         e_conv = DecodeError_clone(&e_conv);
6757         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6758         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
6759         return (uint64_t)ret_conv;
6760 }
6761
6762 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6763         if ((_res & 1) != 0) return;
6764         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6765         FREE((void*)_res);
6766         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
6767 }
6768
6769 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6770         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6771         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6772         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6773         return (uint64_t)ret_conv;
6774 }
6775
6776 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6777         LDKBuiltCommitmentTransaction o_conv;
6778         o_conv.inner = (void*)(o & (~1));
6779         o_conv.is_owned = (o & 1) || (o == 0);
6780         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
6781         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6782         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
6783         return (uint64_t)ret_conv;
6784 }
6785
6786 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6787         LDKDecodeError e_conv;
6788         e_conv.inner = (void*)(e & (~1));
6789         e_conv.is_owned = (e & 1) || (e == 0);
6790         e_conv = DecodeError_clone(&e_conv);
6791         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6792         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
6793         return (uint64_t)ret_conv;
6794 }
6795
6796 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6797         if ((_res & 1) != 0) return;
6798         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6799         FREE((void*)_res);
6800         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
6801 }
6802
6803 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6804         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6805         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6806         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6807         return (uint64_t)ret_conv;
6808 }
6809
6810 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6811         LDKCommitmentTransaction o_conv;
6812         o_conv.inner = (void*)(o & (~1));
6813         o_conv.is_owned = (o & 1) || (o == 0);
6814         o_conv = CommitmentTransaction_clone(&o_conv);
6815         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6816         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
6817         return (uint64_t)ret_conv;
6818 }
6819
6820 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6821         LDKDecodeError e_conv;
6822         e_conv.inner = (void*)(e & (~1));
6823         e_conv.is_owned = (e & 1) || (e == 0);
6824         e_conv = DecodeError_clone(&e_conv);
6825         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6826         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
6827         return (uint64_t)ret_conv;
6828 }
6829
6830 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6831         if ((_res & 1) != 0) return;
6832         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6833         FREE((void*)_res);
6834         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
6835 }
6836
6837 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6838         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
6839         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6840         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
6841         return (uint64_t)ret_conv;
6842 }
6843
6844 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
6845         LDKTrustedCommitmentTransaction o_conv;
6846         o_conv.inner = (void*)(o & (~1));
6847         o_conv.is_owned = (o & 1) || (o == 0);
6848         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
6849         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6850         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
6851         return (uint64_t)ret_conv;
6852 }
6853
6854 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
6855         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6856         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
6857         return (uint64_t)ret_conv;
6858 }
6859
6860 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
6861         if ((_res & 1) != 0) return;
6862         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
6863         FREE((void*)_res);
6864         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
6865 }
6866
6867 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
6868         LDKCVec_SignatureZ o_constr;
6869         o_constr.datalen = *((uint32_t*)o);
6870         if (o_constr.datalen > 0)
6871                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6872         else
6873                 o_constr.data = NULL;
6874         int8_tArray* o_vals = (int8_tArray*)(o + 4);
6875         for (size_t m = 0; m < o_constr.datalen; m++) {
6876                 int8_tArray o_conv_12 = o_vals[m];
6877                 LDKSignature o_conv_12_ref;
6878                 CHECK(*((uint32_t*)o_conv_12) == 64);
6879                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
6880                 o_constr.data[m] = o_conv_12_ref;
6881         }
6882         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6883         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
6884         return (uint64_t)ret_conv;
6885 }
6886
6887 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
6888         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6889         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
6890         return (uint64_t)ret_conv;
6891 }
6892
6893 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
6894         if ((_res & 1) != 0) return;
6895         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
6896         FREE((void*)_res);
6897         CResult_CVec_SignatureZNoneZ_free(_res_conv);
6898 }
6899
6900 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
6901         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
6902         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6903         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
6904         return (uint64_t)ret_conv;
6905 }
6906
6907 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
6908         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6909         *ret_conv = CResult_NoneErrorZ_ok();
6910         return (uint64_t)ret_conv;
6911 }
6912
6913 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
6914         LDKIOError e_conv = LDKIOError_from_js(e);
6915         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6916         *ret_conv = CResult_NoneErrorZ_err(e_conv);
6917         return (uint64_t)ret_conv;
6918 }
6919
6920 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
6921         if ((_res & 1) != 0) return;
6922         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
6923         FREE((void*)_res);
6924         CResult_NoneErrorZ_free(_res_conv);
6925 }
6926
6927 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
6928         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
6929         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6930         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
6931         return (uint64_t)ret_conv;
6932 }
6933
6934 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
6935         LDKRouteHop o_conv;
6936         o_conv.inner = (void*)(o & (~1));
6937         o_conv.is_owned = (o & 1) || (o == 0);
6938         o_conv = RouteHop_clone(&o_conv);
6939         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
6940         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
6941         return (uint64_t)ret_conv;
6942 }
6943
6944 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
6945         LDKDecodeError e_conv;
6946         e_conv.inner = (void*)(e & (~1));
6947         e_conv.is_owned = (e & 1) || (e == 0);
6948         e_conv = DecodeError_clone(&e_conv);
6949         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
6950         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
6951         return (uint64_t)ret_conv;
6952 }
6953
6954 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
6955         if ((_res & 1) != 0) return;
6956         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
6957         FREE((void*)_res);
6958         CResult_RouteHopDecodeErrorZ_free(_res_conv);
6959 }
6960
6961 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
6962         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
6963         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
6964         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
6965         return (uint64_t)ret_conv;
6966 }
6967
6968 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
6969         LDKCVec_RouteHopZ _res_constr;
6970         _res_constr.datalen = *((uint32_t*)_res);
6971         if (_res_constr.datalen > 0)
6972                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
6973         else
6974                 _res_constr.data = NULL;
6975         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6976         for (size_t k = 0; k < _res_constr.datalen; k++) {
6977                 uint32_t _res_conv_10 = _res_vals[k];
6978                 LDKRouteHop _res_conv_10_conv;
6979                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
6980                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
6981                 _res_constr.data[k] = _res_conv_10_conv;
6982         }
6983         CVec_RouteHopZ_free(_res_constr);
6984 }
6985
6986 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
6987         LDKCVec_CVec_RouteHopZZ _res_constr;
6988         _res_constr.datalen = *((uint32_t*)_res);
6989         if (_res_constr.datalen > 0)
6990                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
6991         else
6992                 _res_constr.data = NULL;
6993         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
6994         for (size_t m = 0; m < _res_constr.datalen; m++) {
6995                 uint32_tArray _res_conv_12 = _res_vals[m];
6996                 LDKCVec_RouteHopZ _res_conv_12_constr;
6997                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
6998                 if (_res_conv_12_constr.datalen > 0)
6999                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7000                 else
7001                         _res_conv_12_constr.data = NULL;
7002                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
7003                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
7004                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
7005                         LDKRouteHop _res_conv_12_conv_10_conv;
7006                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
7007                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
7008                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
7009                 }
7010                 _res_constr.data[m] = _res_conv_12_constr;
7011         }
7012         CVec_CVec_RouteHopZZ_free(_res_constr);
7013 }
7014
7015 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
7016         LDKRoute o_conv;
7017         o_conv.inner = (void*)(o & (~1));
7018         o_conv.is_owned = (o & 1) || (o == 0);
7019         o_conv = Route_clone(&o_conv);
7020         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7021         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7022         return (uint64_t)ret_conv;
7023 }
7024
7025 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
7026         LDKDecodeError e_conv;
7027         e_conv.inner = (void*)(e & (~1));
7028         e_conv.is_owned = (e & 1) || (e == 0);
7029         e_conv = DecodeError_clone(&e_conv);
7030         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7031         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7032         return (uint64_t)ret_conv;
7033 }
7034
7035 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
7036         if ((_res & 1) != 0) return;
7037         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7038         FREE((void*)_res);
7039         CResult_RouteDecodeErrorZ_free(_res_conv);
7040 }
7041
7042 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
7043         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7044         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7045         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7046         return (uint64_t)ret_conv;
7047 }
7048
7049 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
7050         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7051         *ret_copy = COption_u64Z_some(o);
7052         uint64_t ret_ref = (uint64_t)ret_copy;
7053         return ret_ref;
7054 }
7055
7056 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
7057         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7058         *ret_copy = COption_u64Z_none();
7059         uint64_t ret_ref = (uint64_t)ret_copy;
7060         return ret_ref;
7061 }
7062
7063 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
7064         if ((_res & 1) != 0) return;
7065         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
7066         FREE((void*)_res);
7067         COption_u64Z_free(_res_conv);
7068 }
7069
7070 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
7071         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
7072         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7073         *ret_copy = COption_u64Z_clone(orig_conv);
7074         uint64_t ret_ref = (uint64_t)ret_copy;
7075         return ret_ref;
7076 }
7077
7078 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
7079         LDKCVec_ChannelDetailsZ _res_constr;
7080         _res_constr.datalen = *((uint32_t*)_res);
7081         if (_res_constr.datalen > 0)
7082                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7083         else
7084                 _res_constr.data = NULL;
7085         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7086         for (size_t q = 0; q < _res_constr.datalen; q++) {
7087                 uint32_t _res_conv_16 = _res_vals[q];
7088                 LDKChannelDetails _res_conv_16_conv;
7089                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7090                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7091                 _res_constr.data[q] = _res_conv_16_conv;
7092         }
7093         CVec_ChannelDetailsZ_free(_res_constr);
7094 }
7095
7096 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
7097         LDKCVec_RouteHintZ _res_constr;
7098         _res_constr.datalen = *((uint32_t*)_res);
7099         if (_res_constr.datalen > 0)
7100                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7101         else
7102                 _res_constr.data = NULL;
7103         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7104         for (size_t l = 0; l < _res_constr.datalen; l++) {
7105                 uint32_t _res_conv_11 = _res_vals[l];
7106                 LDKRouteHint _res_conv_11_conv;
7107                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
7108                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
7109                 _res_constr.data[l] = _res_conv_11_conv;
7110         }
7111         CVec_RouteHintZ_free(_res_constr);
7112 }
7113
7114 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
7115         LDKRoute o_conv;
7116         o_conv.inner = (void*)(o & (~1));
7117         o_conv.is_owned = (o & 1) || (o == 0);
7118         o_conv = Route_clone(&o_conv);
7119         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7120         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
7121         return (uint64_t)ret_conv;
7122 }
7123
7124 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
7125         LDKLightningError e_conv;
7126         e_conv.inner = (void*)(e & (~1));
7127         e_conv.is_owned = (e & 1) || (e == 0);
7128         e_conv = LightningError_clone(&e_conv);
7129         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7130         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
7131         return (uint64_t)ret_conv;
7132 }
7133
7134 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
7135         if ((_res & 1) != 0) return;
7136         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
7137         FREE((void*)_res);
7138         CResult_RouteLightningErrorZ_free(_res_conv);
7139 }
7140
7141 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
7142         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
7143         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7144         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
7145         return (uint64_t)ret_conv;
7146 }
7147
7148 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
7149         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
7150         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7151         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
7152         return (uint64_t)ret_conv;
7153 }
7154
7155 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
7156         LDKAccessError e_conv = LDKAccessError_from_js(e);
7157         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7158         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
7159         return (uint64_t)ret_conv;
7160 }
7161
7162 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
7163         if ((_res & 1) != 0) return;
7164         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
7165         FREE((void*)_res);
7166         CResult_TxOutAccessErrorZ_free(_res_conv);
7167 }
7168
7169 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
7170         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
7171         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7172         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
7173         return (uint64_t)ret_conv;
7174 }
7175
7176 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
7177         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
7178         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7179         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
7180         return (uint64_t)ret_ref;
7181 }
7182
7183 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
7184         LDKTransaction b_ref;
7185         b_ref.datalen = *((uint32_t*)b);
7186         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
7187         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
7188         b_ref.data_is_owned = true;
7189         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7190         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
7191         return (uint64_t)ret_ref;
7192 }
7193
7194 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
7195         if ((_res & 1) != 0) return;
7196         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
7197         FREE((void*)_res);
7198         C2Tuple_usizeTransactionZ_free(_res_conv);
7199 }
7200
7201 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
7202         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
7203         _res_constr.datalen = *((uint32_t*)_res);
7204         if (_res_constr.datalen > 0)
7205                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7206         else
7207                 _res_constr.data = NULL;
7208         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7209         for (size_t e = 0; e < _res_constr.datalen; e++) {
7210                 uint32_t _res_conv_30 = _res_vals[e];
7211                 LDKC2Tuple_usizeTransactionZ _res_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_30) & ~1);
7212                 FREE((void*)_res_conv_30);
7213                 _res_constr.data[e] = _res_conv_30_conv;
7214         }
7215         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
7216 }
7217
7218 void  __attribute__((visibility("default"))) TS_CVec_TxidZ_free(ptrArray _res) {
7219         LDKCVec_TxidZ _res_constr;
7220         _res_constr.datalen = *((uint32_t*)_res);
7221         if (_res_constr.datalen > 0)
7222                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7223         else
7224                 _res_constr.data = NULL;
7225         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7226         for (size_t m = 0; m < _res_constr.datalen; m++) {
7227                 int8_tArray _res_conv_12 = _res_vals[m];
7228                 LDKThirtyTwoBytes _res_conv_12_ref;
7229                 CHECK(*((uint32_t*)_res_conv_12) == 32);
7230                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), 32);
7231                 _res_constr.data[m] = _res_conv_12_ref;
7232         }
7233         CVec_TxidZ_free(_res_constr);
7234 }
7235
7236 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
7237         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7238         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
7239         return (uint64_t)ret_conv;
7240 }
7241
7242 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
7243         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
7244         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7245         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
7246         return (uint64_t)ret_conv;
7247 }
7248
7249 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
7250         if ((_res & 1) != 0) return;
7251         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
7252         FREE((void*)_res);
7253         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
7254 }
7255
7256 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
7257         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
7258         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7259         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
7260         return (uint64_t)ret_conv;
7261 }
7262
7263 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
7264         LDKCVec_MonitorEventZ _res_constr;
7265         _res_constr.datalen = *((uint32_t*)_res);
7266         if (_res_constr.datalen > 0)
7267                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
7268         else
7269                 _res_constr.data = NULL;
7270         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7271         for (size_t o = 0; o < _res_constr.datalen; o++) {
7272                 uint32_t _res_conv_14 = _res_vals[o];
7273                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
7274                 FREE((void*)_res_conv_14);
7275                 _res_constr.data[o] = _res_conv_14_conv;
7276         }
7277         CVec_MonitorEventZ_free(_res_constr);
7278 }
7279
7280 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
7281         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
7282         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7283         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
7284         uint64_t ret_ref = (uint64_t)ret_copy;
7285         return ret_ref;
7286 }
7287
7288 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
7289         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7290         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
7291         uint64_t ret_ref = (uint64_t)ret_copy;
7292         return ret_ref;
7293 }
7294
7295 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
7296         if ((_res & 1) != 0) return;
7297         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
7298         FREE((void*)_res);
7299         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
7300 }
7301
7302 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
7303         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
7304         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7305         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
7306         uint64_t ret_ref = (uint64_t)ret_copy;
7307         return ret_ref;
7308 }
7309
7310 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
7311         LDKCVec_SpendableOutputDescriptorZ _res_constr;
7312         _res_constr.datalen = *((uint32_t*)_res);
7313         if (_res_constr.datalen > 0)
7314                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
7315         else
7316                 _res_constr.data = NULL;
7317         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7318         for (size_t b = 0; b < _res_constr.datalen; b++) {
7319                 uint32_t _res_conv_27 = _res_vals[b];
7320                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
7321                 FREE((void*)_res_conv_27);
7322                 _res_constr.data[b] = _res_conv_27_conv;
7323         }
7324         CVec_SpendableOutputDescriptorZ_free(_res_constr);
7325 }
7326
7327 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
7328         LDKCVec_MessageSendEventZ _res_constr;
7329         _res_constr.datalen = *((uint32_t*)_res);
7330         if (_res_constr.datalen > 0)
7331                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7332         else
7333                 _res_constr.data = NULL;
7334         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7335         for (size_t s = 0; s < _res_constr.datalen; s++) {
7336                 uint32_t _res_conv_18 = _res_vals[s];
7337                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
7338                 FREE((void*)_res_conv_18);
7339                 _res_constr.data[s] = _res_conv_18_conv;
7340         }
7341         CVec_MessageSendEventZ_free(_res_constr);
7342 }
7343
7344 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
7345         LDKInitFeatures o_conv;
7346         o_conv.inner = (void*)(o & (~1));
7347         o_conv.is_owned = (o & 1) || (o == 0);
7348         o_conv = InitFeatures_clone(&o_conv);
7349         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7350         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
7351         return (uint64_t)ret_conv;
7352 }
7353
7354 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
7355         LDKDecodeError e_conv;
7356         e_conv.inner = (void*)(e & (~1));
7357         e_conv.is_owned = (e & 1) || (e == 0);
7358         e_conv = DecodeError_clone(&e_conv);
7359         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7360         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
7361         return (uint64_t)ret_conv;
7362 }
7363
7364 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
7365         if ((_res & 1) != 0) return;
7366         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7367         FREE((void*)_res);
7368         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
7369 }
7370
7371 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
7372         LDKNodeFeatures o_conv;
7373         o_conv.inner = (void*)(o & (~1));
7374         o_conv.is_owned = (o & 1) || (o == 0);
7375         o_conv = NodeFeatures_clone(&o_conv);
7376         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7377         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
7378         return (uint64_t)ret_conv;
7379 }
7380
7381 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
7382         LDKDecodeError e_conv;
7383         e_conv.inner = (void*)(e & (~1));
7384         e_conv.is_owned = (e & 1) || (e == 0);
7385         e_conv = DecodeError_clone(&e_conv);
7386         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7387         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
7388         return (uint64_t)ret_conv;
7389 }
7390
7391 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
7392         if ((_res & 1) != 0) return;
7393         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7394         FREE((void*)_res);
7395         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
7396 }
7397
7398 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
7399         LDKChannelFeatures o_conv;
7400         o_conv.inner = (void*)(o & (~1));
7401         o_conv.is_owned = (o & 1) || (o == 0);
7402         o_conv = ChannelFeatures_clone(&o_conv);
7403         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7404         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
7405         return (uint64_t)ret_conv;
7406 }
7407
7408 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
7409         LDKDecodeError e_conv;
7410         e_conv.inner = (void*)(e & (~1));
7411         e_conv.is_owned = (e & 1) || (e == 0);
7412         e_conv = DecodeError_clone(&e_conv);
7413         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7414         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
7415         return (uint64_t)ret_conv;
7416 }
7417
7418 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
7419         if ((_res & 1) != 0) return;
7420         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7421         FREE((void*)_res);
7422         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
7423 }
7424
7425 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
7426         LDKInvoiceFeatures o_conv;
7427         o_conv.inner = (void*)(o & (~1));
7428         o_conv.is_owned = (o & 1) || (o == 0);
7429         o_conv = InvoiceFeatures_clone(&o_conv);
7430         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7431         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
7432         return (uint64_t)ret_conv;
7433 }
7434
7435 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
7436         LDKDecodeError e_conv;
7437         e_conv.inner = (void*)(e & (~1));
7438         e_conv.is_owned = (e & 1) || (e == 0);
7439         e_conv = DecodeError_clone(&e_conv);
7440         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7441         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
7442         return (uint64_t)ret_conv;
7443 }
7444
7445 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
7446         if ((_res & 1) != 0) return;
7447         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7448         FREE((void*)_res);
7449         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
7450 }
7451
7452 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7453         LDKDelayedPaymentOutputDescriptor o_conv;
7454         o_conv.inner = (void*)(o & (~1));
7455         o_conv.is_owned = (o & 1) || (o == 0);
7456         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
7457         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7458         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
7459         return (uint64_t)ret_conv;
7460 }
7461
7462 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7463         LDKDecodeError e_conv;
7464         e_conv.inner = (void*)(e & (~1));
7465         e_conv.is_owned = (e & 1) || (e == 0);
7466         e_conv = DecodeError_clone(&e_conv);
7467         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7468         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
7469         return (uint64_t)ret_conv;
7470 }
7471
7472 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7473         if ((_res & 1) != 0) return;
7474         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7475         FREE((void*)_res);
7476         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
7477 }
7478
7479 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7480         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
7481         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7482         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
7483         return (uint64_t)ret_conv;
7484 }
7485
7486 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7487         LDKStaticPaymentOutputDescriptor o_conv;
7488         o_conv.inner = (void*)(o & (~1));
7489         o_conv.is_owned = (o & 1) || (o == 0);
7490         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
7491         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7492         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
7493         return (uint64_t)ret_conv;
7494 }
7495
7496 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7497         LDKDecodeError e_conv;
7498         e_conv.inner = (void*)(e & (~1));
7499         e_conv.is_owned = (e & 1) || (e == 0);
7500         e_conv = DecodeError_clone(&e_conv);
7501         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7502         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
7503         return (uint64_t)ret_conv;
7504 }
7505
7506 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7507         if ((_res & 1) != 0) return;
7508         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7509         FREE((void*)_res);
7510         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
7511 }
7512
7513 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7514         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
7515         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7516         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
7517         return (uint64_t)ret_conv;
7518 }
7519
7520 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7521         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
7522         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7523         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
7524         return (uint64_t)ret_conv;
7525 }
7526
7527 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7528         LDKDecodeError e_conv;
7529         e_conv.inner = (void*)(e & (~1));
7530         e_conv.is_owned = (e & 1) || (e == 0);
7531         e_conv = DecodeError_clone(&e_conv);
7532         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7533         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
7534         return (uint64_t)ret_conv;
7535 }
7536
7537 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7538         if ((_res & 1) != 0) return;
7539         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7540         FREE((void*)_res);
7541         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
7542 }
7543
7544 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7545         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
7546         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7547         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
7548         return (uint64_t)ret_conv;
7549 }
7550
7551 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
7552         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
7553         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7554         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
7555         return (uint64_t)ret_ref;
7556 }
7557
7558 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
7559         LDKSignature a_ref;
7560         CHECK(*((uint32_t*)a) == 64);
7561         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
7562         LDKCVec_SignatureZ b_constr;
7563         b_constr.datalen = *((uint32_t*)b);
7564         if (b_constr.datalen > 0)
7565                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7566         else
7567                 b_constr.data = NULL;
7568         int8_tArray* b_vals = (int8_tArray*)(b + 4);
7569         for (size_t m = 0; m < b_constr.datalen; m++) {
7570                 int8_tArray b_conv_12 = b_vals[m];
7571                 LDKSignature b_conv_12_ref;
7572                 CHECK(*((uint32_t*)b_conv_12) == 64);
7573                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
7574                 b_constr.data[m] = b_conv_12_ref;
7575         }
7576         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7577         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
7578         return (uint64_t)ret_ref;
7579 }
7580
7581 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
7582         if ((_res & 1) != 0) return;
7583         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
7584         FREE((void*)_res);
7585         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
7586 }
7587
7588 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
7589         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
7590         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7591         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
7592         return (uint64_t)ret_conv;
7593 }
7594
7595 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
7596         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7597         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
7598         return (uint64_t)ret_conv;
7599 }
7600
7601 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
7602         if ((_res & 1) != 0) return;
7603         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
7604         FREE((void*)_res);
7605         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
7606 }
7607
7608 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
7609         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
7610         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7611         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
7612         return (uint64_t)ret_conv;
7613 }
7614
7615 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
7616         LDKSignature o_ref;
7617         CHECK(*((uint32_t*)o) == 64);
7618         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
7619         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7620         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
7621         return (uint64_t)ret_conv;
7622 }
7623
7624 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
7625         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7626         *ret_conv = CResult_SignatureNoneZ_err();
7627         return (uint64_t)ret_conv;
7628 }
7629
7630 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
7631         if ((_res & 1) != 0) return;
7632         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
7633         FREE((void*)_res);
7634         CResult_SignatureNoneZ_free(_res_conv);
7635 }
7636
7637 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
7638         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
7639         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7640         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
7641         return (uint64_t)ret_conv;
7642 }
7643
7644 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
7645         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
7646         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7647         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
7648         return (uint64_t)ret_conv;
7649 }
7650
7651 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
7652         LDKDecodeError e_conv;
7653         e_conv.inner = (void*)(e & (~1));
7654         e_conv.is_owned = (e & 1) || (e == 0);
7655         e_conv = DecodeError_clone(&e_conv);
7656         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7657         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
7658         return (uint64_t)ret_conv;
7659 }
7660
7661 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
7662         if ((_res & 1) != 0) return;
7663         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
7664         FREE((void*)_res);
7665         CResult_SignDecodeErrorZ_free(_res_conv);
7666 }
7667
7668 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
7669         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
7670         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7671         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
7672         return (uint64_t)ret_conv;
7673 }
7674
7675 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
7676         LDKCVec_u8Z _res_ref;
7677         _res_ref.datalen = *((uint32_t*)_res);
7678         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
7679         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
7680         CVec_u8Z_free(_res_ref);
7681 }
7682
7683 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray arg) {
7684         LDKRecoverableSignature arg_ref;
7685         CHECK(*((uint32_t*)arg) == 68);
7686         memcpy(arg_ref.serialized_form, (uint8_t*)(arg + 4), 68);
7687         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7688         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
7689         return (uint64_t)ret_conv;
7690 }
7691
7692 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_err() {
7693         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7694         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
7695         return (uint64_t)ret_conv;
7696 }
7697
7698 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
7699         if ((_res & 1) != 0) return;
7700         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
7701         FREE((void*)_res);
7702         CResult_RecoverableSignatureNoneZ_free(_res_conv);
7703 }
7704
7705 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
7706         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
7707         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7708         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
7709         return (uint64_t)ret_conv;
7710 }
7711
7712 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
7713         LDKCVec_CVec_u8ZZ _res_constr;
7714         _res_constr.datalen = *((uint32_t*)_res);
7715         if (_res_constr.datalen > 0)
7716                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7717         else
7718                 _res_constr.data = NULL;
7719         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7720         for (size_t m = 0; m < _res_constr.datalen; m++) {
7721                 int8_tArray _res_conv_12 = _res_vals[m];
7722                 LDKCVec_u8Z _res_conv_12_ref;
7723                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
7724                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7725                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
7726                 _res_constr.data[m] = _res_conv_12_ref;
7727         }
7728         CVec_CVec_u8ZZ_free(_res_constr);
7729 }
7730
7731 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
7732         LDKCVec_CVec_u8ZZ o_constr;
7733         o_constr.datalen = *((uint32_t*)o);
7734         if (o_constr.datalen > 0)
7735                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7736         else
7737                 o_constr.data = NULL;
7738         int8_tArray* o_vals = (int8_tArray*)(o + 4);
7739         for (size_t m = 0; m < o_constr.datalen; m++) {
7740                 int8_tArray o_conv_12 = o_vals[m];
7741                 LDKCVec_u8Z o_conv_12_ref;
7742                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
7743                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7744                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
7745                 o_constr.data[m] = o_conv_12_ref;
7746         }
7747         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7748         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
7749         return (uint64_t)ret_conv;
7750 }
7751
7752 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
7753         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7754         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
7755         return (uint64_t)ret_conv;
7756 }
7757
7758 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
7759         if ((_res & 1) != 0) return;
7760         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
7761         FREE((void*)_res);
7762         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
7763 }
7764
7765 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
7766         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
7767         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7768         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
7769         return (uint64_t)ret_conv;
7770 }
7771
7772 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
7773         LDKInMemorySigner o_conv;
7774         o_conv.inner = (void*)(o & (~1));
7775         o_conv.is_owned = (o & 1) || (o == 0);
7776         o_conv = InMemorySigner_clone(&o_conv);
7777         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7778         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
7779         return (uint64_t)ret_conv;
7780 }
7781
7782 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
7783         LDKDecodeError e_conv;
7784         e_conv.inner = (void*)(e & (~1));
7785         e_conv.is_owned = (e & 1) || (e == 0);
7786         e_conv = DecodeError_clone(&e_conv);
7787         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7788         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
7789         return (uint64_t)ret_conv;
7790 }
7791
7792 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
7793         if ((_res & 1) != 0) return;
7794         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
7795         FREE((void*)_res);
7796         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
7797 }
7798
7799 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
7800         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
7801         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7802         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
7803         return (uint64_t)ret_conv;
7804 }
7805
7806 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
7807         LDKCVec_TxOutZ _res_constr;
7808         _res_constr.datalen = *((uint32_t*)_res);
7809         if (_res_constr.datalen > 0)
7810                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
7811         else
7812                 _res_constr.data = NULL;
7813         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7814         for (size_t h = 0; h < _res_constr.datalen; h++) {
7815                 uint32_t _res_conv_7 = _res_vals[h];
7816                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
7817                 FREE((void*)_res_conv_7);
7818                 _res_constr.data[h] = _res_conv_7_conv;
7819         }
7820         CVec_TxOutZ_free(_res_constr);
7821 }
7822
7823 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
7824         LDKTransaction o_ref;
7825         o_ref.datalen = *((uint32_t*)o);
7826         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
7827         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
7828         o_ref.data_is_owned = true;
7829         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7830         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
7831         return (uint64_t)ret_conv;
7832 }
7833
7834 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
7835         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7836         *ret_conv = CResult_TransactionNoneZ_err();
7837         return (uint64_t)ret_conv;
7838 }
7839
7840 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
7841         if ((_res & 1) != 0) return;
7842         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
7843         FREE((void*)_res);
7844         CResult_TransactionNoneZ_free(_res_conv);
7845 }
7846
7847 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
7848         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
7849         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7850         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
7851         return (uint64_t)ret_conv;
7852 }
7853
7854 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
7855         LDKThirtyTwoBytes a_ref;
7856         CHECK(*((uint32_t*)a) == 32);
7857         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
7858         LDKChannelMonitor b_conv;
7859         b_conv.inner = (void*)(b & (~1));
7860         b_conv.is_owned = (b & 1) || (b == 0);
7861         b_conv = ChannelMonitor_clone(&b_conv);
7862         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7863         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
7864         return (uint64_t)ret_ref;
7865 }
7866
7867 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
7868         if ((_res & 1) != 0) return;
7869         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
7870         FREE((void*)_res);
7871         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
7872 }
7873
7874 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMonitorZZ_free(uint32_tArray _res) {
7875         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
7876         _res_constr.datalen = *((uint32_t*)_res);
7877         if (_res_constr.datalen > 0)
7878                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
7879         else
7880                 _res_constr.data = NULL;
7881         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7882         for (size_t m = 0; m < _res_constr.datalen; m++) {
7883                 uint32_t _res_conv_38 = _res_vals[m];
7884                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_38) & ~1);
7885                 FREE((void*)_res_conv_38);
7886                 _res_constr.data[m] = _res_conv_38_conv;
7887         }
7888         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
7889 }
7890
7891 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(uint32_tArray o) {
7892         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
7893         o_constr.datalen = *((uint32_t*)o);
7894         if (o_constr.datalen > 0)
7895                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
7896         else
7897                 o_constr.data = NULL;
7898         uint32_t* o_vals = (uint32_t*)(o + 4);
7899         for (size_t m = 0; m < o_constr.datalen; m++) {
7900                 uint32_t o_conv_38 = o_vals[m];
7901                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_38) & ~1);
7902                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
7903                 o_constr.data[m] = o_conv_38_conv;
7904         }
7905         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
7906         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
7907         return (uint64_t)ret_conv;
7908 }
7909
7910 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(uint32_t e) {
7911         LDKIOError e_conv = LDKIOError_from_js(e);
7912         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
7913         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
7914         return (uint64_t)ret_conv;
7915 }
7916
7917 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
7918         if ((_res & 1) != 0) return;
7919         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
7920         FREE((void*)_res);
7921         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
7922 }
7923
7924 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
7925         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7926         *ret_conv = CResult_NoneAPIErrorZ_ok();
7927         return (uint64_t)ret_conv;
7928 }
7929
7930 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
7931         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
7932         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7933         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
7934         return (uint64_t)ret_conv;
7935 }
7936
7937 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
7938         if ((_res & 1) != 0) return;
7939         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
7940         FREE((void*)_res);
7941         CResult_NoneAPIErrorZ_free(_res_conv);
7942 }
7943
7944 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
7945         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
7946         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7947         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
7948         return (uint64_t)ret_conv;
7949 }
7950
7951 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
7952         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
7953         _res_constr.datalen = *((uint32_t*)_res);
7954         if (_res_constr.datalen > 0)
7955                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
7956         else
7957                 _res_constr.data = NULL;
7958         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7959         for (size_t w = 0; w < _res_constr.datalen; w++) {
7960                 uint32_t _res_conv_22 = _res_vals[w];
7961                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
7962                 FREE((void*)_res_conv_22);
7963                 _res_constr.data[w] = _res_conv_22_conv;
7964         }
7965         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
7966 }
7967
7968 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
7969         LDKCVec_APIErrorZ _res_constr;
7970         _res_constr.datalen = *((uint32_t*)_res);
7971         if (_res_constr.datalen > 0)
7972                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
7973         else
7974                 _res_constr.data = NULL;
7975         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7976         for (size_t k = 0; k < _res_constr.datalen; k++) {
7977                 uint32_t _res_conv_10 = _res_vals[k];
7978                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
7979                 FREE((void*)_res_conv_10);
7980                 _res_constr.data[k] = _res_conv_10_conv;
7981         }
7982         CVec_APIErrorZ_free(_res_constr);
7983 }
7984
7985 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
7986         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7987         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
7988         return (uint64_t)ret_conv;
7989 }
7990
7991 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
7992         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
7993         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7994         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
7995         return (uint64_t)ret_conv;
7996 }
7997
7998 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
7999         if ((_res & 1) != 0) return;
8000         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
8001         FREE((void*)_res);
8002         CResult_NonePaymentSendFailureZ_free(_res_conv);
8003 }
8004
8005 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
8006         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
8007         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8008         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
8009         return (uint64_t)ret_conv;
8010 }
8011
8012 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
8013         LDKCVec_NetAddressZ _res_constr;
8014         _res_constr.datalen = *((uint32_t*)_res);
8015         if (_res_constr.datalen > 0)
8016                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
8017         else
8018                 _res_constr.data = NULL;
8019         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8020         for (size_t m = 0; m < _res_constr.datalen; m++) {
8021                 uint32_t _res_conv_12 = _res_vals[m];
8022                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
8023                 FREE((void*)_res_conv_12);
8024                 _res_constr.data[m] = _res_conv_12_conv;
8025         }
8026         CVec_NetAddressZ_free(_res_constr);
8027 }
8028
8029 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
8030         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
8031         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
8032         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
8033         return (uint64_t)ret_ref;
8034 }
8035
8036 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
8037         LDKThirtyTwoBytes a_ref;
8038         CHECK(*((uint32_t*)a) == 32);
8039         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8040         LDKThirtyTwoBytes b_ref;
8041         CHECK(*((uint32_t*)b) == 32);
8042         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
8043         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
8044         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
8045         return (uint64_t)ret_ref;
8046 }
8047
8048 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
8049         if ((_res & 1) != 0) return;
8050         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
8051         FREE((void*)_res);
8052         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
8053 }
8054
8055 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
8056         LDKThirtyTwoBytes o_ref;
8057         CHECK(*((uint32_t*)o) == 32);
8058         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
8059         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8060         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
8061         return (uint64_t)ret_conv;
8062 }
8063
8064 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
8065         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
8066         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8067         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
8068         return (uint64_t)ret_conv;
8069 }
8070
8071 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
8072         if ((_res & 1) != 0) return;
8073         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
8074         FREE((void*)_res);
8075         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
8076 }
8077
8078 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
8079         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
8080         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8081         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
8082         return (uint64_t)ret_conv;
8083 }
8084
8085 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
8086         LDKCVec_ChannelMonitorZ _res_constr;
8087         _res_constr.datalen = *((uint32_t*)_res);
8088         if (_res_constr.datalen > 0)
8089                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
8090         else
8091                 _res_constr.data = NULL;
8092         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8093         for (size_t q = 0; q < _res_constr.datalen; q++) {
8094                 uint32_t _res_conv_16 = _res_vals[q];
8095                 LDKChannelMonitor _res_conv_16_conv;
8096                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8097                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8098                 _res_constr.data[q] = _res_conv_16_conv;
8099         }
8100         CVec_ChannelMonitorZ_free(_res_constr);
8101 }
8102
8103 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
8104         LDKThirtyTwoBytes a_ref;
8105         CHECK(*((uint32_t*)a) == 32);
8106         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8107         LDKChannelManager b_conv;
8108         b_conv.inner = (void*)(b & (~1));
8109         b_conv.is_owned = (b & 1) || (b == 0);
8110         // Warning: we need a move here but no clone is available for LDKChannelManager
8111         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
8112         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
8113         return (uint64_t)ret_ref;
8114 }
8115
8116 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
8117         if ((_res & 1) != 0) return;
8118         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
8119         FREE((void*)_res);
8120         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
8121 }
8122
8123 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
8124         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
8125         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8126         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
8127         return (uint64_t)ret_conv;
8128 }
8129
8130 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
8131         LDKDecodeError e_conv;
8132         e_conv.inner = (void*)(e & (~1));
8133         e_conv.is_owned = (e & 1) || (e == 0);
8134         e_conv = DecodeError_clone(&e_conv);
8135         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8136         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
8137         return (uint64_t)ret_conv;
8138 }
8139
8140 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
8141         if ((_res & 1) != 0) return;
8142         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8143         FREE((void*)_res);
8144         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
8145 }
8146
8147 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
8148         LDKChannelConfig o_conv;
8149         o_conv.inner = (void*)(o & (~1));
8150         o_conv.is_owned = (o & 1) || (o == 0);
8151         o_conv = ChannelConfig_clone(&o_conv);
8152         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8153         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
8154         return (uint64_t)ret_conv;
8155 }
8156
8157 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
8158         LDKDecodeError e_conv;
8159         e_conv.inner = (void*)(e & (~1));
8160         e_conv.is_owned = (e & 1) || (e == 0);
8161         e_conv = DecodeError_clone(&e_conv);
8162         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8163         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
8164         return (uint64_t)ret_conv;
8165 }
8166
8167 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
8168         if ((_res & 1) != 0) return;
8169         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
8170         FREE((void*)_res);
8171         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
8172 }
8173
8174 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
8175         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
8176         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8177         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
8178         return (uint64_t)ret_conv;
8179 }
8180
8181 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
8182         LDKOutPoint o_conv;
8183         o_conv.inner = (void*)(o & (~1));
8184         o_conv.is_owned = (o & 1) || (o == 0);
8185         o_conv = OutPoint_clone(&o_conv);
8186         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8187         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
8188         return (uint64_t)ret_conv;
8189 }
8190
8191 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
8192         LDKDecodeError e_conv;
8193         e_conv.inner = (void*)(e & (~1));
8194         e_conv.is_owned = (e & 1) || (e == 0);
8195         e_conv = DecodeError_clone(&e_conv);
8196         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8197         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
8198         return (uint64_t)ret_conv;
8199 }
8200
8201 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
8202         if ((_res & 1) != 0) return;
8203         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
8204         FREE((void*)_res);
8205         CResult_OutPointDecodeErrorZ_free(_res_conv);
8206 }
8207
8208 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
8209         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
8210         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8211         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
8212         return (uint64_t)ret_conv;
8213 }
8214
8215 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
8216         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
8217         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8218         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
8219         return (uint64_t)ret_conv;
8220 }
8221
8222 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err() {
8223         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8224         *ret_conv = CResult_SiPrefixNoneZ_err();
8225         return (uint64_t)ret_conv;
8226 }
8227
8228 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
8229         if ((_res & 1) != 0) return;
8230         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
8231         FREE((void*)_res);
8232         CResult_SiPrefixNoneZ_free(_res_conv);
8233 }
8234
8235 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
8236         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
8237         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8238         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
8239         return (uint64_t)ret_conv;
8240 }
8241
8242 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
8243         LDKInvoice o_conv;
8244         o_conv.inner = (void*)(o & (~1));
8245         o_conv.is_owned = (o & 1) || (o == 0);
8246         o_conv = Invoice_clone(&o_conv);
8247         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8248         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
8249         return (uint64_t)ret_conv;
8250 }
8251
8252 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
8253         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8254         *ret_conv = CResult_InvoiceNoneZ_err();
8255         return (uint64_t)ret_conv;
8256 }
8257
8258 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
8259         if ((_res & 1) != 0) return;
8260         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
8261         FREE((void*)_res);
8262         CResult_InvoiceNoneZ_free(_res_conv);
8263 }
8264
8265 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
8266         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
8267         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8268         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
8269         return (uint64_t)ret_conv;
8270 }
8271
8272 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
8273         LDKSignedRawInvoice o_conv;
8274         o_conv.inner = (void*)(o & (~1));
8275         o_conv.is_owned = (o & 1) || (o == 0);
8276         o_conv = SignedRawInvoice_clone(&o_conv);
8277         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8278         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
8279         return (uint64_t)ret_conv;
8280 }
8281
8282 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
8283         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8284         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
8285         return (uint64_t)ret_conv;
8286 }
8287
8288 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
8289         if ((_res & 1) != 0) return;
8290         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
8291         FREE((void*)_res);
8292         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
8293 }
8294
8295 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
8296         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
8297         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8298         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
8299         return (uint64_t)ret_conv;
8300 }
8301
8302 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
8303         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
8304         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
8305         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
8306         return (uint64_t)ret_ref;
8307 }
8308
8309 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
8310         LDKRawInvoice a_conv;
8311         a_conv.inner = (void*)(a & (~1));
8312         a_conv.is_owned = (a & 1) || (a == 0);
8313         a_conv = RawInvoice_clone(&a_conv);
8314         LDKThirtyTwoBytes b_ref;
8315         CHECK(*((uint32_t*)b) == 32);
8316         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
8317         LDKInvoiceSignature c_conv;
8318         c_conv.inner = (void*)(c & (~1));
8319         c_conv.is_owned = (c & 1) || (c == 0);
8320         c_conv = InvoiceSignature_clone(&c_conv);
8321         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
8322         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
8323         return (uint64_t)ret_ref;
8324 }
8325
8326 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
8327         if ((_res & 1) != 0) return;
8328         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
8329         FREE((void*)_res);
8330         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
8331 }
8332
8333 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
8334         LDKPayeePubKey o_conv;
8335         o_conv.inner = (void*)(o & (~1));
8336         o_conv.is_owned = (o & 1) || (o == 0);
8337         o_conv = PayeePubKey_clone(&o_conv);
8338         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8339         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
8340         return (uint64_t)ret_conv;
8341 }
8342
8343 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
8344         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8345         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8346         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
8347         return (uint64_t)ret_conv;
8348 }
8349
8350 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
8351         if ((_res & 1) != 0) return;
8352         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
8353         FREE((void*)_res);
8354         CResult_PayeePubKeyErrorZ_free(_res_conv);
8355 }
8356
8357 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
8358         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
8359         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8360         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
8361         return (uint64_t)ret_conv;
8362 }
8363
8364 void  __attribute__((visibility("default"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
8365         LDKCVec_PrivateRouteZ _res_constr;
8366         _res_constr.datalen = *((uint32_t*)_res);
8367         if (_res_constr.datalen > 0)
8368                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
8369         else
8370                 _res_constr.data = NULL;
8371         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8372         for (size_t o = 0; o < _res_constr.datalen; o++) {
8373                 uint32_t _res_conv_14 = _res_vals[o];
8374                 LDKPrivateRoute _res_conv_14_conv;
8375                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
8376                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
8377                 _res_constr.data[o] = _res_conv_14_conv;
8378         }
8379         CVec_PrivateRouteZ_free(_res_constr);
8380 }
8381
8382 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
8383         LDKPositiveTimestamp o_conv;
8384         o_conv.inner = (void*)(o & (~1));
8385         o_conv.is_owned = (o & 1) || (o == 0);
8386         o_conv = PositiveTimestamp_clone(&o_conv);
8387         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8388         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
8389         return (uint64_t)ret_conv;
8390 }
8391
8392 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
8393         LDKCreationError e_conv = LDKCreationError_from_js(e);
8394         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8395         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
8396         return (uint64_t)ret_conv;
8397 }
8398
8399 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
8400         if ((_res & 1) != 0) return;
8401         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
8402         FREE((void*)_res);
8403         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
8404 }
8405
8406 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
8407         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
8408         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8409         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
8410         return (uint64_t)ret_conv;
8411 }
8412
8413 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_ok() {
8414         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8415         *ret_conv = CResult_NoneSemanticErrorZ_ok();
8416         return (uint64_t)ret_conv;
8417 }
8418
8419 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
8420         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
8421         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8422         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
8423         return (uint64_t)ret_conv;
8424 }
8425
8426 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
8427         if ((_res & 1) != 0) return;
8428         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
8429         FREE((void*)_res);
8430         CResult_NoneSemanticErrorZ_free(_res_conv);
8431 }
8432
8433 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
8434         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
8435         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8436         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
8437         return (uint64_t)ret_conv;
8438 }
8439
8440 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
8441         LDKInvoice o_conv;
8442         o_conv.inner = (void*)(o & (~1));
8443         o_conv.is_owned = (o & 1) || (o == 0);
8444         o_conv = Invoice_clone(&o_conv);
8445         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8446         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
8447         return (uint64_t)ret_conv;
8448 }
8449
8450 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
8451         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
8452         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8453         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
8454         return (uint64_t)ret_conv;
8455 }
8456
8457 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
8458         if ((_res & 1) != 0) return;
8459         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
8460         FREE((void*)_res);
8461         CResult_InvoiceSemanticErrorZ_free(_res_conv);
8462 }
8463
8464 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
8465         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
8466         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8467         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
8468         return (uint64_t)ret_conv;
8469 }
8470
8471 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
8472         LDKDescription o_conv;
8473         o_conv.inner = (void*)(o & (~1));
8474         o_conv.is_owned = (o & 1) || (o == 0);
8475         o_conv = Description_clone(&o_conv);
8476         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8477         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
8478         return (uint64_t)ret_conv;
8479 }
8480
8481 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
8482         LDKCreationError e_conv = LDKCreationError_from_js(e);
8483         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8484         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
8485         return (uint64_t)ret_conv;
8486 }
8487
8488 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
8489         if ((_res & 1) != 0) return;
8490         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
8491         FREE((void*)_res);
8492         CResult_DescriptionCreationErrorZ_free(_res_conv);
8493 }
8494
8495 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
8496         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
8497         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8498         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
8499         return (uint64_t)ret_conv;
8500 }
8501
8502 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_ok(uint32_t o) {
8503         LDKExpiryTime o_conv;
8504         o_conv.inner = (void*)(o & (~1));
8505         o_conv.is_owned = (o & 1) || (o == 0);
8506         o_conv = ExpiryTime_clone(&o_conv);
8507         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8508         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
8509         return (uint64_t)ret_conv;
8510 }
8511
8512 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_err(uint32_t e) {
8513         LDKCreationError e_conv = LDKCreationError_from_js(e);
8514         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8515         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
8516         return (uint64_t)ret_conv;
8517 }
8518
8519 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
8520         if ((_res & 1) != 0) return;
8521         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
8522         FREE((void*)_res);
8523         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
8524 }
8525
8526 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone(uint32_t orig) {
8527         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
8528         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8529         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
8530         return (uint64_t)ret_conv;
8531 }
8532
8533 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
8534         LDKPrivateRoute o_conv;
8535         o_conv.inner = (void*)(o & (~1));
8536         o_conv.is_owned = (o & 1) || (o == 0);
8537         o_conv = PrivateRoute_clone(&o_conv);
8538         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8539         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
8540         return (uint64_t)ret_conv;
8541 }
8542
8543 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
8544         LDKCreationError e_conv = LDKCreationError_from_js(e);
8545         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8546         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
8547         return (uint64_t)ret_conv;
8548 }
8549
8550 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
8551         if ((_res & 1) != 0) return;
8552         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
8553         FREE((void*)_res);
8554         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
8555 }
8556
8557 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
8558         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
8559         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8560         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
8561         return (uint64_t)ret_conv;
8562 }
8563
8564 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_ok(jstring o) {
8565         LDKStr o_conv = str_ref_to_owned_c(o);
8566         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
8567         *ret_conv = CResult_StringErrorZ_ok(o_conv);
8568         return (uint64_t)ret_conv;
8569 }
8570
8571 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uint32_t e) {
8572         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8573         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
8574         *ret_conv = CResult_StringErrorZ_err(e_conv);
8575         return (uint64_t)ret_conv;
8576 }
8577
8578 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
8579         if ((_res & 1) != 0) return;
8580         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
8581         FREE((void*)_res);
8582         CResult_StringErrorZ_free(_res_conv);
8583 }
8584
8585 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
8586         LDKChannelMonitorUpdate o_conv;
8587         o_conv.inner = (void*)(o & (~1));
8588         o_conv.is_owned = (o & 1) || (o == 0);
8589         o_conv = ChannelMonitorUpdate_clone(&o_conv);
8590         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8591         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
8592         return (uint64_t)ret_conv;
8593 }
8594
8595 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
8596         LDKDecodeError e_conv;
8597         e_conv.inner = (void*)(e & (~1));
8598         e_conv.is_owned = (e & 1) || (e == 0);
8599         e_conv = DecodeError_clone(&e_conv);
8600         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8601         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
8602         return (uint64_t)ret_conv;
8603 }
8604
8605 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
8606         if ((_res & 1) != 0) return;
8607         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8608         FREE((void*)_res);
8609         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
8610 }
8611
8612 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
8613         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
8614         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8615         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
8616         return (uint64_t)ret_conv;
8617 }
8618
8619 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
8620         LDKHTLCUpdate o_conv;
8621         o_conv.inner = (void*)(o & (~1));
8622         o_conv.is_owned = (o & 1) || (o == 0);
8623         o_conv = HTLCUpdate_clone(&o_conv);
8624         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8625         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
8626         return (uint64_t)ret_conv;
8627 }
8628
8629 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
8630         LDKDecodeError e_conv;
8631         e_conv.inner = (void*)(e & (~1));
8632         e_conv.is_owned = (e & 1) || (e == 0);
8633         e_conv = DecodeError_clone(&e_conv);
8634         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8635         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
8636         return (uint64_t)ret_conv;
8637 }
8638
8639 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
8640         if ((_res & 1) != 0) return;
8641         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8642         FREE((void*)_res);
8643         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
8644 }
8645
8646 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
8647         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
8648         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8649         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
8650         return (uint64_t)ret_conv;
8651 }
8652
8653 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
8654         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8655         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
8656         return (uint64_t)ret_conv;
8657 }
8658
8659 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
8660         LDKMonitorUpdateError e_conv;
8661         e_conv.inner = (void*)(e & (~1));
8662         e_conv.is_owned = (e & 1) || (e == 0);
8663         e_conv = MonitorUpdateError_clone(&e_conv);
8664         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8665         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
8666         return (uint64_t)ret_conv;
8667 }
8668
8669 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
8670         if ((_res & 1) != 0) return;
8671         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
8672         FREE((void*)_res);
8673         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
8674 }
8675
8676 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
8677         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
8678         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8679         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
8680         return (uint64_t)ret_conv;
8681 }
8682
8683 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
8684         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
8685         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
8686         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
8687         return (uint64_t)ret_ref;
8688 }
8689
8690 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
8691         LDKOutPoint a_conv;
8692         a_conv.inner = (void*)(a & (~1));
8693         a_conv.is_owned = (a & 1) || (a == 0);
8694         a_conv = OutPoint_clone(&a_conv);
8695         LDKCVec_u8Z b_ref;
8696         b_ref.datalen = *((uint32_t*)b);
8697         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
8698         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
8699         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
8700         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
8701         return (uint64_t)ret_ref;
8702 }
8703
8704 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
8705         if ((_res & 1) != 0) return;
8706         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
8707         FREE((void*)_res);
8708         C2Tuple_OutPointScriptZ_free(_res_conv);
8709 }
8710
8711 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
8712         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
8713         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8714         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
8715         return (uint64_t)ret_ref;
8716 }
8717
8718 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
8719         LDKCVec_u8Z b_ref;
8720         b_ref.datalen = *((uint32_t*)b);
8721         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
8722         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
8723         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8724         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
8725         return (uint64_t)ret_ref;
8726 }
8727
8728 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
8729         if ((_res & 1) != 0) return;
8730         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
8731         FREE((void*)_res);
8732         C2Tuple_u32ScriptZ_free(_res_conv);
8733 }
8734
8735 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
8736         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
8737         _res_constr.datalen = *((uint32_t*)_res);
8738         if (_res_constr.datalen > 0)
8739                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
8740         else
8741                 _res_constr.data = NULL;
8742         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8743         for (size_t e = 0; e < _res_constr.datalen; e++) {
8744                 uint32_t _res_conv_30 = _res_vals[e];
8745                 LDKC2Tuple_u32ScriptZ _res_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_30) & ~1);
8746                 FREE((void*)_res_conv_30);
8747                 _res_constr.data[e] = _res_conv_30_conv;
8748         }
8749         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
8750 }
8751
8752 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
8753         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
8754         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
8755         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
8756         return (uint64_t)ret_ref;
8757 }
8758
8759 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
8760         LDKThirtyTwoBytes a_ref;
8761         CHECK(*((uint32_t*)a) == 32);
8762         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8763         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
8764         b_constr.datalen = *((uint32_t*)b);
8765         if (b_constr.datalen > 0)
8766                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
8767         else
8768                 b_constr.data = NULL;
8769         uint32_t* b_vals = (uint32_t*)(b + 4);
8770         for (size_t e = 0; e < b_constr.datalen; e++) {
8771                 uint32_t b_conv_30 = b_vals[e];
8772                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
8773                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
8774                 b_constr.data[e] = b_conv_30_conv;
8775         }
8776         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
8777         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
8778         return (uint64_t)ret_ref;
8779 }
8780
8781 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
8782         if ((_res & 1) != 0) return;
8783         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
8784         FREE((void*)_res);
8785         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
8786 }
8787
8788 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
8789         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
8790         _res_constr.datalen = *((uint32_t*)_res);
8791         if (_res_constr.datalen > 0)
8792                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
8793         else
8794                 _res_constr.data = NULL;
8795         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8796         for (size_t c = 0; c < _res_constr.datalen; c++) {
8797                 uint32_t _res_conv_54 = _res_vals[c];
8798                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_54_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_54) & ~1);
8799                 FREE((void*)_res_conv_54);
8800                 _res_constr.data[c] = _res_conv_54_conv;
8801         }
8802         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
8803 }
8804
8805 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
8806         LDKCVec_EventZ _res_constr;
8807         _res_constr.datalen = *((uint32_t*)_res);
8808         if (_res_constr.datalen > 0)
8809                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
8810         else
8811                 _res_constr.data = NULL;
8812         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8813         for (size_t h = 0; h < _res_constr.datalen; h++) {
8814                 uint32_t _res_conv_7 = _res_vals[h];
8815                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
8816                 FREE((void*)_res_conv_7);
8817                 _res_constr.data[h] = _res_conv_7_conv;
8818         }
8819         CVec_EventZ_free(_res_constr);
8820 }
8821
8822 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
8823         LDKCVec_TransactionZ _res_constr;
8824         _res_constr.datalen = *((uint32_t*)_res);
8825         if (_res_constr.datalen > 0)
8826                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
8827         else
8828                 _res_constr.data = NULL;
8829         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8830         for (size_t m = 0; m < _res_constr.datalen; m++) {
8831                 int8_tArray _res_conv_12 = _res_vals[m];
8832                 LDKTransaction _res_conv_12_ref;
8833                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
8834                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
8835                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
8836                 _res_conv_12_ref.data_is_owned = true;
8837                 _res_constr.data[m] = _res_conv_12_ref;
8838         }
8839         CVec_TransactionZ_free(_res_constr);
8840 }
8841
8842 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
8843         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
8844         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8845         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
8846         return (uint64_t)ret_ref;
8847 }
8848
8849 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
8850         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
8851         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8852         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
8853         return (uint64_t)ret_ref;
8854 }
8855
8856 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
8857         if ((_res & 1) != 0) return;
8858         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
8859         FREE((void*)_res);
8860         C2Tuple_u32TxOutZ_free(_res_conv);
8861 }
8862
8863 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
8864         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
8865         _res_constr.datalen = *((uint32_t*)_res);
8866         if (_res_constr.datalen > 0)
8867                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
8868         else
8869                 _res_constr.data = NULL;
8870         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8871         for (size_t z = 0; z < _res_constr.datalen; z++) {
8872                 uint32_t _res_conv_25 = _res_vals[z];
8873                 LDKC2Tuple_u32TxOutZ _res_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_25) & ~1);
8874                 FREE((void*)_res_conv_25);
8875                 _res_constr.data[z] = _res_conv_25_conv;
8876         }
8877         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
8878 }
8879
8880 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
8881         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
8882         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
8883         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
8884         return (uint64_t)ret_ref;
8885 }
8886
8887 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
8888         LDKThirtyTwoBytes a_ref;
8889         CHECK(*((uint32_t*)a) == 32);
8890         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8891         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
8892         b_constr.datalen = *((uint32_t*)b);
8893         if (b_constr.datalen > 0)
8894                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
8895         else
8896                 b_constr.data = NULL;
8897         uint32_t* b_vals = (uint32_t*)(b + 4);
8898         for (size_t z = 0; z < b_constr.datalen; z++) {
8899                 uint32_t b_conv_25 = b_vals[z];
8900                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
8901                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
8902                 b_constr.data[z] = b_conv_25_conv;
8903         }
8904         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
8905         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
8906         return (uint64_t)ret_ref;
8907 }
8908
8909 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
8910         if ((_res & 1) != 0) return;
8911         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
8912         FREE((void*)_res);
8913         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
8914 }
8915
8916 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
8917         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
8918         _res_constr.datalen = *((uint32_t*)_res);
8919         if (_res_constr.datalen > 0)
8920                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
8921         else
8922                 _res_constr.data = NULL;
8923         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8924         for (size_t x = 0; x < _res_constr.datalen; x++) {
8925                 uint32_t _res_conv_49 = _res_vals[x];
8926                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_49) & ~1);
8927                 FREE((void*)_res_conv_49);
8928                 _res_constr.data[x] = _res_conv_49_conv;
8929         }
8930         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
8931 }
8932
8933 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
8934         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
8935         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
8936         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
8937         return (uint64_t)ret_conv;
8938 }
8939
8940 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
8941         LDKDecodeError e_conv;
8942         e_conv.inner = (void*)(e & (~1));
8943         e_conv.is_owned = (e & 1) || (e == 0);
8944         e_conv = DecodeError_clone(&e_conv);
8945         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
8946         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
8947         return (uint64_t)ret_conv;
8948 }
8949
8950 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
8951         if ((_res & 1) != 0) return;
8952         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8953         FREE((void*)_res);
8954         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
8955 }
8956
8957 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
8958         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8959         *ret_conv = CResult_boolLightningErrorZ_ok(o);
8960         return (uint64_t)ret_conv;
8961 }
8962
8963 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
8964         LDKLightningError e_conv;
8965         e_conv.inner = (void*)(e & (~1));
8966         e_conv.is_owned = (e & 1) || (e == 0);
8967         e_conv = LightningError_clone(&e_conv);
8968         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8969         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
8970         return (uint64_t)ret_conv;
8971 }
8972
8973 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
8974         if ((_res & 1) != 0) return;
8975         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
8976         FREE((void*)_res);
8977         CResult_boolLightningErrorZ_free(_res_conv);
8978 }
8979
8980 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
8981         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
8982         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8983         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
8984         return (uint64_t)ret_conv;
8985 }
8986
8987 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
8988         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
8989         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8990         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
8991         return (uint64_t)ret_ref;
8992 }
8993
8994 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
8995         LDKChannelAnnouncement a_conv;
8996         a_conv.inner = (void*)(a & (~1));
8997         a_conv.is_owned = (a & 1) || (a == 0);
8998         a_conv = ChannelAnnouncement_clone(&a_conv);
8999         LDKChannelUpdate b_conv;
9000         b_conv.inner = (void*)(b & (~1));
9001         b_conv.is_owned = (b & 1) || (b == 0);
9002         b_conv = ChannelUpdate_clone(&b_conv);
9003         LDKChannelUpdate c_conv;
9004         c_conv.inner = (void*)(c & (~1));
9005         c_conv.is_owned = (c & 1) || (c == 0);
9006         c_conv = ChannelUpdate_clone(&c_conv);
9007         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9008         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
9009         return (uint64_t)ret_ref;
9010 }
9011
9012 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
9013         if ((_res & 1) != 0) return;
9014         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
9015         FREE((void*)_res);
9016         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
9017 }
9018
9019 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
9020         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
9021         _res_constr.datalen = *((uint32_t*)_res);
9022         if (_res_constr.datalen > 0)
9023                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9024         else
9025                 _res_constr.data = NULL;
9026         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9027         for (size_t l = 0; l < _res_constr.datalen; l++) {
9028                 uint32_t _res_conv_63 = _res_vals[l];
9029                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
9030                 FREE((void*)_res_conv_63);
9031                 _res_constr.data[l] = _res_conv_63_conv;
9032         }
9033         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
9034 }
9035
9036 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
9037         LDKCVec_NodeAnnouncementZ _res_constr;
9038         _res_constr.datalen = *((uint32_t*)_res);
9039         if (_res_constr.datalen > 0)
9040                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9041         else
9042                 _res_constr.data = NULL;
9043         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9044         for (size_t s = 0; s < _res_constr.datalen; s++) {
9045                 uint32_t _res_conv_18 = _res_vals[s];
9046                 LDKNodeAnnouncement _res_conv_18_conv;
9047                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
9048                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
9049                 _res_constr.data[s] = _res_conv_18_conv;
9050         }
9051         CVec_NodeAnnouncementZ_free(_res_constr);
9052 }
9053
9054 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
9055         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9056         *ret_conv = CResult_NoneLightningErrorZ_ok();
9057         return (uint64_t)ret_conv;
9058 }
9059
9060 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
9061         LDKLightningError e_conv;
9062         e_conv.inner = (void*)(e & (~1));
9063         e_conv.is_owned = (e & 1) || (e == 0);
9064         e_conv = LightningError_clone(&e_conv);
9065         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9066         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
9067         return (uint64_t)ret_conv;
9068 }
9069
9070 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
9071         if ((_res & 1) != 0) return;
9072         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
9073         FREE((void*)_res);
9074         CResult_NoneLightningErrorZ_free(_res_conv);
9075 }
9076
9077 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
9078         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
9079         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9080         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
9081         return (uint64_t)ret_conv;
9082 }
9083
9084 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
9085         LDKCVec_PublicKeyZ _res_constr;
9086         _res_constr.datalen = *((uint32_t*)_res);
9087         if (_res_constr.datalen > 0)
9088                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
9089         else
9090                 _res_constr.data = NULL;
9091         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
9092         for (size_t m = 0; m < _res_constr.datalen; m++) {
9093                 int8_tArray _res_conv_12 = _res_vals[m];
9094                 LDKPublicKey _res_conv_12_ref;
9095                 CHECK(*((uint32_t*)_res_conv_12) == 33);
9096                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
9097                 _res_constr.data[m] = _res_conv_12_ref;
9098         }
9099         CVec_PublicKeyZ_free(_res_constr);
9100 }
9101
9102 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
9103         LDKCVec_u8Z o_ref;
9104         o_ref.datalen = *((uint32_t*)o);
9105         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
9106         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
9107         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9108         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
9109         return (uint64_t)ret_conv;
9110 }
9111
9112 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
9113         LDKPeerHandleError e_conv;
9114         e_conv.inner = (void*)(e & (~1));
9115         e_conv.is_owned = (e & 1) || (e == 0);
9116         e_conv = PeerHandleError_clone(&e_conv);
9117         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9118         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
9119         return (uint64_t)ret_conv;
9120 }
9121
9122 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
9123         if ((_res & 1) != 0) return;
9124         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9125         FREE((void*)_res);
9126         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
9127 }
9128
9129 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
9130         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
9131         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9132         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
9133         return (uint64_t)ret_conv;
9134 }
9135
9136 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
9137         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9138         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
9139         return (uint64_t)ret_conv;
9140 }
9141
9142 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
9143         LDKPeerHandleError e_conv;
9144         e_conv.inner = (void*)(e & (~1));
9145         e_conv.is_owned = (e & 1) || (e == 0);
9146         e_conv = PeerHandleError_clone(&e_conv);
9147         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9148         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
9149         return (uint64_t)ret_conv;
9150 }
9151
9152 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
9153         if ((_res & 1) != 0) return;
9154         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9155         FREE((void*)_res);
9156         CResult_NonePeerHandleErrorZ_free(_res_conv);
9157 }
9158
9159 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
9160         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
9161         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9162         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
9163         return (uint64_t)ret_conv;
9164 }
9165
9166 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
9167         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9168         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
9169         return (uint64_t)ret_conv;
9170 }
9171
9172 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
9173         LDKPeerHandleError e_conv;
9174         e_conv.inner = (void*)(e & (~1));
9175         e_conv.is_owned = (e & 1) || (e == 0);
9176         e_conv = PeerHandleError_clone(&e_conv);
9177         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9178         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
9179         return (uint64_t)ret_conv;
9180 }
9181
9182 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
9183         if ((_res & 1) != 0) return;
9184         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9185         FREE((void*)_res);
9186         CResult_boolPeerHandleErrorZ_free(_res_conv);
9187 }
9188
9189 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
9190         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
9191         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9192         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
9193         return (uint64_t)ret_conv;
9194 }
9195
9196 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
9197         LDKDirectionalChannelInfo o_conv;
9198         o_conv.inner = (void*)(o & (~1));
9199         o_conv.is_owned = (o & 1) || (o == 0);
9200         o_conv = DirectionalChannelInfo_clone(&o_conv);
9201         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9202         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
9203         return (uint64_t)ret_conv;
9204 }
9205
9206 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
9207         LDKDecodeError e_conv;
9208         e_conv.inner = (void*)(e & (~1));
9209         e_conv.is_owned = (e & 1) || (e == 0);
9210         e_conv = DecodeError_clone(&e_conv);
9211         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9212         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
9213         return (uint64_t)ret_conv;
9214 }
9215
9216 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
9217         if ((_res & 1) != 0) return;
9218         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9219         FREE((void*)_res);
9220         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
9221 }
9222
9223 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
9224         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
9225         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9226         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
9227         return (uint64_t)ret_conv;
9228 }
9229
9230 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
9231         LDKChannelInfo o_conv;
9232         o_conv.inner = (void*)(o & (~1));
9233         o_conv.is_owned = (o & 1) || (o == 0);
9234         o_conv = ChannelInfo_clone(&o_conv);
9235         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9236         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
9237         return (uint64_t)ret_conv;
9238 }
9239
9240 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
9241         LDKDecodeError e_conv;
9242         e_conv.inner = (void*)(e & (~1));
9243         e_conv.is_owned = (e & 1) || (e == 0);
9244         e_conv = DecodeError_clone(&e_conv);
9245         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9246         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
9247         return (uint64_t)ret_conv;
9248 }
9249
9250 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
9251         if ((_res & 1) != 0) return;
9252         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9253         FREE((void*)_res);
9254         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
9255 }
9256
9257 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
9258         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
9259         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9260         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
9261         return (uint64_t)ret_conv;
9262 }
9263
9264 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
9265         LDKRoutingFees o_conv;
9266         o_conv.inner = (void*)(o & (~1));
9267         o_conv.is_owned = (o & 1) || (o == 0);
9268         o_conv = RoutingFees_clone(&o_conv);
9269         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9270         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
9271         return (uint64_t)ret_conv;
9272 }
9273
9274 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
9275         LDKDecodeError e_conv;
9276         e_conv.inner = (void*)(e & (~1));
9277         e_conv.is_owned = (e & 1) || (e == 0);
9278         e_conv = DecodeError_clone(&e_conv);
9279         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9280         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
9281         return (uint64_t)ret_conv;
9282 }
9283
9284 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
9285         if ((_res & 1) != 0) return;
9286         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9287         FREE((void*)_res);
9288         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
9289 }
9290
9291 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
9292         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
9293         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9294         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
9295         return (uint64_t)ret_conv;
9296 }
9297
9298 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
9299         LDKNodeAnnouncementInfo o_conv;
9300         o_conv.inner = (void*)(o & (~1));
9301         o_conv.is_owned = (o & 1) || (o == 0);
9302         o_conv = NodeAnnouncementInfo_clone(&o_conv);
9303         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9304         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
9305         return (uint64_t)ret_conv;
9306 }
9307
9308 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
9309         LDKDecodeError e_conv;
9310         e_conv.inner = (void*)(e & (~1));
9311         e_conv.is_owned = (e & 1) || (e == 0);
9312         e_conv = DecodeError_clone(&e_conv);
9313         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9314         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
9315         return (uint64_t)ret_conv;
9316 }
9317
9318 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
9319         if ((_res & 1) != 0) return;
9320         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9321         FREE((void*)_res);
9322         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
9323 }
9324
9325 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
9326         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
9327         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9328         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
9329         return (uint64_t)ret_conv;
9330 }
9331
9332 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
9333         LDKCVec_u64Z _res_constr;
9334         _res_constr.datalen = *((uint32_t*)_res);
9335         if (_res_constr.datalen > 0)
9336                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
9337         else
9338                 _res_constr.data = NULL;
9339         int64_t* _res_vals = (int64_t*)(_res + 4);
9340         for (size_t i = 0; i < _res_constr.datalen; i++) {
9341                 int64_t _res_conv_8 = _res_vals[i];
9342                 _res_constr.data[i] = _res_conv_8;
9343         }
9344         CVec_u64Z_free(_res_constr);
9345 }
9346
9347 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
9348         LDKNodeInfo o_conv;
9349         o_conv.inner = (void*)(o & (~1));
9350         o_conv.is_owned = (o & 1) || (o == 0);
9351         o_conv = NodeInfo_clone(&o_conv);
9352         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9353         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
9354         return (uint64_t)ret_conv;
9355 }
9356
9357 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
9358         LDKDecodeError e_conv;
9359         e_conv.inner = (void*)(e & (~1));
9360         e_conv.is_owned = (e & 1) || (e == 0);
9361         e_conv = DecodeError_clone(&e_conv);
9362         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9363         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
9364         return (uint64_t)ret_conv;
9365 }
9366
9367 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
9368         if ((_res & 1) != 0) return;
9369         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9370         FREE((void*)_res);
9371         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
9372 }
9373
9374 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
9375         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
9376         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9377         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
9378         return (uint64_t)ret_conv;
9379 }
9380
9381 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
9382         LDKNetworkGraph o_conv;
9383         o_conv.inner = (void*)(o & (~1));
9384         o_conv.is_owned = (o & 1) || (o == 0);
9385         o_conv = NetworkGraph_clone(&o_conv);
9386         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9387         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
9388         return (uint64_t)ret_conv;
9389 }
9390
9391 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
9392         LDKDecodeError e_conv;
9393         e_conv.inner = (void*)(e & (~1));
9394         e_conv.is_owned = (e & 1) || (e == 0);
9395         e_conv = DecodeError_clone(&e_conv);
9396         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9397         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
9398         return (uint64_t)ret_conv;
9399 }
9400
9401 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
9402         if ((_res & 1) != 0) return;
9403         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
9404         FREE((void*)_res);
9405         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
9406 }
9407
9408 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
9409         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
9410         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9411         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
9412         return (uint64_t)ret_conv;
9413 }
9414
9415 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
9416         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
9417         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9418         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
9419         return (uint64_t)ret_conv;
9420 }
9421
9422 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
9423         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9424         *ret_conv = CResult_NetAddressu8Z_err(e);
9425         return (uint64_t)ret_conv;
9426 }
9427
9428 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
9429         if ((_res & 1) != 0) return;
9430         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
9431         FREE((void*)_res);
9432         CResult_NetAddressu8Z_free(_res_conv);
9433 }
9434
9435 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
9436         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
9437         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9438         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
9439         return (uint64_t)ret_conv;
9440 }
9441
9442 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
9443         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
9444         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9445         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
9446         return (uint64_t)ret_conv;
9447 }
9448
9449 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
9450         LDKDecodeError e_conv;
9451         e_conv.inner = (void*)(e & (~1));
9452         e_conv.is_owned = (e & 1) || (e == 0);
9453         e_conv = DecodeError_clone(&e_conv);
9454         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9455         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
9456         return (uint64_t)ret_conv;
9457 }
9458
9459 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
9460         if ((_res & 1) != 0) return;
9461         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9462         FREE((void*)_res);
9463         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
9464 }
9465
9466 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
9467         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
9468         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9469         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
9470         return (uint64_t)ret_conv;
9471 }
9472
9473 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
9474         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
9475         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9476         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
9477         return (uint64_t)ret_conv;
9478 }
9479
9480 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
9481         LDKDecodeError e_conv;
9482         e_conv.inner = (void*)(e & (~1));
9483         e_conv.is_owned = (e & 1) || (e == 0);
9484         e_conv = DecodeError_clone(&e_conv);
9485         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9486         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
9487         return (uint64_t)ret_conv;
9488 }
9489
9490 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
9491         if ((_res & 1) != 0) return;
9492         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
9493         FREE((void*)_res);
9494         CResult_NetAddressDecodeErrorZ_free(_res_conv);
9495 }
9496
9497 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
9498         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
9499         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9500         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
9501         return (uint64_t)ret_conv;
9502 }
9503
9504 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
9505         LDKCVec_UpdateAddHTLCZ _res_constr;
9506         _res_constr.datalen = *((uint32_t*)_res);
9507         if (_res_constr.datalen > 0)
9508                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
9509         else
9510                 _res_constr.data = NULL;
9511         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9512         for (size_t p = 0; p < _res_constr.datalen; p++) {
9513                 uint32_t _res_conv_15 = _res_vals[p];
9514                 LDKUpdateAddHTLC _res_conv_15_conv;
9515                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
9516                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
9517                 _res_constr.data[p] = _res_conv_15_conv;
9518         }
9519         CVec_UpdateAddHTLCZ_free(_res_constr);
9520 }
9521
9522 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
9523         LDKCVec_UpdateFulfillHTLCZ _res_constr;
9524         _res_constr.datalen = *((uint32_t*)_res);
9525         if (_res_constr.datalen > 0)
9526                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
9527         else
9528                 _res_constr.data = NULL;
9529         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9530         for (size_t t = 0; t < _res_constr.datalen; t++) {
9531                 uint32_t _res_conv_19 = _res_vals[t];
9532                 LDKUpdateFulfillHTLC _res_conv_19_conv;
9533                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
9534                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
9535                 _res_constr.data[t] = _res_conv_19_conv;
9536         }
9537         CVec_UpdateFulfillHTLCZ_free(_res_constr);
9538 }
9539
9540 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
9541         LDKCVec_UpdateFailHTLCZ _res_constr;
9542         _res_constr.datalen = *((uint32_t*)_res);
9543         if (_res_constr.datalen > 0)
9544                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
9545         else
9546                 _res_constr.data = NULL;
9547         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9548         for (size_t q = 0; q < _res_constr.datalen; q++) {
9549                 uint32_t _res_conv_16 = _res_vals[q];
9550                 LDKUpdateFailHTLC _res_conv_16_conv;
9551                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9552                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9553                 _res_constr.data[q] = _res_conv_16_conv;
9554         }
9555         CVec_UpdateFailHTLCZ_free(_res_constr);
9556 }
9557
9558 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
9559         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
9560         _res_constr.datalen = *((uint32_t*)_res);
9561         if (_res_constr.datalen > 0)
9562                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
9563         else
9564                 _res_constr.data = NULL;
9565         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9566         for (size_t z = 0; z < _res_constr.datalen; z++) {
9567                 uint32_t _res_conv_25 = _res_vals[z];
9568                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
9569                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
9570                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
9571                 _res_constr.data[z] = _res_conv_25_conv;
9572         }
9573         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
9574 }
9575
9576 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
9577         LDKAcceptChannel o_conv;
9578         o_conv.inner = (void*)(o & (~1));
9579         o_conv.is_owned = (o & 1) || (o == 0);
9580         o_conv = AcceptChannel_clone(&o_conv);
9581         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9582         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
9583         return (uint64_t)ret_conv;
9584 }
9585
9586 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
9587         LDKDecodeError e_conv;
9588         e_conv.inner = (void*)(e & (~1));
9589         e_conv.is_owned = (e & 1) || (e == 0);
9590         e_conv = DecodeError_clone(&e_conv);
9591         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9592         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
9593         return (uint64_t)ret_conv;
9594 }
9595
9596 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
9597         if ((_res & 1) != 0) return;
9598         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9599         FREE((void*)_res);
9600         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
9601 }
9602
9603 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
9604         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
9605         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9606         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
9607         return (uint64_t)ret_conv;
9608 }
9609
9610 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
9611         LDKAnnouncementSignatures o_conv;
9612         o_conv.inner = (void*)(o & (~1));
9613         o_conv.is_owned = (o & 1) || (o == 0);
9614         o_conv = AnnouncementSignatures_clone(&o_conv);
9615         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9616         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
9617         return (uint64_t)ret_conv;
9618 }
9619
9620 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
9621         LDKDecodeError e_conv;
9622         e_conv.inner = (void*)(e & (~1));
9623         e_conv.is_owned = (e & 1) || (e == 0);
9624         e_conv = DecodeError_clone(&e_conv);
9625         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9626         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
9627         return (uint64_t)ret_conv;
9628 }
9629
9630 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
9631         if ((_res & 1) != 0) return;
9632         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9633         FREE((void*)_res);
9634         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
9635 }
9636
9637 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
9638         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
9639         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9640         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
9641         return (uint64_t)ret_conv;
9642 }
9643
9644 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
9645         LDKChannelReestablish o_conv;
9646         o_conv.inner = (void*)(o & (~1));
9647         o_conv.is_owned = (o & 1) || (o == 0);
9648         o_conv = ChannelReestablish_clone(&o_conv);
9649         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9650         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
9651         return (uint64_t)ret_conv;
9652 }
9653
9654 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
9655         LDKDecodeError e_conv;
9656         e_conv.inner = (void*)(e & (~1));
9657         e_conv.is_owned = (e & 1) || (e == 0);
9658         e_conv = DecodeError_clone(&e_conv);
9659         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9660         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
9661         return (uint64_t)ret_conv;
9662 }
9663
9664 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
9665         if ((_res & 1) != 0) return;
9666         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
9667         FREE((void*)_res);
9668         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
9669 }
9670
9671 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
9672         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
9673         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9674         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
9675         return (uint64_t)ret_conv;
9676 }
9677
9678 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
9679         LDKClosingSigned o_conv;
9680         o_conv.inner = (void*)(o & (~1));
9681         o_conv.is_owned = (o & 1) || (o == 0);
9682         o_conv = ClosingSigned_clone(&o_conv);
9683         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9684         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
9685         return (uint64_t)ret_conv;
9686 }
9687
9688 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
9689         LDKDecodeError e_conv;
9690         e_conv.inner = (void*)(e & (~1));
9691         e_conv.is_owned = (e & 1) || (e == 0);
9692         e_conv = DecodeError_clone(&e_conv);
9693         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9694         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
9695         return (uint64_t)ret_conv;
9696 }
9697
9698 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
9699         if ((_res & 1) != 0) return;
9700         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9701         FREE((void*)_res);
9702         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
9703 }
9704
9705 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
9706         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
9707         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9708         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
9709         return (uint64_t)ret_conv;
9710 }
9711
9712 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
9713         LDKCommitmentSigned o_conv;
9714         o_conv.inner = (void*)(o & (~1));
9715         o_conv.is_owned = (o & 1) || (o == 0);
9716         o_conv = CommitmentSigned_clone(&o_conv);
9717         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9718         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
9719         return (uint64_t)ret_conv;
9720 }
9721
9722 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
9723         LDKDecodeError e_conv;
9724         e_conv.inner = (void*)(e & (~1));
9725         e_conv.is_owned = (e & 1) || (e == 0);
9726         e_conv = DecodeError_clone(&e_conv);
9727         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9728         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
9729         return (uint64_t)ret_conv;
9730 }
9731
9732 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
9733         if ((_res & 1) != 0) return;
9734         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9735         FREE((void*)_res);
9736         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
9737 }
9738
9739 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
9740         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
9741         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9742         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
9743         return (uint64_t)ret_conv;
9744 }
9745
9746 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
9747         LDKFundingCreated o_conv;
9748         o_conv.inner = (void*)(o & (~1));
9749         o_conv.is_owned = (o & 1) || (o == 0);
9750         o_conv = FundingCreated_clone(&o_conv);
9751         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9752         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
9753         return (uint64_t)ret_conv;
9754 }
9755
9756 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
9757         LDKDecodeError e_conv;
9758         e_conv.inner = (void*)(e & (~1));
9759         e_conv.is_owned = (e & 1) || (e == 0);
9760         e_conv = DecodeError_clone(&e_conv);
9761         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9762         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
9763         return (uint64_t)ret_conv;
9764 }
9765
9766 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
9767         if ((_res & 1) != 0) return;
9768         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9769         FREE((void*)_res);
9770         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
9771 }
9772
9773 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
9774         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
9775         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9776         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
9777         return (uint64_t)ret_conv;
9778 }
9779
9780 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
9781         LDKFundingSigned o_conv;
9782         o_conv.inner = (void*)(o & (~1));
9783         o_conv.is_owned = (o & 1) || (o == 0);
9784         o_conv = FundingSigned_clone(&o_conv);
9785         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9786         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
9787         return (uint64_t)ret_conv;
9788 }
9789
9790 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
9791         LDKDecodeError e_conv;
9792         e_conv.inner = (void*)(e & (~1));
9793         e_conv.is_owned = (e & 1) || (e == 0);
9794         e_conv = DecodeError_clone(&e_conv);
9795         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9796         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
9797         return (uint64_t)ret_conv;
9798 }
9799
9800 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
9801         if ((_res & 1) != 0) return;
9802         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9803         FREE((void*)_res);
9804         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
9805 }
9806
9807 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
9808         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
9809         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9810         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
9811         return (uint64_t)ret_conv;
9812 }
9813
9814 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
9815         LDKFundingLocked o_conv;
9816         o_conv.inner = (void*)(o & (~1));
9817         o_conv.is_owned = (o & 1) || (o == 0);
9818         o_conv = FundingLocked_clone(&o_conv);
9819         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9820         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
9821         return (uint64_t)ret_conv;
9822 }
9823
9824 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
9825         LDKDecodeError e_conv;
9826         e_conv.inner = (void*)(e & (~1));
9827         e_conv.is_owned = (e & 1) || (e == 0);
9828         e_conv = DecodeError_clone(&e_conv);
9829         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9830         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
9831         return (uint64_t)ret_conv;
9832 }
9833
9834 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
9835         if ((_res & 1) != 0) return;
9836         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9837         FREE((void*)_res);
9838         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
9839 }
9840
9841 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
9842         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
9843         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9844         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
9845         return (uint64_t)ret_conv;
9846 }
9847
9848 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
9849         LDKInit o_conv;
9850         o_conv.inner = (void*)(o & (~1));
9851         o_conv.is_owned = (o & 1) || (o == 0);
9852         o_conv = Init_clone(&o_conv);
9853         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9854         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
9855         return (uint64_t)ret_conv;
9856 }
9857
9858 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
9859         LDKDecodeError e_conv;
9860         e_conv.inner = (void*)(e & (~1));
9861         e_conv.is_owned = (e & 1) || (e == 0);
9862         e_conv = DecodeError_clone(&e_conv);
9863         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9864         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
9865         return (uint64_t)ret_conv;
9866 }
9867
9868 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
9869         if ((_res & 1) != 0) return;
9870         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
9871         FREE((void*)_res);
9872         CResult_InitDecodeErrorZ_free(_res_conv);
9873 }
9874
9875 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
9876         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
9877         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9878         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
9879         return (uint64_t)ret_conv;
9880 }
9881
9882 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
9883         LDKOpenChannel o_conv;
9884         o_conv.inner = (void*)(o & (~1));
9885         o_conv.is_owned = (o & 1) || (o == 0);
9886         o_conv = OpenChannel_clone(&o_conv);
9887         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9888         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
9889         return (uint64_t)ret_conv;
9890 }
9891
9892 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
9893         LDKDecodeError e_conv;
9894         e_conv.inner = (void*)(e & (~1));
9895         e_conv.is_owned = (e & 1) || (e == 0);
9896         e_conv = DecodeError_clone(&e_conv);
9897         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9898         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
9899         return (uint64_t)ret_conv;
9900 }
9901
9902 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
9903         if ((_res & 1) != 0) return;
9904         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9905         FREE((void*)_res);
9906         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
9907 }
9908
9909 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
9910         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
9911         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9912         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
9913         return (uint64_t)ret_conv;
9914 }
9915
9916 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
9917         LDKRevokeAndACK o_conv;
9918         o_conv.inner = (void*)(o & (~1));
9919         o_conv.is_owned = (o & 1) || (o == 0);
9920         o_conv = RevokeAndACK_clone(&o_conv);
9921         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9922         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
9923         return (uint64_t)ret_conv;
9924 }
9925
9926 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
9927         LDKDecodeError e_conv;
9928         e_conv.inner = (void*)(e & (~1));
9929         e_conv.is_owned = (e & 1) || (e == 0);
9930         e_conv = DecodeError_clone(&e_conv);
9931         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9932         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
9933         return (uint64_t)ret_conv;
9934 }
9935
9936 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
9937         if ((_res & 1) != 0) return;
9938         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
9939         FREE((void*)_res);
9940         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
9941 }
9942
9943 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
9944         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
9945         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9946         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
9947         return (uint64_t)ret_conv;
9948 }
9949
9950 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
9951         LDKShutdown o_conv;
9952         o_conv.inner = (void*)(o & (~1));
9953         o_conv.is_owned = (o & 1) || (o == 0);
9954         o_conv = Shutdown_clone(&o_conv);
9955         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9956         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
9957         return (uint64_t)ret_conv;
9958 }
9959
9960 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
9961         LDKDecodeError e_conv;
9962         e_conv.inner = (void*)(e & (~1));
9963         e_conv.is_owned = (e & 1) || (e == 0);
9964         e_conv = DecodeError_clone(&e_conv);
9965         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9966         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
9967         return (uint64_t)ret_conv;
9968 }
9969
9970 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
9971         if ((_res & 1) != 0) return;
9972         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
9973         FREE((void*)_res);
9974         CResult_ShutdownDecodeErrorZ_free(_res_conv);
9975 }
9976
9977 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
9978         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
9979         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9980         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
9981         return (uint64_t)ret_conv;
9982 }
9983
9984 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
9985         LDKUpdateFailHTLC o_conv;
9986         o_conv.inner = (void*)(o & (~1));
9987         o_conv.is_owned = (o & 1) || (o == 0);
9988         o_conv = UpdateFailHTLC_clone(&o_conv);
9989         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9990         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
9991         return (uint64_t)ret_conv;
9992 }
9993
9994 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
9995         LDKDecodeError e_conv;
9996         e_conv.inner = (void*)(e & (~1));
9997         e_conv.is_owned = (e & 1) || (e == 0);
9998         e_conv = DecodeError_clone(&e_conv);
9999         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
10000         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
10001         return (uint64_t)ret_conv;
10002 }
10003
10004 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
10005         if ((_res & 1) != 0) return;
10006         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10007         FREE((void*)_res);
10008         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
10009 }
10010
10011 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
10012         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
10013         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
10014         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
10015         return (uint64_t)ret_conv;
10016 }
10017
10018 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
10019         LDKUpdateFailMalformedHTLC o_conv;
10020         o_conv.inner = (void*)(o & (~1));
10021         o_conv.is_owned = (o & 1) || (o == 0);
10022         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
10023         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10024         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
10025         return (uint64_t)ret_conv;
10026 }
10027
10028 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
10029         LDKDecodeError e_conv;
10030         e_conv.inner = (void*)(e & (~1));
10031         e_conv.is_owned = (e & 1) || (e == 0);
10032         e_conv = DecodeError_clone(&e_conv);
10033         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10034         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
10035         return (uint64_t)ret_conv;
10036 }
10037
10038 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
10039         if ((_res & 1) != 0) return;
10040         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10041         FREE((void*)_res);
10042         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
10043 }
10044
10045 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
10046         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
10047         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10048         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
10049         return (uint64_t)ret_conv;
10050 }
10051
10052 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
10053         LDKUpdateFee o_conv;
10054         o_conv.inner = (void*)(o & (~1));
10055         o_conv.is_owned = (o & 1) || (o == 0);
10056         o_conv = UpdateFee_clone(&o_conv);
10057         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10058         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
10059         return (uint64_t)ret_conv;
10060 }
10061
10062 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
10063         LDKDecodeError e_conv;
10064         e_conv.inner = (void*)(e & (~1));
10065         e_conv.is_owned = (e & 1) || (e == 0);
10066         e_conv = DecodeError_clone(&e_conv);
10067         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10068         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
10069         return (uint64_t)ret_conv;
10070 }
10071
10072 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
10073         if ((_res & 1) != 0) return;
10074         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10075         FREE((void*)_res);
10076         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
10077 }
10078
10079 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
10080         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
10081         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10082         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
10083         return (uint64_t)ret_conv;
10084 }
10085
10086 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
10087         LDKUpdateFulfillHTLC o_conv;
10088         o_conv.inner = (void*)(o & (~1));
10089         o_conv.is_owned = (o & 1) || (o == 0);
10090         o_conv = UpdateFulfillHTLC_clone(&o_conv);
10091         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10092         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
10093         return (uint64_t)ret_conv;
10094 }
10095
10096 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
10097         LDKDecodeError e_conv;
10098         e_conv.inner = (void*)(e & (~1));
10099         e_conv.is_owned = (e & 1) || (e == 0);
10100         e_conv = DecodeError_clone(&e_conv);
10101         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10102         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
10103         return (uint64_t)ret_conv;
10104 }
10105
10106 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
10107         if ((_res & 1) != 0) return;
10108         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10109         FREE((void*)_res);
10110         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
10111 }
10112
10113 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
10114         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
10115         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10116         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
10117         return (uint64_t)ret_conv;
10118 }
10119
10120 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
10121         LDKUpdateAddHTLC o_conv;
10122         o_conv.inner = (void*)(o & (~1));
10123         o_conv.is_owned = (o & 1) || (o == 0);
10124         o_conv = UpdateAddHTLC_clone(&o_conv);
10125         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10126         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
10127         return (uint64_t)ret_conv;
10128 }
10129
10130 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
10131         LDKDecodeError e_conv;
10132         e_conv.inner = (void*)(e & (~1));
10133         e_conv.is_owned = (e & 1) || (e == 0);
10134         e_conv = DecodeError_clone(&e_conv);
10135         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10136         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
10137         return (uint64_t)ret_conv;
10138 }
10139
10140 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
10141         if ((_res & 1) != 0) return;
10142         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10143         FREE((void*)_res);
10144         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
10145 }
10146
10147 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
10148         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
10149         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10150         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
10151         return (uint64_t)ret_conv;
10152 }
10153
10154 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
10155         LDKPing o_conv;
10156         o_conv.inner = (void*)(o & (~1));
10157         o_conv.is_owned = (o & 1) || (o == 0);
10158         o_conv = Ping_clone(&o_conv);
10159         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10160         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
10161         return (uint64_t)ret_conv;
10162 }
10163
10164 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
10165         LDKDecodeError e_conv;
10166         e_conv.inner = (void*)(e & (~1));
10167         e_conv.is_owned = (e & 1) || (e == 0);
10168         e_conv = DecodeError_clone(&e_conv);
10169         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10170         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
10171         return (uint64_t)ret_conv;
10172 }
10173
10174 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
10175         if ((_res & 1) != 0) return;
10176         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
10177         FREE((void*)_res);
10178         CResult_PingDecodeErrorZ_free(_res_conv);
10179 }
10180
10181 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
10182         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
10183         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10184         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
10185         return (uint64_t)ret_conv;
10186 }
10187
10188 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
10189         LDKPong o_conv;
10190         o_conv.inner = (void*)(o & (~1));
10191         o_conv.is_owned = (o & 1) || (o == 0);
10192         o_conv = Pong_clone(&o_conv);
10193         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10194         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
10195         return (uint64_t)ret_conv;
10196 }
10197
10198 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
10199         LDKDecodeError e_conv;
10200         e_conv.inner = (void*)(e & (~1));
10201         e_conv.is_owned = (e & 1) || (e == 0);
10202         e_conv = DecodeError_clone(&e_conv);
10203         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10204         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
10205         return (uint64_t)ret_conv;
10206 }
10207
10208 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
10209         if ((_res & 1) != 0) return;
10210         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
10211         FREE((void*)_res);
10212         CResult_PongDecodeErrorZ_free(_res_conv);
10213 }
10214
10215 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
10216         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
10217         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10218         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
10219         return (uint64_t)ret_conv;
10220 }
10221
10222 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
10223         LDKUnsignedChannelAnnouncement o_conv;
10224         o_conv.inner = (void*)(o & (~1));
10225         o_conv.is_owned = (o & 1) || (o == 0);
10226         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
10227         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10228         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
10229         return (uint64_t)ret_conv;
10230 }
10231
10232 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
10233         LDKDecodeError e_conv;
10234         e_conv.inner = (void*)(e & (~1));
10235         e_conv.is_owned = (e & 1) || (e == 0);
10236         e_conv = DecodeError_clone(&e_conv);
10237         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10238         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
10239         return (uint64_t)ret_conv;
10240 }
10241
10242 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
10243         if ((_res & 1) != 0) return;
10244         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10245         FREE((void*)_res);
10246         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
10247 }
10248
10249 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10250         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
10251         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10252         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
10253         return (uint64_t)ret_conv;
10254 }
10255
10256 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
10257         LDKChannelAnnouncement o_conv;
10258         o_conv.inner = (void*)(o & (~1));
10259         o_conv.is_owned = (o & 1) || (o == 0);
10260         o_conv = ChannelAnnouncement_clone(&o_conv);
10261         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10262         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
10263         return (uint64_t)ret_conv;
10264 }
10265
10266 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
10267         LDKDecodeError e_conv;
10268         e_conv.inner = (void*)(e & (~1));
10269         e_conv.is_owned = (e & 1) || (e == 0);
10270         e_conv = DecodeError_clone(&e_conv);
10271         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10272         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
10273         return (uint64_t)ret_conv;
10274 }
10275
10276 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
10277         if ((_res & 1) != 0) return;
10278         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10279         FREE((void*)_res);
10280         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
10281 }
10282
10283 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10284         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
10285         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10286         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
10287         return (uint64_t)ret_conv;
10288 }
10289
10290 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
10291         LDKUnsignedChannelUpdate o_conv;
10292         o_conv.inner = (void*)(o & (~1));
10293         o_conv.is_owned = (o & 1) || (o == 0);
10294         o_conv = UnsignedChannelUpdate_clone(&o_conv);
10295         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10296         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
10297         return (uint64_t)ret_conv;
10298 }
10299
10300 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
10301         LDKDecodeError e_conv;
10302         e_conv.inner = (void*)(e & (~1));
10303         e_conv.is_owned = (e & 1) || (e == 0);
10304         e_conv = DecodeError_clone(&e_conv);
10305         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10306         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
10307         return (uint64_t)ret_conv;
10308 }
10309
10310 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
10311         if ((_res & 1) != 0) return;
10312         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10313         FREE((void*)_res);
10314         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
10315 }
10316
10317 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
10318         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
10319         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10320         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
10321         return (uint64_t)ret_conv;
10322 }
10323
10324 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
10325         LDKChannelUpdate o_conv;
10326         o_conv.inner = (void*)(o & (~1));
10327         o_conv.is_owned = (o & 1) || (o == 0);
10328         o_conv = ChannelUpdate_clone(&o_conv);
10329         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10330         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
10331         return (uint64_t)ret_conv;
10332 }
10333
10334 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
10335         LDKDecodeError e_conv;
10336         e_conv.inner = (void*)(e & (~1));
10337         e_conv.is_owned = (e & 1) || (e == 0);
10338         e_conv = DecodeError_clone(&e_conv);
10339         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10340         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
10341         return (uint64_t)ret_conv;
10342 }
10343
10344 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
10345         if ((_res & 1) != 0) return;
10346         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10347         FREE((void*)_res);
10348         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
10349 }
10350
10351 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
10352         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
10353         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10354         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
10355         return (uint64_t)ret_conv;
10356 }
10357
10358 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
10359         LDKErrorMessage o_conv;
10360         o_conv.inner = (void*)(o & (~1));
10361         o_conv.is_owned = (o & 1) || (o == 0);
10362         o_conv = ErrorMessage_clone(&o_conv);
10363         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10364         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
10365         return (uint64_t)ret_conv;
10366 }
10367
10368 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
10369         LDKDecodeError e_conv;
10370         e_conv.inner = (void*)(e & (~1));
10371         e_conv.is_owned = (e & 1) || (e == 0);
10372         e_conv = DecodeError_clone(&e_conv);
10373         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10374         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
10375         return (uint64_t)ret_conv;
10376 }
10377
10378 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
10379         if ((_res & 1) != 0) return;
10380         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
10381         FREE((void*)_res);
10382         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
10383 }
10384
10385 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
10386         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
10387         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10388         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
10389         return (uint64_t)ret_conv;
10390 }
10391
10392 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
10393         LDKUnsignedNodeAnnouncement o_conv;
10394         o_conv.inner = (void*)(o & (~1));
10395         o_conv.is_owned = (o & 1) || (o == 0);
10396         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
10397         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10398         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
10399         return (uint64_t)ret_conv;
10400 }
10401
10402 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
10403         LDKDecodeError e_conv;
10404         e_conv.inner = (void*)(e & (~1));
10405         e_conv.is_owned = (e & 1) || (e == 0);
10406         e_conv = DecodeError_clone(&e_conv);
10407         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10408         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
10409         return (uint64_t)ret_conv;
10410 }
10411
10412 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
10413         if ((_res & 1) != 0) return;
10414         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10415         FREE((void*)_res);
10416         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
10417 }
10418
10419 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10420         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
10421         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10422         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
10423         return (uint64_t)ret_conv;
10424 }
10425
10426 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
10427         LDKNodeAnnouncement o_conv;
10428         o_conv.inner = (void*)(o & (~1));
10429         o_conv.is_owned = (o & 1) || (o == 0);
10430         o_conv = NodeAnnouncement_clone(&o_conv);
10431         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10432         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
10433         return (uint64_t)ret_conv;
10434 }
10435
10436 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
10437         LDKDecodeError e_conv;
10438         e_conv.inner = (void*)(e & (~1));
10439         e_conv.is_owned = (e & 1) || (e == 0);
10440         e_conv = DecodeError_clone(&e_conv);
10441         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10442         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
10443         return (uint64_t)ret_conv;
10444 }
10445
10446 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
10447         if ((_res & 1) != 0) return;
10448         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10449         FREE((void*)_res);
10450         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
10451 }
10452
10453 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10454         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
10455         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10456         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
10457         return (uint64_t)ret_conv;
10458 }
10459
10460 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
10461         LDKQueryShortChannelIds o_conv;
10462         o_conv.inner = (void*)(o & (~1));
10463         o_conv.is_owned = (o & 1) || (o == 0);
10464         o_conv = QueryShortChannelIds_clone(&o_conv);
10465         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10466         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
10467         return (uint64_t)ret_conv;
10468 }
10469
10470 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
10471         LDKDecodeError e_conv;
10472         e_conv.inner = (void*)(e & (~1));
10473         e_conv.is_owned = (e & 1) || (e == 0);
10474         e_conv = DecodeError_clone(&e_conv);
10475         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10476         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
10477         return (uint64_t)ret_conv;
10478 }
10479
10480 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
10481         if ((_res & 1) != 0) return;
10482         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
10483         FREE((void*)_res);
10484         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
10485 }
10486
10487 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
10488         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
10489         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10490         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
10491         return (uint64_t)ret_conv;
10492 }
10493
10494 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
10495         LDKReplyShortChannelIdsEnd o_conv;
10496         o_conv.inner = (void*)(o & (~1));
10497         o_conv.is_owned = (o & 1) || (o == 0);
10498         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
10499         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10500         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
10501         return (uint64_t)ret_conv;
10502 }
10503
10504 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
10505         LDKDecodeError e_conv;
10506         e_conv.inner = (void*)(e & (~1));
10507         e_conv.is_owned = (e & 1) || (e == 0);
10508         e_conv = DecodeError_clone(&e_conv);
10509         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10510         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
10511         return (uint64_t)ret_conv;
10512 }
10513
10514 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
10515         if ((_res & 1) != 0) return;
10516         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
10517         FREE((void*)_res);
10518         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
10519 }
10520
10521 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
10522         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
10523         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10524         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
10525         return (uint64_t)ret_conv;
10526 }
10527
10528 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
10529         LDKQueryChannelRange o_conv;
10530         o_conv.inner = (void*)(o & (~1));
10531         o_conv.is_owned = (o & 1) || (o == 0);
10532         o_conv = QueryChannelRange_clone(&o_conv);
10533         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10534         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
10535         return (uint64_t)ret_conv;
10536 }
10537
10538 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
10539         LDKDecodeError e_conv;
10540         e_conv.inner = (void*)(e & (~1));
10541         e_conv.is_owned = (e & 1) || (e == 0);
10542         e_conv = DecodeError_clone(&e_conv);
10543         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10544         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
10545         return (uint64_t)ret_conv;
10546 }
10547
10548 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
10549         if ((_res & 1) != 0) return;
10550         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10551         FREE((void*)_res);
10552         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
10553 }
10554
10555 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
10556         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
10557         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10558         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
10559         return (uint64_t)ret_conv;
10560 }
10561
10562 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
10563         LDKReplyChannelRange o_conv;
10564         o_conv.inner = (void*)(o & (~1));
10565         o_conv.is_owned = (o & 1) || (o == 0);
10566         o_conv = ReplyChannelRange_clone(&o_conv);
10567         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10568         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
10569         return (uint64_t)ret_conv;
10570 }
10571
10572 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
10573         LDKDecodeError e_conv;
10574         e_conv.inner = (void*)(e & (~1));
10575         e_conv.is_owned = (e & 1) || (e == 0);
10576         e_conv = DecodeError_clone(&e_conv);
10577         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10578         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
10579         return (uint64_t)ret_conv;
10580 }
10581
10582 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
10583         if ((_res & 1) != 0) return;
10584         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10585         FREE((void*)_res);
10586         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
10587 }
10588
10589 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
10590         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
10591         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10592         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
10593         return (uint64_t)ret_conv;
10594 }
10595
10596 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
10597         LDKGossipTimestampFilter o_conv;
10598         o_conv.inner = (void*)(o & (~1));
10599         o_conv.is_owned = (o & 1) || (o == 0);
10600         o_conv = GossipTimestampFilter_clone(&o_conv);
10601         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10602         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
10603         return (uint64_t)ret_conv;
10604 }
10605
10606 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
10607         LDKDecodeError e_conv;
10608         e_conv.inner = (void*)(e & (~1));
10609         e_conv.is_owned = (e & 1) || (e == 0);
10610         e_conv = DecodeError_clone(&e_conv);
10611         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10612         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
10613         return (uint64_t)ret_conv;
10614 }
10615
10616 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
10617         if ((_res & 1) != 0) return;
10618         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
10619         FREE((void*)_res);
10620         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
10621 }
10622
10623 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
10624         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
10625         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10626         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
10627         return (uint64_t)ret_conv;
10628 }
10629
10630 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
10631         LDKInvoice o_conv;
10632         o_conv.inner = (void*)(o & (~1));
10633         o_conv.is_owned = (o & 1) || (o == 0);
10634         o_conv = Invoice_clone(&o_conv);
10635         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10636         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
10637         return (uint64_t)ret_conv;
10638 }
10639
10640 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
10641         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
10642         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10643         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
10644         return (uint64_t)ret_conv;
10645 }
10646
10647 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
10648         if ((_res & 1) != 0) return;
10649         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
10650         FREE((void*)_res);
10651         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
10652 }
10653
10654 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
10655         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
10656         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10657         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
10658         return (uint64_t)ret_conv;
10659 }
10660
10661 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
10662         if ((this_ptr & 1) != 0) return;
10663         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
10664         FREE((void*)this_ptr);
10665         Event_free(this_ptr_conv);
10666 }
10667
10668 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
10669         LDKEvent* orig_conv = (LDKEvent*)orig;
10670         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
10671         *ret_copy = Event_clone(orig_conv);
10672         uint64_t ret_ref = (uint64_t)ret_copy;
10673         return ret_ref;
10674 }
10675
10676 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
10677         LDKEvent* obj_conv = (LDKEvent*)obj;
10678         LDKCVec_u8Z ret_var = Event_write(obj_conv);
10679         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10680         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10681         CVec_u8Z_free(ret_var);
10682         return ret_arr;
10683 }
10684
10685 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
10686         if ((this_ptr & 1) != 0) return;
10687         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
10688         FREE((void*)this_ptr);
10689         MessageSendEvent_free(this_ptr_conv);
10690 }
10691
10692 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
10693         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
10694         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10695         *ret_copy = MessageSendEvent_clone(orig_conv);
10696         uint64_t ret_ref = (uint64_t)ret_copy;
10697         return ret_ref;
10698 }
10699
10700 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
10701         if ((this_ptr & 1) != 0) return;
10702         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
10703         FREE((void*)this_ptr);
10704         MessageSendEventsProvider_free(this_ptr_conv);
10705 }
10706
10707 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
10708         if ((this_ptr & 1) != 0) return;
10709         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
10710         FREE((void*)this_ptr);
10711         EventsProvider_free(this_ptr_conv);
10712 }
10713
10714 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
10715         if ((this_ptr & 1) != 0) return;
10716         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
10717         FREE((void*)this_ptr);
10718         EventHandler_free(this_ptr_conv);
10719 }
10720
10721 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
10722         if ((this_ptr & 1) != 0) return;
10723         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
10724         FREE((void*)this_ptr);
10725         APIError_free(this_ptr_conv);
10726 }
10727
10728 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
10729         LDKAPIError* orig_conv = (LDKAPIError*)orig;
10730         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
10731         *ret_copy = APIError_clone(orig_conv);
10732         uint64_t ret_ref = (uint64_t)ret_copy;
10733         return ret_ref;
10734 }
10735
10736 uint32_t  __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_tArray sk) {
10737         LDKu8slice msg_ref;
10738         msg_ref.datalen = *((uint32_t*)msg);
10739         msg_ref.data = (int8_t*)(msg + 4);
10740         LDKSecretKey sk_ref;
10741         CHECK(*((uint32_t*)sk) == 32);
10742         memcpy(sk_ref.bytes, (uint8_t*)(sk + 4), 32);
10743         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10744         *ret_conv = sign(msg_ref, sk_ref);
10745         return (uint64_t)ret_conv;
10746 }
10747
10748 uint32_t  __attribute__((visibility("default"))) TS_recover_pk(int8_tArray msg, jstring sig) {
10749         LDKu8slice msg_ref;
10750         msg_ref.datalen = *((uint32_t*)msg);
10751         msg_ref.data = (int8_t*)(msg + 4);
10752         LDKStr sig_conv = str_ref_to_owned_c(sig);
10753         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10754         *ret_conv = recover_pk(msg_ref, sig_conv);
10755         return (uint64_t)ret_conv;
10756 }
10757
10758 jboolean  __attribute__((visibility("default"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
10759         LDKu8slice msg_ref;
10760         msg_ref.datalen = *((uint32_t*)msg);
10761         msg_ref.data = (int8_t*)(msg + 4);
10762         LDKStr sig_conv = str_ref_to_owned_c(sig);
10763         LDKPublicKey pk_ref;
10764         CHECK(*((uint32_t*)pk) == 33);
10765         memcpy(pk_ref.compressed_form, (uint8_t*)(pk + 4), 33);
10766         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
10767         return ret_val;
10768 }
10769
10770 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
10771         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
10772         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
10773         return ret_conv;
10774 }
10775
10776 jboolean  __attribute__((visibility("default"))) TS_Level_eq(uint32_t a, uint32_t b) {
10777         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
10778         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
10779         jboolean ret_val = Level_eq(a_conv, b_conv);
10780         return ret_val;
10781 }
10782
10783 int64_t  __attribute__((visibility("default"))) TS_Level_hash(uint32_t o) {
10784         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
10785         int64_t ret_val = Level_hash(o_conv);
10786         return ret_val;
10787 }
10788
10789 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
10790         uint32_t ret_conv = LDKLevel_to_js(Level_max());
10791         return ret_conv;
10792 }
10793
10794 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
10795         if ((this_ptr & 1) != 0) return;
10796         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
10797         FREE((void*)this_ptr);
10798         Logger_free(this_ptr_conv);
10799 }
10800
10801 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
10802         LDKChannelHandshakeConfig this_obj_conv;
10803         this_obj_conv.inner = (void*)(this_obj & (~1));
10804         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10805         ChannelHandshakeConfig_free(this_obj_conv);
10806 }
10807
10808 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
10809         LDKChannelHandshakeConfig this_ptr_conv;
10810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10811         this_ptr_conv.is_owned = false;
10812         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
10813         return ret_val;
10814 }
10815
10816 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
10817         LDKChannelHandshakeConfig this_ptr_conv;
10818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10819         this_ptr_conv.is_owned = false;
10820         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
10821 }
10822
10823 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
10824         LDKChannelHandshakeConfig this_ptr_conv;
10825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10826         this_ptr_conv.is_owned = false;
10827         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
10828         return ret_val;
10829 }
10830
10831 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
10832         LDKChannelHandshakeConfig this_ptr_conv;
10833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10834         this_ptr_conv.is_owned = false;
10835         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
10836 }
10837
10838 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
10839         LDKChannelHandshakeConfig this_ptr_conv;
10840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10841         this_ptr_conv.is_owned = false;
10842         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
10843         return ret_val;
10844 }
10845
10846 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
10847         LDKChannelHandshakeConfig this_ptr_conv;
10848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10849         this_ptr_conv.is_owned = false;
10850         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
10851 }
10852
10853 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) {
10854         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
10855         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10856         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10857         uint64_t ret_ref = (uint64_t)ret_var.inner;
10858         if (ret_var.is_owned) {
10859                 ret_ref |= 1;
10860         }
10861         return ret_ref;
10862 }
10863
10864 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
10865         LDKChannelHandshakeConfig orig_conv;
10866         orig_conv.inner = (void*)(orig & (~1));
10867         orig_conv.is_owned = false;
10868         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
10869         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10870         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10871         uint64_t ret_ref = (uint64_t)ret_var.inner;
10872         if (ret_var.is_owned) {
10873                 ret_ref |= 1;
10874         }
10875         return ret_ref;
10876 }
10877
10878 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
10879         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
10880         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10881         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10882         uint64_t ret_ref = (uint64_t)ret_var.inner;
10883         if (ret_var.is_owned) {
10884                 ret_ref |= 1;
10885         }
10886         return ret_ref;
10887 }
10888
10889 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
10890         LDKChannelHandshakeLimits this_obj_conv;
10891         this_obj_conv.inner = (void*)(this_obj & (~1));
10892         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10893         ChannelHandshakeLimits_free(this_obj_conv);
10894 }
10895
10896 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
10897         LDKChannelHandshakeLimits this_ptr_conv;
10898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10899         this_ptr_conv.is_owned = false;
10900         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
10901         return ret_val;
10902 }
10903
10904 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
10905         LDKChannelHandshakeLimits this_ptr_conv;
10906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10907         this_ptr_conv.is_owned = false;
10908         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
10909 }
10910
10911 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
10912         LDKChannelHandshakeLimits this_ptr_conv;
10913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10914         this_ptr_conv.is_owned = false;
10915         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
10916         return ret_val;
10917 }
10918
10919 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
10920         LDKChannelHandshakeLimits this_ptr_conv;
10921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10922         this_ptr_conv.is_owned = false;
10923         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
10924 }
10925
10926 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
10927         LDKChannelHandshakeLimits this_ptr_conv;
10928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10929         this_ptr_conv.is_owned = false;
10930         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
10931         return ret_val;
10932 }
10933
10934 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
10935         LDKChannelHandshakeLimits this_ptr_conv;
10936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10937         this_ptr_conv.is_owned = false;
10938         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
10939 }
10940
10941 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
10942         LDKChannelHandshakeLimits this_ptr_conv;
10943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10944         this_ptr_conv.is_owned = false;
10945         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
10946         return ret_val;
10947 }
10948
10949 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
10950         LDKChannelHandshakeLimits this_ptr_conv;
10951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10952         this_ptr_conv.is_owned = false;
10953         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
10954 }
10955
10956 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
10957         LDKChannelHandshakeLimits this_ptr_conv;
10958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10959         this_ptr_conv.is_owned = false;
10960         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
10961         return ret_val;
10962 }
10963
10964 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
10965         LDKChannelHandshakeLimits this_ptr_conv;
10966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10967         this_ptr_conv.is_owned = false;
10968         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
10969 }
10970
10971 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
10972         LDKChannelHandshakeLimits this_ptr_conv;
10973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10974         this_ptr_conv.is_owned = false;
10975         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
10976         return ret_val;
10977 }
10978
10979 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
10980         LDKChannelHandshakeLimits this_ptr_conv;
10981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10982         this_ptr_conv.is_owned = false;
10983         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
10984 }
10985
10986 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
10987         LDKChannelHandshakeLimits this_ptr_conv;
10988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10989         this_ptr_conv.is_owned = false;
10990         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
10991         return ret_val;
10992 }
10993
10994 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
10995         LDKChannelHandshakeLimits this_ptr_conv;
10996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10997         this_ptr_conv.is_owned = false;
10998         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
10999 }
11000
11001 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
11002         LDKChannelHandshakeLimits this_ptr_conv;
11003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11004         this_ptr_conv.is_owned = false;
11005         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
11006         return ret_val;
11007 }
11008
11009 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
11010         LDKChannelHandshakeLimits this_ptr_conv;
11011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11012         this_ptr_conv.is_owned = false;
11013         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
11014 }
11015
11016 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) {
11017         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);
11018         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11019         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11020         uint64_t ret_ref = (uint64_t)ret_var.inner;
11021         if (ret_var.is_owned) {
11022                 ret_ref |= 1;
11023         }
11024         return ret_ref;
11025 }
11026
11027 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
11028         LDKChannelHandshakeLimits orig_conv;
11029         orig_conv.inner = (void*)(orig & (~1));
11030         orig_conv.is_owned = false;
11031         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
11032         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11033         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11034         uint64_t ret_ref = (uint64_t)ret_var.inner;
11035         if (ret_var.is_owned) {
11036                 ret_ref |= 1;
11037         }
11038         return ret_ref;
11039 }
11040
11041 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
11042         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
11043         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11044         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11045         uint64_t ret_ref = (uint64_t)ret_var.inner;
11046         if (ret_var.is_owned) {
11047                 ret_ref |= 1;
11048         }
11049         return ret_ref;
11050 }
11051
11052 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
11053         LDKChannelConfig this_obj_conv;
11054         this_obj_conv.inner = (void*)(this_obj & (~1));
11055         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11056         ChannelConfig_free(this_obj_conv);
11057 }
11058
11059 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_fee_proportional_millionths(uint32_t this_ptr) {
11060         LDKChannelConfig this_ptr_conv;
11061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11062         this_ptr_conv.is_owned = false;
11063         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
11064         return ret_val;
11065 }
11066
11067 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
11068         LDKChannelConfig this_ptr_conv;
11069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11070         this_ptr_conv.is_owned = false;
11071         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
11072 }
11073
11074 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
11075         LDKChannelConfig this_ptr_conv;
11076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11077         this_ptr_conv.is_owned = false;
11078         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
11079         return ret_val;
11080 }
11081
11082 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
11083         LDKChannelConfig this_ptr_conv;
11084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11085         this_ptr_conv.is_owned = false;
11086         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
11087 }
11088
11089 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
11090         LDKChannelConfig this_ptr_conv;
11091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11092         this_ptr_conv.is_owned = false;
11093         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
11094         return ret_val;
11095 }
11096
11097 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
11098         LDKChannelConfig this_ptr_conv;
11099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11100         this_ptr_conv.is_owned = false;
11101         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
11102 }
11103
11104 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
11105         LDKChannelConfig this_ptr_conv;
11106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11107         this_ptr_conv.is_owned = false;
11108         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
11109         return ret_val;
11110 }
11111
11112 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
11113         LDKChannelConfig this_ptr_conv;
11114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11115         this_ptr_conv.is_owned = false;
11116         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
11117 }
11118
11119 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
11120         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
11121         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11122         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11123         uint64_t ret_ref = (uint64_t)ret_var.inner;
11124         if (ret_var.is_owned) {
11125                 ret_ref |= 1;
11126         }
11127         return ret_ref;
11128 }
11129
11130 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
11131         LDKChannelConfig orig_conv;
11132         orig_conv.inner = (void*)(orig & (~1));
11133         orig_conv.is_owned = false;
11134         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
11135         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11136         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11137         uint64_t ret_ref = (uint64_t)ret_var.inner;
11138         if (ret_var.is_owned) {
11139                 ret_ref |= 1;
11140         }
11141         return ret_ref;
11142 }
11143
11144 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
11145         LDKChannelConfig ret_var = ChannelConfig_default();
11146         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11147         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11148         uint64_t ret_ref = (uint64_t)ret_var.inner;
11149         if (ret_var.is_owned) {
11150                 ret_ref |= 1;
11151         }
11152         return ret_ref;
11153 }
11154
11155 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
11156         LDKChannelConfig obj_conv;
11157         obj_conv.inner = (void*)(obj & (~1));
11158         obj_conv.is_owned = false;
11159         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
11160         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11161         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11162         CVec_u8Z_free(ret_var);
11163         return ret_arr;
11164 }
11165
11166 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
11167         LDKu8slice ser_ref;
11168         ser_ref.datalen = *((uint32_t*)ser);
11169         ser_ref.data = (int8_t*)(ser + 4);
11170         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
11171         *ret_conv = ChannelConfig_read(ser_ref);
11172         return (uint64_t)ret_conv;
11173 }
11174
11175 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
11176         LDKUserConfig this_obj_conv;
11177         this_obj_conv.inner = (void*)(this_obj & (~1));
11178         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11179         UserConfig_free(this_obj_conv);
11180 }
11181
11182 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
11183         LDKUserConfig this_ptr_conv;
11184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11185         this_ptr_conv.is_owned = false;
11186         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
11187         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11188         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11189         uint64_t ret_ref = (uint64_t)ret_var.inner;
11190         if (ret_var.is_owned) {
11191                 ret_ref |= 1;
11192         }
11193         return ret_ref;
11194 }
11195
11196 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
11197         LDKUserConfig this_ptr_conv;
11198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11199         this_ptr_conv.is_owned = false;
11200         LDKChannelHandshakeConfig val_conv;
11201         val_conv.inner = (void*)(val & (~1));
11202         val_conv.is_owned = (val & 1) || (val == 0);
11203         val_conv = ChannelHandshakeConfig_clone(&val_conv);
11204         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
11205 }
11206
11207 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
11208         LDKUserConfig this_ptr_conv;
11209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11210         this_ptr_conv.is_owned = false;
11211         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
11212         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11213         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11214         uint64_t ret_ref = (uint64_t)ret_var.inner;
11215         if (ret_var.is_owned) {
11216                 ret_ref |= 1;
11217         }
11218         return ret_ref;
11219 }
11220
11221 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
11222         LDKUserConfig this_ptr_conv;
11223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11224         this_ptr_conv.is_owned = false;
11225         LDKChannelHandshakeLimits val_conv;
11226         val_conv.inner = (void*)(val & (~1));
11227         val_conv.is_owned = (val & 1) || (val == 0);
11228         val_conv = ChannelHandshakeLimits_clone(&val_conv);
11229         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
11230 }
11231
11232 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
11233         LDKUserConfig this_ptr_conv;
11234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11235         this_ptr_conv.is_owned = false;
11236         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
11237         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11238         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11239         uint64_t ret_ref = (uint64_t)ret_var.inner;
11240         if (ret_var.is_owned) {
11241                 ret_ref |= 1;
11242         }
11243         return ret_ref;
11244 }
11245
11246 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
11247         LDKUserConfig this_ptr_conv;
11248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11249         this_ptr_conv.is_owned = false;
11250         LDKChannelConfig val_conv;
11251         val_conv.inner = (void*)(val & (~1));
11252         val_conv.is_owned = (val & 1) || (val == 0);
11253         val_conv = ChannelConfig_clone(&val_conv);
11254         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
11255 }
11256
11257 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) {
11258         LDKChannelHandshakeConfig own_channel_config_arg_conv;
11259         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
11260         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
11261         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
11262         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
11263         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
11264         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
11265         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
11266         LDKChannelConfig channel_options_arg_conv;
11267         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
11268         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
11269         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
11270         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
11271         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11272         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11273         uint64_t ret_ref = (uint64_t)ret_var.inner;
11274         if (ret_var.is_owned) {
11275                 ret_ref |= 1;
11276         }
11277         return ret_ref;
11278 }
11279
11280 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
11281         LDKUserConfig orig_conv;
11282         orig_conv.inner = (void*)(orig & (~1));
11283         orig_conv.is_owned = false;
11284         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
11285         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11286         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11287         uint64_t ret_ref = (uint64_t)ret_var.inner;
11288         if (ret_var.is_owned) {
11289                 ret_ref |= 1;
11290         }
11291         return ret_ref;
11292 }
11293
11294 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
11295         LDKUserConfig ret_var = UserConfig_default();
11296         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11297         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11298         uint64_t ret_ref = (uint64_t)ret_var.inner;
11299         if (ret_var.is_owned) {
11300                 ret_ref |= 1;
11301         }
11302         return ret_ref;
11303 }
11304
11305 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
11306         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
11307         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
11308         return ret_conv;
11309 }
11310
11311 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
11312         if ((this_ptr & 1) != 0) return;
11313         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
11314         FREE((void*)this_ptr);
11315         Access_free(this_ptr_conv);
11316 }
11317
11318 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
11319         if ((this_ptr & 1) != 0) return;
11320         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
11321         FREE((void*)this_ptr);
11322         Listen_free(this_ptr_conv);
11323 }
11324
11325 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
11326         if ((this_ptr & 1) != 0) return;
11327         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
11328         FREE((void*)this_ptr);
11329         Confirm_free(this_ptr_conv);
11330 }
11331
11332 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
11333         if ((this_ptr & 1) != 0) return;
11334         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
11335         FREE((void*)this_ptr);
11336         Watch_free(this_ptr_conv);
11337 }
11338
11339 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
11340         if ((this_ptr & 1) != 0) return;
11341         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
11342         FREE((void*)this_ptr);
11343         Filter_free(this_ptr_conv);
11344 }
11345
11346 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
11347         LDKWatchedOutput this_obj_conv;
11348         this_obj_conv.inner = (void*)(this_obj & (~1));
11349         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11350         WatchedOutput_free(this_obj_conv);
11351 }
11352
11353 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
11354         LDKWatchedOutput this_ptr_conv;
11355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11356         this_ptr_conv.is_owned = false;
11357         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11358         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
11359         return ret_arr;
11360 }
11361
11362 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
11363         LDKWatchedOutput this_ptr_conv;
11364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11365         this_ptr_conv.is_owned = false;
11366         LDKThirtyTwoBytes val_ref;
11367         CHECK(*((uint32_t*)val) == 32);
11368         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11369         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
11370 }
11371
11372 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
11373         LDKWatchedOutput this_ptr_conv;
11374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11375         this_ptr_conv.is_owned = false;
11376         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
11377         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11378         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11379         uint64_t ret_ref = (uint64_t)ret_var.inner;
11380         if (ret_var.is_owned) {
11381                 ret_ref |= 1;
11382         }
11383         return ret_ref;
11384 }
11385
11386 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
11387         LDKWatchedOutput this_ptr_conv;
11388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11389         this_ptr_conv.is_owned = false;
11390         LDKOutPoint val_conv;
11391         val_conv.inner = (void*)(val & (~1));
11392         val_conv.is_owned = (val & 1) || (val == 0);
11393         val_conv = OutPoint_clone(&val_conv);
11394         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
11395 }
11396
11397 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
11398         LDKWatchedOutput this_ptr_conv;
11399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11400         this_ptr_conv.is_owned = false;
11401         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
11402         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11403         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11404         return ret_arr;
11405 }
11406
11407 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
11408         LDKWatchedOutput this_ptr_conv;
11409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11410         this_ptr_conv.is_owned = false;
11411         LDKCVec_u8Z val_ref;
11412         val_ref.datalen = *((uint32_t*)val);
11413         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11414         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
11415         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
11416 }
11417
11418 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
11419         LDKThirtyTwoBytes block_hash_arg_ref;
11420         CHECK(*((uint32_t*)block_hash_arg) == 32);
11421         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
11422         LDKOutPoint outpoint_arg_conv;
11423         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
11424         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
11425         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
11426         LDKCVec_u8Z script_pubkey_arg_ref;
11427         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
11428         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11429         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
11430         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
11431         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11432         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11433         uint64_t ret_ref = (uint64_t)ret_var.inner;
11434         if (ret_var.is_owned) {
11435                 ret_ref |= 1;
11436         }
11437         return ret_ref;
11438 }
11439
11440 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t orig) {
11441         LDKWatchedOutput orig_conv;
11442         orig_conv.inner = (void*)(orig & (~1));
11443         orig_conv.is_owned = false;
11444         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
11445         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11446         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11447         uint64_t ret_ref = (uint64_t)ret_var.inner;
11448         if (ret_var.is_owned) {
11449                 ret_ref |= 1;
11450         }
11451         return ret_ref;
11452 }
11453
11454 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o) {
11455         LDKWatchedOutput o_conv;
11456         o_conv.inner = (void*)(o & (~1));
11457         o_conv.is_owned = false;
11458         int64_t ret_val = WatchedOutput_hash(&o_conv);
11459         return ret_val;
11460 }
11461
11462 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
11463         if ((this_ptr & 1) != 0) return;
11464         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
11465         FREE((void*)this_ptr);
11466         BroadcasterInterface_free(this_ptr_conv);
11467 }
11468
11469 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
11470         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
11471         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
11472         return ret_conv;
11473 }
11474
11475 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
11476         if ((this_ptr & 1) != 0) return;
11477         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
11478         FREE((void*)this_ptr);
11479         FeeEstimator_free(this_ptr_conv);
11480 }
11481
11482 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
11483         LDKChainMonitor this_obj_conv;
11484         this_obj_conv.inner = (void*)(this_obj & (~1));
11485         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11486         ChainMonitor_free(this_obj_conv);
11487 }
11488
11489 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
11490         LDKFilter *chain_source_conv_ptr = NULL;
11491         if (chain_source != 0) {
11492                 LDKFilter chain_source_conv;
11493                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
11494                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
11495                 *chain_source_conv_ptr = chain_source_conv;
11496         }
11497         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11498         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11499         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
11500         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
11501         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
11502         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11503         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11504         uint64_t ret_ref = (uint64_t)ret_var.inner;
11505         if (ret_var.is_owned) {
11506                 ret_ref |= 1;
11507         }
11508         return ret_ref;
11509 }
11510
11511 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
11512         LDKChainMonitor this_arg_conv;
11513         this_arg_conv.inner = (void*)(this_arg & (~1));
11514         this_arg_conv.is_owned = false;
11515         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
11516         *ret = ChainMonitor_as_Listen(&this_arg_conv);
11517         return (uint64_t)ret;
11518 }
11519
11520 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
11521         LDKChainMonitor this_arg_conv;
11522         this_arg_conv.inner = (void*)(this_arg & (~1));
11523         this_arg_conv.is_owned = false;
11524         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11525         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
11526         return (uint64_t)ret;
11527 }
11528
11529 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
11530         LDKChainMonitor this_arg_conv;
11531         this_arg_conv.inner = (void*)(this_arg & (~1));
11532         this_arg_conv.is_owned = false;
11533         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
11534         *ret = ChainMonitor_as_Watch(&this_arg_conv);
11535         return (uint64_t)ret;
11536 }
11537
11538 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
11539         LDKChainMonitor this_arg_conv;
11540         this_arg_conv.inner = (void*)(this_arg & (~1));
11541         this_arg_conv.is_owned = false;
11542         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11543         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
11544         return (uint64_t)ret;
11545 }
11546
11547 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
11548         LDKChannelMonitorUpdate this_obj_conv;
11549         this_obj_conv.inner = (void*)(this_obj & (~1));
11550         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11551         ChannelMonitorUpdate_free(this_obj_conv);
11552 }
11553
11554 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
11555         LDKChannelMonitorUpdate this_ptr_conv;
11556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11557         this_ptr_conv.is_owned = false;
11558         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
11559         return ret_val;
11560 }
11561
11562 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
11563         LDKChannelMonitorUpdate this_ptr_conv;
11564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11565         this_ptr_conv.is_owned = false;
11566         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
11567 }
11568
11569 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
11570         LDKChannelMonitorUpdate orig_conv;
11571         orig_conv.inner = (void*)(orig & (~1));
11572         orig_conv.is_owned = false;
11573         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
11574         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11575         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11576         uint64_t ret_ref = (uint64_t)ret_var.inner;
11577         if (ret_var.is_owned) {
11578                 ret_ref |= 1;
11579         }
11580         return ret_ref;
11581 }
11582
11583 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
11584         LDKChannelMonitorUpdate obj_conv;
11585         obj_conv.inner = (void*)(obj & (~1));
11586         obj_conv.is_owned = false;
11587         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
11588         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11589         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11590         CVec_u8Z_free(ret_var);
11591         return ret_arr;
11592 }
11593
11594 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
11595         LDKu8slice ser_ref;
11596         ser_ref.datalen = *((uint32_t*)ser);
11597         ser_ref.data = (int8_t*)(ser + 4);
11598         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11599         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
11600         return (uint64_t)ret_conv;
11601 }
11602
11603 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
11604         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
11605         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
11606         return ret_conv;
11607 }
11608
11609 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
11610         LDKMonitorUpdateError this_obj_conv;
11611         this_obj_conv.inner = (void*)(this_obj & (~1));
11612         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11613         MonitorUpdateError_free(this_obj_conv);
11614 }
11615
11616 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
11617         LDKMonitorUpdateError orig_conv;
11618         orig_conv.inner = (void*)(orig & (~1));
11619         orig_conv.is_owned = false;
11620         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
11621         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11622         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11623         uint64_t ret_ref = (uint64_t)ret_var.inner;
11624         if (ret_var.is_owned) {
11625                 ret_ref |= 1;
11626         }
11627         return ret_ref;
11628 }
11629
11630 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
11631         if ((this_ptr & 1) != 0) return;
11632         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
11633         FREE((void*)this_ptr);
11634         MonitorEvent_free(this_ptr_conv);
11635 }
11636
11637 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
11638         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
11639         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11640         *ret_copy = MonitorEvent_clone(orig_conv);
11641         uint64_t ret_ref = (uint64_t)ret_copy;
11642         return ret_ref;
11643 }
11644
11645 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
11646         LDKHTLCUpdate this_obj_conv;
11647         this_obj_conv.inner = (void*)(this_obj & (~1));
11648         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11649         HTLCUpdate_free(this_obj_conv);
11650 }
11651
11652 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
11653         LDKHTLCUpdate orig_conv;
11654         orig_conv.inner = (void*)(orig & (~1));
11655         orig_conv.is_owned = false;
11656         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
11657         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11658         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11659         uint64_t ret_ref = (uint64_t)ret_var.inner;
11660         if (ret_var.is_owned) {
11661                 ret_ref |= 1;
11662         }
11663         return ret_ref;
11664 }
11665
11666 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
11667         LDKHTLCUpdate obj_conv;
11668         obj_conv.inner = (void*)(obj & (~1));
11669         obj_conv.is_owned = false;
11670         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
11671         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11672         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11673         CVec_u8Z_free(ret_var);
11674         return ret_arr;
11675 }
11676
11677 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
11678         LDKu8slice ser_ref;
11679         ser_ref.datalen = *((uint32_t*)ser);
11680         ser_ref.data = (int8_t*)(ser + 4);
11681         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11682         *ret_conv = HTLCUpdate_read(ser_ref);
11683         return (uint64_t)ret_conv;
11684 }
11685
11686 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
11687         LDKChannelMonitor this_obj_conv;
11688         this_obj_conv.inner = (void*)(this_obj & (~1));
11689         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11690         ChannelMonitor_free(this_obj_conv);
11691 }
11692
11693 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
11694         LDKChannelMonitor orig_conv;
11695         orig_conv.inner = (void*)(orig & (~1));
11696         orig_conv.is_owned = false;
11697         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
11698         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11699         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11700         uint64_t ret_ref = (uint64_t)ret_var.inner;
11701         if (ret_var.is_owned) {
11702                 ret_ref |= 1;
11703         }
11704         return ret_ref;
11705 }
11706
11707 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
11708         LDKChannelMonitor obj_conv;
11709         obj_conv.inner = (void*)(obj & (~1));
11710         obj_conv.is_owned = false;
11711         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
11712         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11713         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11714         CVec_u8Z_free(ret_var);
11715         return ret_arr;
11716 }
11717
11718 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) {
11719         LDKChannelMonitor this_arg_conv;
11720         this_arg_conv.inner = (void*)(this_arg & (~1));
11721         this_arg_conv.is_owned = false;
11722         LDKChannelMonitorUpdate updates_conv;
11723         updates_conv.inner = (void*)(updates & (~1));
11724         updates_conv.is_owned = false;
11725         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11726         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11727         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11728         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11729         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
11730         return (uint64_t)ret_conv;
11731 }
11732
11733 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
11734         LDKChannelMonitor this_arg_conv;
11735         this_arg_conv.inner = (void*)(this_arg & (~1));
11736         this_arg_conv.is_owned = false;
11737         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
11738         return ret_val;
11739 }
11740
11741 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
11742         LDKChannelMonitor this_arg_conv;
11743         this_arg_conv.inner = (void*)(this_arg & (~1));
11744         this_arg_conv.is_owned = false;
11745         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11746         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
11747         return (uint64_t)ret_ref;
11748 }
11749
11750 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
11751         LDKChannelMonitor this_arg_conv;
11752         this_arg_conv.inner = (void*)(this_arg & (~1));
11753         this_arg_conv.is_owned = false;
11754         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
11755         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11756         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11757         for (size_t c = 0; c < ret_var.datalen; c++) {
11758                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_54_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11759                 *ret_conv_54_ref = ret_var.data[c];
11760                 ret_arr_ptr[c] = (uint64_t)ret_conv_54_ref;
11761         }
11762         FREE(ret_var.data);
11763         return ret_arr;
11764 }
11765
11766 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
11767         LDKChannelMonitor this_arg_conv;
11768         this_arg_conv.inner = (void*)(this_arg & (~1));
11769         this_arg_conv.is_owned = false;
11770         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
11771         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
11772 }
11773
11774 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
11775         LDKChannelMonitor this_arg_conv;
11776         this_arg_conv.inner = (void*)(this_arg & (~1));
11777         this_arg_conv.is_owned = false;
11778         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
11779         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11780         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11781         for (size_t o = 0; o < ret_var.datalen; o++) {
11782                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11783                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
11784                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
11785                 ret_arr_ptr[o] = ret_conv_14_ref;
11786         }
11787         FREE(ret_var.data);
11788         return ret_arr;
11789 }
11790
11791 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
11792         LDKChannelMonitor this_arg_conv;
11793         this_arg_conv.inner = (void*)(this_arg & (~1));
11794         this_arg_conv.is_owned = false;
11795         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
11796         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11797         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11798         for (size_t h = 0; h < ret_var.datalen; h++) {
11799                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11800                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
11801                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
11802                 ret_arr_ptr[h] = ret_conv_7_ref;
11803         }
11804         FREE(ret_var.data);
11805         return ret_arr;
11806 }
11807
11808 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
11809         LDKChannelMonitor this_arg_conv;
11810         this_arg_conv.inner = (void*)(this_arg & (~1));
11811         this_arg_conv.is_owned = false;
11812         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11813         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
11814         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
11815         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
11816         for (size_t m = 0; m < ret_var.datalen; m++) {
11817                 LDKTransaction ret_conv_12_var = ret_var.data[m];
11818                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11819                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
11820                 Transaction_free(ret_conv_12_var);
11821                 ret_arr_ptr[m] = ret_conv_12_arr;
11822         }
11823         FREE(ret_var.data);
11824         return ret_arr;
11825 }
11826
11827 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) {
11828         LDKChannelMonitor this_arg_conv;
11829         this_arg_conv.inner = (void*)(this_arg & (~1));
11830         this_arg_conv.is_owned = false;
11831         unsigned char header_arr[80];
11832         CHECK(*((uint32_t*)header) == 80);
11833         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11834         unsigned char (*header_ref)[80] = &header_arr;
11835         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11836         txdata_constr.datalen = *((uint32_t*)txdata);
11837         if (txdata_constr.datalen > 0)
11838                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11839         else
11840                 txdata_constr.data = NULL;
11841         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
11842         for (size_t e = 0; e < txdata_constr.datalen; e++) {
11843                 uint32_t txdata_conv_30 = txdata_vals[e];
11844                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
11845                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
11846                 txdata_constr.data[e] = txdata_conv_30_conv;
11847         }
11848         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11849         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11850         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11851         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);
11852         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11853         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11854         for (size_t x = 0; x < ret_var.datalen; x++) {
11855                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11856                 *ret_conv_49_ref = ret_var.data[x];
11857                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
11858         }
11859         FREE(ret_var.data);
11860         return ret_arr;
11861 }
11862
11863 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) {
11864         LDKChannelMonitor this_arg_conv;
11865         this_arg_conv.inner = (void*)(this_arg & (~1));
11866         this_arg_conv.is_owned = false;
11867         unsigned char header_arr[80];
11868         CHECK(*((uint32_t*)header) == 80);
11869         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11870         unsigned char (*header_ref)[80] = &header_arr;
11871         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11872         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11873         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11874         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
11875 }
11876
11877 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) {
11878         LDKChannelMonitor this_arg_conv;
11879         this_arg_conv.inner = (void*)(this_arg & (~1));
11880         this_arg_conv.is_owned = false;
11881         unsigned char header_arr[80];
11882         CHECK(*((uint32_t*)header) == 80);
11883         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11884         unsigned char (*header_ref)[80] = &header_arr;
11885         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11886         txdata_constr.datalen = *((uint32_t*)txdata);
11887         if (txdata_constr.datalen > 0)
11888                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11889         else
11890                 txdata_constr.data = NULL;
11891         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
11892         for (size_t e = 0; e < txdata_constr.datalen; e++) {
11893                 uint32_t txdata_conv_30 = txdata_vals[e];
11894                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
11895                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
11896                 txdata_constr.data[e] = txdata_conv_30_conv;
11897         }
11898         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11899         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11900         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11901         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);
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 x = 0; x < ret_var.datalen; x++) {
11905                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11906                 *ret_conv_49_ref = ret_var.data[x];
11907                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
11908         }
11909         FREE(ret_var.data);
11910         return ret_arr;
11911 }
11912
11913 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) {
11914         LDKChannelMonitor this_arg_conv;
11915         this_arg_conv.inner = (void*)(this_arg & (~1));
11916         this_arg_conv.is_owned = false;
11917         unsigned char txid_arr[32];
11918         CHECK(*((uint32_t*)txid) == 32);
11919         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
11920         unsigned char (*txid_ref)[32] = &txid_arr;
11921         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11922         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11923         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11924         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
11925 }
11926
11927 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) {
11928         LDKChannelMonitor this_arg_conv;
11929         this_arg_conv.inner = (void*)(this_arg & (~1));
11930         this_arg_conv.is_owned = false;
11931         unsigned char header_arr[80];
11932         CHECK(*((uint32_t*)header) == 80);
11933         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11934         unsigned char (*header_ref)[80] = &header_arr;
11935         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11936         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11937         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11938         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
11939         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11940         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11941         for (size_t x = 0; x < ret_var.datalen; x++) {
11942                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11943                 *ret_conv_49_ref = ret_var.data[x];
11944                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
11945         }
11946         FREE(ret_var.data);
11947         return ret_arr;
11948 }
11949
11950 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
11951         LDKChannelMonitor this_arg_conv;
11952         this_arg_conv.inner = (void*)(this_arg & (~1));
11953         this_arg_conv.is_owned = false;
11954         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
11955         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
11956         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
11957         for (size_t m = 0; m < ret_var.datalen; m++) {
11958                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11959                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
11960                 ret_arr_ptr[m] = ret_conv_12_arr;
11961         }
11962         FREE(ret_var.data);
11963         return ret_arr;
11964 }
11965
11966 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
11967         if ((this_ptr & 1) != 0) return;
11968         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
11969         FREE((void*)this_ptr);
11970         Persist_free(this_ptr_conv);
11971 }
11972
11973 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
11974         LDKu8slice ser_ref;
11975         ser_ref.datalen = *((uint32_t*)ser);
11976         ser_ref.data = (int8_t*)(ser + 4);
11977         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
11978         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11979         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
11980         return (uint64_t)ret_conv;
11981 }
11982
11983 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
11984         LDKOutPoint this_obj_conv;
11985         this_obj_conv.inner = (void*)(this_obj & (~1));
11986         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11987         OutPoint_free(this_obj_conv);
11988 }
11989
11990 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
11991         LDKOutPoint this_ptr_conv;
11992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11993         this_ptr_conv.is_owned = false;
11994         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11995         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
11996         return ret_arr;
11997 }
11998
11999 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
12000         LDKOutPoint this_ptr_conv;
12001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12002         this_ptr_conv.is_owned = false;
12003         LDKThirtyTwoBytes val_ref;
12004         CHECK(*((uint32_t*)val) == 32);
12005         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12006         OutPoint_set_txid(&this_ptr_conv, val_ref);
12007 }
12008
12009 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
12010         LDKOutPoint this_ptr_conv;
12011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12012         this_ptr_conv.is_owned = false;
12013         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
12014         return ret_val;
12015 }
12016
12017 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
12018         LDKOutPoint this_ptr_conv;
12019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12020         this_ptr_conv.is_owned = false;
12021         OutPoint_set_index(&this_ptr_conv, val);
12022 }
12023
12024 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
12025         LDKThirtyTwoBytes txid_arg_ref;
12026         CHECK(*((uint32_t*)txid_arg) == 32);
12027         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
12028         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
12029         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12030         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12031         uint64_t ret_ref = (uint64_t)ret_var.inner;
12032         if (ret_var.is_owned) {
12033                 ret_ref |= 1;
12034         }
12035         return ret_ref;
12036 }
12037
12038 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
12039         LDKOutPoint orig_conv;
12040         orig_conv.inner = (void*)(orig & (~1));
12041         orig_conv.is_owned = false;
12042         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
12043         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12044         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12045         uint64_t ret_ref = (uint64_t)ret_var.inner;
12046         if (ret_var.is_owned) {
12047                 ret_ref |= 1;
12048         }
12049         return ret_ref;
12050 }
12051
12052 jboolean  __attribute__((visibility("default"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
12053         LDKOutPoint a_conv;
12054         a_conv.inner = (void*)(a & (~1));
12055         a_conv.is_owned = false;
12056         LDKOutPoint b_conv;
12057         b_conv.inner = (void*)(b & (~1));
12058         b_conv.is_owned = false;
12059         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
12060         return ret_val;
12061 }
12062
12063 int64_t  __attribute__((visibility("default"))) TS_OutPoint_hash(uint32_t o) {
12064         LDKOutPoint o_conv;
12065         o_conv.inner = (void*)(o & (~1));
12066         o_conv.is_owned = false;
12067         int64_t ret_val = OutPoint_hash(&o_conv);
12068         return ret_val;
12069 }
12070
12071 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
12072         LDKOutPoint this_arg_conv;
12073         this_arg_conv.inner = (void*)(this_arg & (~1));
12074         this_arg_conv.is_owned = false;
12075         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12076         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
12077         return ret_arr;
12078 }
12079
12080 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
12081         LDKOutPoint obj_conv;
12082         obj_conv.inner = (void*)(obj & (~1));
12083         obj_conv.is_owned = false;
12084         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
12085         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12086         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12087         CVec_u8Z_free(ret_var);
12088         return ret_arr;
12089 }
12090
12091 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
12092         LDKu8slice ser_ref;
12093         ser_ref.datalen = *((uint32_t*)ser);
12094         ser_ref.data = (int8_t*)(ser + 4);
12095         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12096         *ret_conv = OutPoint_read(ser_ref);
12097         return (uint64_t)ret_conv;
12098 }
12099
12100 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
12101         LDKDelayedPaymentOutputDescriptor this_obj_conv;
12102         this_obj_conv.inner = (void*)(this_obj & (~1));
12103         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12104         DelayedPaymentOutputDescriptor_free(this_obj_conv);
12105 }
12106
12107 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
12108         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12110         this_ptr_conv.is_owned = false;
12111         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
12112         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12113         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12114         uint64_t ret_ref = (uint64_t)ret_var.inner;
12115         if (ret_var.is_owned) {
12116                 ret_ref |= 1;
12117         }
12118         return ret_ref;
12119 }
12120
12121 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
12122         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12124         this_ptr_conv.is_owned = false;
12125         LDKOutPoint val_conv;
12126         val_conv.inner = (void*)(val & (~1));
12127         val_conv.is_owned = (val & 1) || (val == 0);
12128         val_conv = OutPoint_clone(&val_conv);
12129         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
12130 }
12131
12132 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
12133         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12135         this_ptr_conv.is_owned = false;
12136         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12137         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12138         return ret_arr;
12139 }
12140
12141 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12142         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12144         this_ptr_conv.is_owned = false;
12145         LDKPublicKey val_ref;
12146         CHECK(*((uint32_t*)val) == 33);
12147         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12148         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
12149 }
12150
12151 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
12152         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12154         this_ptr_conv.is_owned = false;
12155         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
12156         return ret_val;
12157 }
12158
12159 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
12160         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12162         this_ptr_conv.is_owned = false;
12163         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
12164 }
12165
12166 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
12167         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12169         this_ptr_conv.is_owned = false;
12170         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
12171         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
12172 }
12173
12174 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
12175         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12177         this_ptr_conv.is_owned = false;
12178         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12179         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
12180         return ret_arr;
12181 }
12182
12183 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
12184         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12186         this_ptr_conv.is_owned = false;
12187         LDKPublicKey val_ref;
12188         CHECK(*((uint32_t*)val) == 33);
12189         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12190         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
12191 }
12192
12193 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
12194         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12196         this_ptr_conv.is_owned = false;
12197         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12198         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
12199         return ret_arr;
12200 }
12201
12202 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
12203         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12205         this_ptr_conv.is_owned = false;
12206         LDKThirtyTwoBytes val_ref;
12207         CHECK(*((uint32_t*)val) == 32);
12208         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12209         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
12210 }
12211
12212 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
12213         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12215         this_ptr_conv.is_owned = false;
12216         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
12217         return ret_val;
12218 }
12219
12220 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
12221         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12223         this_ptr_conv.is_owned = false;
12224         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
12225 }
12226
12227 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) {
12228         LDKOutPoint outpoint_arg_conv;
12229         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12230         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12231         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12232         LDKPublicKey per_commitment_point_arg_ref;
12233         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
12234         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
12235         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
12236         LDKPublicKey revocation_pubkey_arg_ref;
12237         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
12238         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
12239         LDKThirtyTwoBytes channel_keys_id_arg_ref;
12240         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
12241         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
12242         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);
12243         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12244         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12245         uint64_t ret_ref = (uint64_t)ret_var.inner;
12246         if (ret_var.is_owned) {
12247                 ret_ref |= 1;
12248         }
12249         return ret_ref;
12250 }
12251
12252 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
12253         LDKDelayedPaymentOutputDescriptor orig_conv;
12254         orig_conv.inner = (void*)(orig & (~1));
12255         orig_conv.is_owned = false;
12256         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
12257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12259         uint64_t ret_ref = (uint64_t)ret_var.inner;
12260         if (ret_var.is_owned) {
12261                 ret_ref |= 1;
12262         }
12263         return ret_ref;
12264 }
12265
12266 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
12267         LDKDelayedPaymentOutputDescriptor obj_conv;
12268         obj_conv.inner = (void*)(obj & (~1));
12269         obj_conv.is_owned = false;
12270         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
12271         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12272         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12273         CVec_u8Z_free(ret_var);
12274         return ret_arr;
12275 }
12276
12277 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
12278         LDKu8slice ser_ref;
12279         ser_ref.datalen = *((uint32_t*)ser);
12280         ser_ref.data = (int8_t*)(ser + 4);
12281         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12282         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
12283         return (uint64_t)ret_conv;
12284 }
12285
12286 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
12287         LDKStaticPaymentOutputDescriptor this_obj_conv;
12288         this_obj_conv.inner = (void*)(this_obj & (~1));
12289         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12290         StaticPaymentOutputDescriptor_free(this_obj_conv);
12291 }
12292
12293 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
12294         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12296         this_ptr_conv.is_owned = false;
12297         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
12298         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12299         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12300         uint64_t ret_ref = (uint64_t)ret_var.inner;
12301         if (ret_var.is_owned) {
12302                 ret_ref |= 1;
12303         }
12304         return ret_ref;
12305 }
12306
12307 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
12308         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12310         this_ptr_conv.is_owned = false;
12311         LDKOutPoint val_conv;
12312         val_conv.inner = (void*)(val & (~1));
12313         val_conv.is_owned = (val & 1) || (val == 0);
12314         val_conv = OutPoint_clone(&val_conv);
12315         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
12316 }
12317
12318 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
12319         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12321         this_ptr_conv.is_owned = false;
12322         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
12323         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
12324 }
12325
12326 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
12327         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12329         this_ptr_conv.is_owned = false;
12330         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12331         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
12332         return ret_arr;
12333 }
12334
12335 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
12336         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12338         this_ptr_conv.is_owned = false;
12339         LDKThirtyTwoBytes val_ref;
12340         CHECK(*((uint32_t*)val) == 32);
12341         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12342         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
12343 }
12344
12345 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
12346         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12348         this_ptr_conv.is_owned = false;
12349         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
12350         return ret_val;
12351 }
12352
12353 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
12354         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12356         this_ptr_conv.is_owned = false;
12357         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
12358 }
12359
12360 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) {
12361         LDKOutPoint outpoint_arg_conv;
12362         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12363         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12364         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12365         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
12366         LDKThirtyTwoBytes channel_keys_id_arg_ref;
12367         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
12368         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
12369         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
12370         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12371         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12372         uint64_t ret_ref = (uint64_t)ret_var.inner;
12373         if (ret_var.is_owned) {
12374                 ret_ref |= 1;
12375         }
12376         return ret_ref;
12377 }
12378
12379 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
12380         LDKStaticPaymentOutputDescriptor orig_conv;
12381         orig_conv.inner = (void*)(orig & (~1));
12382         orig_conv.is_owned = false;
12383         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
12384         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12385         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12386         uint64_t ret_ref = (uint64_t)ret_var.inner;
12387         if (ret_var.is_owned) {
12388                 ret_ref |= 1;
12389         }
12390         return ret_ref;
12391 }
12392
12393 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
12394         LDKStaticPaymentOutputDescriptor obj_conv;
12395         obj_conv.inner = (void*)(obj & (~1));
12396         obj_conv.is_owned = false;
12397         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
12398         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12399         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12400         CVec_u8Z_free(ret_var);
12401         return ret_arr;
12402 }
12403
12404 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
12405         LDKu8slice ser_ref;
12406         ser_ref.datalen = *((uint32_t*)ser);
12407         ser_ref.data = (int8_t*)(ser + 4);
12408         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
12409         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
12410         return (uint64_t)ret_conv;
12411 }
12412
12413 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
12414         if ((this_ptr & 1) != 0) return;
12415         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
12416         FREE((void*)this_ptr);
12417         SpendableOutputDescriptor_free(this_ptr_conv);
12418 }
12419
12420 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
12421         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
12422         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
12423         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
12424         uint64_t ret_ref = (uint64_t)ret_copy;
12425         return ret_ref;
12426 }
12427
12428 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
12429         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
12430         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
12431         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12432         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12433         CVec_u8Z_free(ret_var);
12434         return ret_arr;
12435 }
12436
12437 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
12438         LDKu8slice ser_ref;
12439         ser_ref.datalen = *((uint32_t*)ser);
12440         ser_ref.data = (int8_t*)(ser + 4);
12441         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
12442         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
12443         return (uint64_t)ret_conv;
12444 }
12445
12446 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
12447         if ((this_ptr & 1) != 0) return;
12448         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
12449         FREE((void*)this_ptr);
12450         BaseSign_free(this_ptr_conv);
12451 }
12452
12453 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
12454         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
12455         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12456         *ret = Sign_clone(orig_conv);
12457         return (uint64_t)ret;
12458 }
12459
12460 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
12461         if ((this_ptr & 1) != 0) return;
12462         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
12463         FREE((void*)this_ptr);
12464         Sign_free(this_ptr_conv);
12465 }
12466
12467 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
12468         if ((this_ptr & 1) != 0) return;
12469         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
12470         FREE((void*)this_ptr);
12471         KeysInterface_free(this_ptr_conv);
12472 }
12473
12474 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
12475         LDKInMemorySigner this_obj_conv;
12476         this_obj_conv.inner = (void*)(this_obj & (~1));
12477         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12478         InMemorySigner_free(this_obj_conv);
12479 }
12480
12481 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
12482         LDKInMemorySigner this_ptr_conv;
12483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12484         this_ptr_conv.is_owned = false;
12485         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12486         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
12487         return ret_arr;
12488 }
12489
12490 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
12491         LDKInMemorySigner this_ptr_conv;
12492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12493         this_ptr_conv.is_owned = false;
12494         LDKSecretKey val_ref;
12495         CHECK(*((uint32_t*)val) == 32);
12496         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12497         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
12498 }
12499
12500 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
12501         LDKInMemorySigner this_ptr_conv;
12502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12503         this_ptr_conv.is_owned = false;
12504         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12505         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
12506         return ret_arr;
12507 }
12508
12509 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
12510         LDKInMemorySigner this_ptr_conv;
12511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12512         this_ptr_conv.is_owned = false;
12513         LDKSecretKey val_ref;
12514         CHECK(*((uint32_t*)val) == 32);
12515         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12516         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
12517 }
12518
12519 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
12520         LDKInMemorySigner this_ptr_conv;
12521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12522         this_ptr_conv.is_owned = false;
12523         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12524         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
12525         return ret_arr;
12526 }
12527
12528 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
12529         LDKInMemorySigner this_ptr_conv;
12530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12531         this_ptr_conv.is_owned = false;
12532         LDKSecretKey val_ref;
12533         CHECK(*((uint32_t*)val) == 32);
12534         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12535         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
12536 }
12537
12538 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
12539         LDKInMemorySigner this_ptr_conv;
12540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12541         this_ptr_conv.is_owned = false;
12542         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12543         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
12544         return ret_arr;
12545 }
12546
12547 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
12548         LDKInMemorySigner this_ptr_conv;
12549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12550         this_ptr_conv.is_owned = false;
12551         LDKSecretKey val_ref;
12552         CHECK(*((uint32_t*)val) == 32);
12553         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12554         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
12555 }
12556
12557 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
12558         LDKInMemorySigner this_ptr_conv;
12559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12560         this_ptr_conv.is_owned = false;
12561         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12562         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
12563         return ret_arr;
12564 }
12565
12566 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
12567         LDKInMemorySigner this_ptr_conv;
12568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12569         this_ptr_conv.is_owned = false;
12570         LDKSecretKey val_ref;
12571         CHECK(*((uint32_t*)val) == 32);
12572         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12573         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
12574 }
12575
12576 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
12577         LDKInMemorySigner this_ptr_conv;
12578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12579         this_ptr_conv.is_owned = false;
12580         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12581         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
12582         return ret_arr;
12583 }
12584
12585 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
12586         LDKInMemorySigner this_ptr_conv;
12587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12588         this_ptr_conv.is_owned = false;
12589         LDKThirtyTwoBytes val_ref;
12590         CHECK(*((uint32_t*)val) == 32);
12591         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12592         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
12593 }
12594
12595 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
12596         LDKInMemorySigner orig_conv;
12597         orig_conv.inner = (void*)(orig & (~1));
12598         orig_conv.is_owned = false;
12599         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
12600         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12601         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12602         uint64_t ret_ref = (uint64_t)ret_var.inner;
12603         if (ret_var.is_owned) {
12604                 ret_ref |= 1;
12605         }
12606         return ret_ref;
12607 }
12608
12609 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) {
12610         LDKSecretKey funding_key_ref;
12611         CHECK(*((uint32_t*)funding_key) == 32);
12612         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
12613         LDKSecretKey revocation_base_key_ref;
12614         CHECK(*((uint32_t*)revocation_base_key) == 32);
12615         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
12616         LDKSecretKey payment_key_ref;
12617         CHECK(*((uint32_t*)payment_key) == 32);
12618         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
12619         LDKSecretKey delayed_payment_base_key_ref;
12620         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
12621         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
12622         LDKSecretKey htlc_base_key_ref;
12623         CHECK(*((uint32_t*)htlc_base_key) == 32);
12624         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
12625         LDKThirtyTwoBytes commitment_seed_ref;
12626         CHECK(*((uint32_t*)commitment_seed) == 32);
12627         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
12628         LDKThirtyTwoBytes channel_keys_id_ref;
12629         CHECK(*((uint32_t*)channel_keys_id) == 32);
12630         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
12631         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);
12632         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12633         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12634         uint64_t ret_ref = (uint64_t)ret_var.inner;
12635         if (ret_var.is_owned) {
12636                 ret_ref |= 1;
12637         }
12638         return ret_ref;
12639 }
12640
12641 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
12642         LDKInMemorySigner this_arg_conv;
12643         this_arg_conv.inner = (void*)(this_arg & (~1));
12644         this_arg_conv.is_owned = false;
12645         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
12646         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12647         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12648         uint64_t ret_ref = (uint64_t)ret_var.inner;
12649         if (ret_var.is_owned) {
12650                 ret_ref |= 1;
12651         }
12652         return ret_ref;
12653 }
12654
12655 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
12656         LDKInMemorySigner this_arg_conv;
12657         this_arg_conv.inner = (void*)(this_arg & (~1));
12658         this_arg_conv.is_owned = false;
12659         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
12660         return ret_val;
12661 }
12662
12663 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
12664         LDKInMemorySigner this_arg_conv;
12665         this_arg_conv.inner = (void*)(this_arg & (~1));
12666         this_arg_conv.is_owned = false;
12667         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
12668         return ret_val;
12669 }
12670
12671 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
12672         LDKInMemorySigner this_arg_conv;
12673         this_arg_conv.inner = (void*)(this_arg & (~1));
12674         this_arg_conv.is_owned = false;
12675         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
12676         return ret_val;
12677 }
12678
12679 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
12680         LDKInMemorySigner this_arg_conv;
12681         this_arg_conv.inner = (void*)(this_arg & (~1));
12682         this_arg_conv.is_owned = false;
12683         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
12684         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12685         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12686         uint64_t ret_ref = (uint64_t)ret_var.inner;
12687         if (ret_var.is_owned) {
12688                 ret_ref |= 1;
12689         }
12690         return ret_ref;
12691 }
12692
12693 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
12694         LDKInMemorySigner this_arg_conv;
12695         this_arg_conv.inner = (void*)(this_arg & (~1));
12696         this_arg_conv.is_owned = false;
12697         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
12698         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12699         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12700         uint64_t ret_ref = (uint64_t)ret_var.inner;
12701         if (ret_var.is_owned) {
12702                 ret_ref |= 1;
12703         }
12704         return ret_ref;
12705 }
12706
12707 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) {
12708         LDKInMemorySigner this_arg_conv;
12709         this_arg_conv.inner = (void*)(this_arg & (~1));
12710         this_arg_conv.is_owned = false;
12711         LDKTransaction spend_tx_ref;
12712         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
12713         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12714         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
12715         spend_tx_ref.data_is_owned = true;
12716         LDKStaticPaymentOutputDescriptor descriptor_conv;
12717         descriptor_conv.inner = (void*)(descriptor & (~1));
12718         descriptor_conv.is_owned = false;
12719         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12720         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12721         return (uint64_t)ret_conv;
12722 }
12723
12724 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) {
12725         LDKInMemorySigner this_arg_conv;
12726         this_arg_conv.inner = (void*)(this_arg & (~1));
12727         this_arg_conv.is_owned = false;
12728         LDKTransaction spend_tx_ref;
12729         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
12730         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12731         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
12732         spend_tx_ref.data_is_owned = true;
12733         LDKDelayedPaymentOutputDescriptor descriptor_conv;
12734         descriptor_conv.inner = (void*)(descriptor & (~1));
12735         descriptor_conv.is_owned = false;
12736         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12737         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12738         return (uint64_t)ret_conv;
12739 }
12740
12741 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
12742         LDKInMemorySigner this_arg_conv;
12743         this_arg_conv.inner = (void*)(this_arg & (~1));
12744         this_arg_conv.is_owned = false;
12745         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
12746         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
12747         return (uint64_t)ret;
12748 }
12749
12750 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
12751         LDKInMemorySigner this_arg_conv;
12752         this_arg_conv.inner = (void*)(this_arg & (~1));
12753         this_arg_conv.is_owned = false;
12754         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12755         *ret = InMemorySigner_as_Sign(&this_arg_conv);
12756         return (uint64_t)ret;
12757 }
12758
12759 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
12760         LDKInMemorySigner obj_conv;
12761         obj_conv.inner = (void*)(obj & (~1));
12762         obj_conv.is_owned = false;
12763         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
12764         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12765         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12766         CVec_u8Z_free(ret_var);
12767         return ret_arr;
12768 }
12769
12770 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
12771         LDKu8slice ser_ref;
12772         ser_ref.datalen = *((uint32_t*)ser);
12773         ser_ref.data = (int8_t*)(ser + 4);
12774         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
12775         *ret_conv = InMemorySigner_read(ser_ref);
12776         return (uint64_t)ret_conv;
12777 }
12778
12779 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
12780         LDKKeysManager this_obj_conv;
12781         this_obj_conv.inner = (void*)(this_obj & (~1));
12782         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12783         KeysManager_free(this_obj_conv);
12784 }
12785
12786 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
12787         unsigned char seed_arr[32];
12788         CHECK(*((uint32_t*)seed) == 32);
12789         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
12790         unsigned char (*seed_ref)[32] = &seed_arr;
12791         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
12792         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12793         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12794         uint64_t ret_ref = (uint64_t)ret_var.inner;
12795         if (ret_var.is_owned) {
12796                 ret_ref |= 1;
12797         }
12798         return ret_ref;
12799 }
12800
12801 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
12802         LDKKeysManager this_arg_conv;
12803         this_arg_conv.inner = (void*)(this_arg & (~1));
12804         this_arg_conv.is_owned = false;
12805         unsigned char params_arr[32];
12806         CHECK(*((uint32_t*)params) == 32);
12807         memcpy(params_arr, (uint8_t*)(params + 4), 32);
12808         unsigned char (*params_ref)[32] = &params_arr;
12809         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
12810         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12811         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12812         uint64_t ret_ref = (uint64_t)ret_var.inner;
12813         if (ret_var.is_owned) {
12814                 ret_ref |= 1;
12815         }
12816         return ret_ref;
12817 }
12818
12819 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) {
12820         LDKKeysManager this_arg_conv;
12821         this_arg_conv.inner = (void*)(this_arg & (~1));
12822         this_arg_conv.is_owned = false;
12823         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
12824         descriptors_constr.datalen = *((uint32_t*)descriptors);
12825         if (descriptors_constr.datalen > 0)
12826                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12827         else
12828                 descriptors_constr.data = NULL;
12829         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
12830         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
12831                 uint32_t descriptors_conv_27 = descriptors_vals[b];
12832                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
12833                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
12834                 descriptors_constr.data[b] = descriptors_conv_27_conv;
12835         }
12836         LDKCVec_TxOutZ outputs_constr;
12837         outputs_constr.datalen = *((uint32_t*)outputs);
12838         if (outputs_constr.datalen > 0)
12839                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
12840         else
12841                 outputs_constr.data = NULL;
12842         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
12843         for (size_t h = 0; h < outputs_constr.datalen; h++) {
12844                 uint32_t outputs_conv_7 = outputs_vals[h];
12845                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
12846                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
12847                 outputs_constr.data[h] = outputs_conv_7_conv;
12848         }
12849         LDKCVec_u8Z change_destination_script_ref;
12850         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
12851         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
12852         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
12853         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
12854         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
12855         return (uint64_t)ret_conv;
12856 }
12857
12858 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
12859         LDKKeysManager this_arg_conv;
12860         this_arg_conv.inner = (void*)(this_arg & (~1));
12861         this_arg_conv.is_owned = false;
12862         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
12863         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
12864         return (uint64_t)ret;
12865 }
12866
12867 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
12868         LDKChannelManager this_obj_conv;
12869         this_obj_conv.inner = (void*)(this_obj & (~1));
12870         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12871         ChannelManager_free(this_obj_conv);
12872 }
12873
12874 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
12875         LDKChainParameters this_obj_conv;
12876         this_obj_conv.inner = (void*)(this_obj & (~1));
12877         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12878         ChainParameters_free(this_obj_conv);
12879 }
12880
12881 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
12882         LDKChainParameters this_ptr_conv;
12883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12884         this_ptr_conv.is_owned = false;
12885         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
12886         return ret_conv;
12887 }
12888
12889 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
12890         LDKChainParameters this_ptr_conv;
12891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12892         this_ptr_conv.is_owned = false;
12893         LDKNetwork val_conv = LDKNetwork_from_js(val);
12894         ChainParameters_set_network(&this_ptr_conv, val_conv);
12895 }
12896
12897 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
12898         LDKChainParameters this_ptr_conv;
12899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12900         this_ptr_conv.is_owned = false;
12901         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
12902         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12903         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12904         uint64_t ret_ref = (uint64_t)ret_var.inner;
12905         if (ret_var.is_owned) {
12906                 ret_ref |= 1;
12907         }
12908         return ret_ref;
12909 }
12910
12911 void  __attribute__((visibility("default"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
12912         LDKChainParameters this_ptr_conv;
12913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12914         this_ptr_conv.is_owned = false;
12915         LDKBestBlock val_conv;
12916         val_conv.inner = (void*)(val & (~1));
12917         val_conv.is_owned = (val & 1) || (val == 0);
12918         val_conv = BestBlock_clone(&val_conv);
12919         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
12920 }
12921
12922 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
12923         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
12924         LDKBestBlock best_block_arg_conv;
12925         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
12926         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
12927         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
12928         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
12929         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12930         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12931         uint64_t ret_ref = (uint64_t)ret_var.inner;
12932         if (ret_var.is_owned) {
12933                 ret_ref |= 1;
12934         }
12935         return ret_ref;
12936 }
12937
12938 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32_t orig) {
12939         LDKChainParameters orig_conv;
12940         orig_conv.inner = (void*)(orig & (~1));
12941         orig_conv.is_owned = false;
12942         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
12943         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12944         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12945         uint64_t ret_ref = (uint64_t)ret_var.inner;
12946         if (ret_var.is_owned) {
12947                 ret_ref |= 1;
12948         }
12949         return ret_ref;
12950 }
12951
12952 void  __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) {
12953         LDKBestBlock this_obj_conv;
12954         this_obj_conv.inner = (void*)(this_obj & (~1));
12955         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12956         BestBlock_free(this_obj_conv);
12957 }
12958
12959 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) {
12960         LDKBestBlock orig_conv;
12961         orig_conv.inner = (void*)(orig & (~1));
12962         orig_conv.is_owned = false;
12963         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
12964         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12965         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12966         uint64_t ret_ref = (uint64_t)ret_var.inner;
12967         if (ret_var.is_owned) {
12968                 ret_ref |= 1;
12969         }
12970         return ret_ref;
12971 }
12972
12973 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
12974         LDKNetwork network_conv = LDKNetwork_from_js(network);
12975         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
12976         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12977         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12978         uint64_t ret_ref = (uint64_t)ret_var.inner;
12979         if (ret_var.is_owned) {
12980                 ret_ref |= 1;
12981         }
12982         return ret_ref;
12983 }
12984
12985 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
12986         LDKThirtyTwoBytes block_hash_ref;
12987         CHECK(*((uint32_t*)block_hash) == 32);
12988         memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
12989         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
12990         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12991         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12992         uint64_t ret_ref = (uint64_t)ret_var.inner;
12993         if (ret_var.is_owned) {
12994                 ret_ref |= 1;
12995         }
12996         return ret_ref;
12997 }
12998
12999 int8_tArray  __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) {
13000         LDKBestBlock this_arg_conv;
13001         this_arg_conv.inner = (void*)(this_arg & (~1));
13002         this_arg_conv.is_owned = false;
13003         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13004         memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32);
13005         return ret_arr;
13006 }
13007
13008 int32_t  __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) {
13009         LDKBestBlock this_arg_conv;
13010         this_arg_conv.inner = (void*)(this_arg & (~1));
13011         this_arg_conv.is_owned = false;
13012         int32_t ret_val = BestBlock_height(&this_arg_conv);
13013         return ret_val;
13014 }
13015
13016 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
13017         LDKChannelDetails this_obj_conv;
13018         this_obj_conv.inner = (void*)(this_obj & (~1));
13019         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13020         ChannelDetails_free(this_obj_conv);
13021 }
13022
13023 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
13024         LDKChannelDetails this_ptr_conv;
13025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13026         this_ptr_conv.is_owned = false;
13027         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13028         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
13029         return ret_arr;
13030 }
13031
13032 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13033         LDKChannelDetails this_ptr_conv;
13034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13035         this_ptr_conv.is_owned = false;
13036         LDKThirtyTwoBytes val_ref;
13037         CHECK(*((uint32_t*)val) == 32);
13038         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13039         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
13040 }
13041
13042 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
13043         LDKChannelDetails this_ptr_conv;
13044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13045         this_ptr_conv.is_owned = false;
13046         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
13047         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13048         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13049         uint64_t ret_ref = (uint64_t)ret_var.inner;
13050         if (ret_var.is_owned) {
13051                 ret_ref |= 1;
13052         }
13053         return ret_ref;
13054 }
13055
13056 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
13057         LDKChannelDetails this_ptr_conv;
13058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13059         this_ptr_conv.is_owned = false;
13060         LDKOutPoint val_conv;
13061         val_conv.inner = (void*)(val & (~1));
13062         val_conv.is_owned = (val & 1) || (val == 0);
13063         val_conv = OutPoint_clone(&val_conv);
13064         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
13065 }
13066
13067 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
13068         LDKChannelDetails this_ptr_conv;
13069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13070         this_ptr_conv.is_owned = false;
13071         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
13072         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
13073         uint64_t ret_ref = (uint64_t)ret_copy;
13074         return ret_ref;
13075 }
13076
13077 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
13078         LDKChannelDetails this_ptr_conv;
13079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13080         this_ptr_conv.is_owned = false;
13081         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
13082         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
13083 }
13084
13085 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_remote_network_id(uint32_t this_ptr) {
13086         LDKChannelDetails this_ptr_conv;
13087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13088         this_ptr_conv.is_owned = false;
13089         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13090         memcpy((uint8_t*)(ret_arr + 4), ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33);
13091         return ret_arr;
13092 }
13093
13094 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_remote_network_id(uint32_t this_ptr, int8_tArray val) {
13095         LDKChannelDetails this_ptr_conv;
13096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13097         this_ptr_conv.is_owned = false;
13098         LDKPublicKey val_ref;
13099         CHECK(*((uint32_t*)val) == 33);
13100         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13101         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
13102 }
13103
13104 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty_features(uint32_t this_ptr) {
13105         LDKChannelDetails this_ptr_conv;
13106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13107         this_ptr_conv.is_owned = false;
13108         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
13109         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13110         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13111         uint64_t ret_ref = (uint64_t)ret_var.inner;
13112         if (ret_var.is_owned) {
13113                 ret_ref |= 1;
13114         }
13115         return ret_ref;
13116 }
13117
13118 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty_features(uint32_t this_ptr, uint32_t val) {
13119         LDKChannelDetails this_ptr_conv;
13120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13121         this_ptr_conv.is_owned = false;
13122         LDKInitFeatures val_conv;
13123         val_conv.inner = (void*)(val & (~1));
13124         val_conv.is_owned = (val & 1) || (val == 0);
13125         val_conv = InitFeatures_clone(&val_conv);
13126         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
13127 }
13128
13129 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
13130         LDKChannelDetails this_ptr_conv;
13131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13132         this_ptr_conv.is_owned = false;
13133         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
13134         return ret_val;
13135 }
13136
13137 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
13138         LDKChannelDetails this_ptr_conv;
13139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13140         this_ptr_conv.is_owned = false;
13141         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
13142 }
13143
13144 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
13145         LDKChannelDetails this_ptr_conv;
13146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13147         this_ptr_conv.is_owned = false;
13148         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
13149         return ret_val;
13150 }
13151
13152 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
13153         LDKChannelDetails this_ptr_conv;
13154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13155         this_ptr_conv.is_owned = false;
13156         ChannelDetails_set_user_id(&this_ptr_conv, val);
13157 }
13158
13159 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
13160         LDKChannelDetails this_ptr_conv;
13161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13162         this_ptr_conv.is_owned = false;
13163         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
13164         return ret_val;
13165 }
13166
13167 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
13168         LDKChannelDetails this_ptr_conv;
13169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13170         this_ptr_conv.is_owned = false;
13171         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
13172 }
13173
13174 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
13175         LDKChannelDetails this_ptr_conv;
13176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13177         this_ptr_conv.is_owned = false;
13178         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
13179         return ret_val;
13180 }
13181
13182 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
13183         LDKChannelDetails this_ptr_conv;
13184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13185         this_ptr_conv.is_owned = false;
13186         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
13187 }
13188
13189 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
13190         LDKChannelDetails this_ptr_conv;
13191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13192         this_ptr_conv.is_owned = false;
13193         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
13194         return ret_val;
13195 }
13196
13197 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
13198         LDKChannelDetails this_ptr_conv;
13199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13200         this_ptr_conv.is_owned = false;
13201         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
13202 }
13203
13204 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
13205         LDKChannelDetails this_ptr_conv;
13206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13207         this_ptr_conv.is_owned = false;
13208         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
13209         return ret_val;
13210 }
13211
13212 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
13213         LDKChannelDetails this_ptr_conv;
13214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13215         this_ptr_conv.is_owned = false;
13216         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
13217 }
13218
13219 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_usable(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         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
13224         return ret_val;
13225 }
13226
13227 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
13228         LDKChannelDetails this_ptr_conv;
13229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13230         this_ptr_conv.is_owned = false;
13231         ChannelDetails_set_is_usable(&this_ptr_conv, val);
13232 }
13233
13234 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
13235         LDKChannelDetails this_ptr_conv;
13236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13237         this_ptr_conv.is_owned = false;
13238         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
13239         return ret_val;
13240 }
13241
13242 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
13243         LDKChannelDetails this_ptr_conv;
13244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13245         this_ptr_conv.is_owned = false;
13246         ChannelDetails_set_is_public(&this_ptr_conv, val);
13247 }
13248
13249 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
13250         LDKChannelDetails orig_conv;
13251         orig_conv.inner = (void*)(orig & (~1));
13252         orig_conv.is_owned = false;
13253         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
13254         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13255         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13256         uint64_t ret_ref = (uint64_t)ret_var.inner;
13257         if (ret_var.is_owned) {
13258                 ret_ref |= 1;
13259         }
13260         return ret_ref;
13261 }
13262
13263 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
13264         if ((this_ptr & 1) != 0) return;
13265         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
13266         FREE((void*)this_ptr);
13267         PaymentSendFailure_free(this_ptr_conv);
13268 }
13269
13270 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
13271         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
13272         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
13273         *ret_copy = PaymentSendFailure_clone(orig_conv);
13274         uint64_t ret_ref = (uint64_t)ret_copy;
13275         return ret_ref;
13276 }
13277
13278 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) {
13279         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
13280         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
13281         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
13282         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13283         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
13284         LDKUserConfig config_conv;
13285         config_conv.inner = (void*)(config & (~1));
13286         config_conv.is_owned = (config & 1) || (config == 0);
13287         config_conv = UserConfig_clone(&config_conv);
13288         LDKChainParameters params_conv;
13289         params_conv.inner = (void*)(params & (~1));
13290         params_conv.is_owned = (params & 1) || (params == 0);
13291         params_conv = ChainParameters_clone(&params_conv);
13292         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
13293         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13294         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13295         uint64_t ret_ref = (uint64_t)ret_var.inner;
13296         if (ret_var.is_owned) {
13297                 ret_ref |= 1;
13298         }
13299         return ret_ref;
13300 }
13301
13302 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
13303         LDKChannelManager this_arg_conv;
13304         this_arg_conv.inner = (void*)(this_arg & (~1));
13305         this_arg_conv.is_owned = false;
13306         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
13307         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13308         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13309         uint64_t ret_ref = (uint64_t)ret_var.inner;
13310         if (ret_var.is_owned) {
13311                 ret_ref |= 1;
13312         }
13313         return ret_ref;
13314 }
13315
13316 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) {
13317         LDKChannelManager this_arg_conv;
13318         this_arg_conv.inner = (void*)(this_arg & (~1));
13319         this_arg_conv.is_owned = false;
13320         LDKPublicKey their_network_key_ref;
13321         CHECK(*((uint32_t*)their_network_key) == 33);
13322         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
13323         LDKUserConfig override_config_conv;
13324         override_config_conv.inner = (void*)(override_config & (~1));
13325         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
13326         override_config_conv = UserConfig_clone(&override_config_conv);
13327         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13328         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
13329         return (uint64_t)ret_conv;
13330 }
13331
13332 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
13333         LDKChannelManager this_arg_conv;
13334         this_arg_conv.inner = (void*)(this_arg & (~1));
13335         this_arg_conv.is_owned = false;
13336         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
13337         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13338         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13339         for (size_t q = 0; q < ret_var.datalen; q++) {
13340                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13341                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13342                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13343                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
13344                 if (ret_conv_16_var.is_owned) {
13345                         ret_conv_16_ref |= 1;
13346                 }
13347                 ret_arr_ptr[q] = ret_conv_16_ref;
13348         }
13349         FREE(ret_var.data);
13350         return ret_arr;
13351 }
13352
13353 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
13354         LDKChannelManager this_arg_conv;
13355         this_arg_conv.inner = (void*)(this_arg & (~1));
13356         this_arg_conv.is_owned = false;
13357         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
13358         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13359         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13360         for (size_t q = 0; q < ret_var.datalen; q++) {
13361                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13362                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13363                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13364                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
13365                 if (ret_conv_16_var.is_owned) {
13366                         ret_conv_16_ref |= 1;
13367                 }
13368                 ret_arr_ptr[q] = ret_conv_16_ref;
13369         }
13370         FREE(ret_var.data);
13371         return ret_arr;
13372 }
13373
13374 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
13375         LDKChannelManager this_arg_conv;
13376         this_arg_conv.inner = (void*)(this_arg & (~1));
13377         this_arg_conv.is_owned = false;
13378         unsigned char channel_id_arr[32];
13379         CHECK(*((uint32_t*)channel_id) == 32);
13380         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
13381         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
13382         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13383         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
13384         return (uint64_t)ret_conv;
13385 }
13386
13387 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
13388         LDKChannelManager this_arg_conv;
13389         this_arg_conv.inner = (void*)(this_arg & (~1));
13390         this_arg_conv.is_owned = false;
13391         unsigned char channel_id_arr[32];
13392         CHECK(*((uint32_t*)channel_id) == 32);
13393         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
13394         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
13395         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13396         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
13397         return (uint64_t)ret_conv;
13398 }
13399
13400 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
13401         LDKChannelManager this_arg_conv;
13402         this_arg_conv.inner = (void*)(this_arg & (~1));
13403         this_arg_conv.is_owned = false;
13404         ChannelManager_force_close_all_channels(&this_arg_conv);
13405 }
13406
13407 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
13408         LDKChannelManager this_arg_conv;
13409         this_arg_conv.inner = (void*)(this_arg & (~1));
13410         this_arg_conv.is_owned = false;
13411         LDKRoute route_conv;
13412         route_conv.inner = (void*)(route & (~1));
13413         route_conv.is_owned = false;
13414         LDKThirtyTwoBytes payment_hash_ref;
13415         CHECK(*((uint32_t*)payment_hash) == 32);
13416         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
13417         LDKThirtyTwoBytes payment_secret_ref;
13418         CHECK(*((uint32_t*)payment_secret) == 32);
13419         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
13420         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13421         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
13422         return (uint64_t)ret_conv;
13423 }
13424
13425 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
13426         LDKChannelManager this_arg_conv;
13427         this_arg_conv.inner = (void*)(this_arg & (~1));
13428         this_arg_conv.is_owned = false;
13429         unsigned char temporary_channel_id_arr[32];
13430         CHECK(*((uint32_t*)temporary_channel_id) == 32);
13431         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
13432         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
13433         LDKTransaction funding_transaction_ref;
13434         funding_transaction_ref.datalen = *((uint32_t*)funding_transaction);
13435         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
13436         memcpy(funding_transaction_ref.data, (uint8_t*)(funding_transaction + 4), funding_transaction_ref.datalen);
13437         funding_transaction_ref.data_is_owned = true;
13438         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13439         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
13440         return (uint64_t)ret_conv;
13441 }
13442
13443 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
13444         LDKChannelManager this_arg_conv;
13445         this_arg_conv.inner = (void*)(this_arg & (~1));
13446         this_arg_conv.is_owned = false;
13447         LDKThreeBytes rgb_ref;
13448         CHECK(*((uint32_t*)rgb) == 3);
13449         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
13450         LDKThirtyTwoBytes alias_ref;
13451         CHECK(*((uint32_t*)alias) == 32);
13452         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
13453         LDKCVec_NetAddressZ addresses_constr;
13454         addresses_constr.datalen = *((uint32_t*)addresses);
13455         if (addresses_constr.datalen > 0)
13456                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13457         else
13458                 addresses_constr.data = NULL;
13459         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
13460         for (size_t m = 0; m < addresses_constr.datalen; m++) {
13461                 uint32_t addresses_conv_12 = addresses_vals[m];
13462                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
13463                 addresses_constr.data[m] = addresses_conv_12_conv;
13464         }
13465         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
13466 }
13467
13468 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
13469         LDKChannelManager this_arg_conv;
13470         this_arg_conv.inner = (void*)(this_arg & (~1));
13471         this_arg_conv.is_owned = false;
13472         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
13473 }
13474
13475 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
13476         LDKChannelManager this_arg_conv;
13477         this_arg_conv.inner = (void*)(this_arg & (~1));
13478         this_arg_conv.is_owned = false;
13479         ChannelManager_timer_tick_occurred(&this_arg_conv);
13480 }
13481
13482 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
13483         LDKChannelManager this_arg_conv;
13484         this_arg_conv.inner = (void*)(this_arg & (~1));
13485         this_arg_conv.is_owned = false;
13486         unsigned char payment_hash_arr[32];
13487         CHECK(*((uint32_t*)payment_hash) == 32);
13488         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
13489         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
13490         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
13491         return ret_val;
13492 }
13493
13494 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
13495         LDKChannelManager this_arg_conv;
13496         this_arg_conv.inner = (void*)(this_arg & (~1));
13497         this_arg_conv.is_owned = false;
13498         LDKThirtyTwoBytes payment_preimage_ref;
13499         CHECK(*((uint32_t*)payment_preimage) == 32);
13500         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
13501         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
13502         return ret_val;
13503 }
13504
13505 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
13506         LDKChannelManager this_arg_conv;
13507         this_arg_conv.inner = (void*)(this_arg & (~1));
13508         this_arg_conv.is_owned = false;
13509         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13510         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
13511         return ret_arr;
13512 }
13513
13514 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
13515         LDKChannelManager this_arg_conv;
13516         this_arg_conv.inner = (void*)(this_arg & (~1));
13517         this_arg_conv.is_owned = false;
13518         LDKOutPoint funding_txo_conv;
13519         funding_txo_conv.inner = (void*)(funding_txo & (~1));
13520         funding_txo_conv.is_owned = false;
13521         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
13522 }
13523
13524 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) {
13525         LDKChannelManager this_arg_conv;
13526         this_arg_conv.inner = (void*)(this_arg & (~1));
13527         this_arg_conv.is_owned = false;
13528         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
13529         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
13530         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
13531         return (uint64_t)ret_ref;
13532 }
13533
13534 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) {
13535         LDKChannelManager this_arg_conv;
13536         this_arg_conv.inner = (void*)(this_arg & (~1));
13537         this_arg_conv.is_owned = false;
13538         LDKThirtyTwoBytes payment_hash_ref;
13539         CHECK(*((uint32_t*)payment_hash) == 32);
13540         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
13541         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
13542         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
13543         *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);
13544         return (uint64_t)ret_conv;
13545 }
13546
13547 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
13548         LDKChannelManager this_arg_conv;
13549         this_arg_conv.inner = (void*)(this_arg & (~1));
13550         this_arg_conv.is_owned = false;
13551         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
13552         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
13553         return (uint64_t)ret;
13554 }
13555
13556 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
13557         LDKChannelManager this_arg_conv;
13558         this_arg_conv.inner = (void*)(this_arg & (~1));
13559         this_arg_conv.is_owned = false;
13560         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
13561         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
13562         return (uint64_t)ret;
13563 }
13564
13565 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
13566         LDKChannelManager this_arg_conv;
13567         this_arg_conv.inner = (void*)(this_arg & (~1));
13568         this_arg_conv.is_owned = false;
13569         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
13570         *ret = ChannelManager_as_Listen(&this_arg_conv);
13571         return (uint64_t)ret;
13572 }
13573
13574 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
13575         LDKChannelManager this_arg_conv;
13576         this_arg_conv.inner = (void*)(this_arg & (~1));
13577         this_arg_conv.is_owned = false;
13578         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
13579         *ret = ChannelManager_as_Confirm(&this_arg_conv);
13580         return (uint64_t)ret;
13581 }
13582
13583 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
13584         LDKChannelManager this_arg_conv;
13585         this_arg_conv.inner = (void*)(this_arg & (~1));
13586         this_arg_conv.is_owned = false;
13587         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
13588         return ret_val;
13589 }
13590
13591 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(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         ChannelManager_await_persistable_update(&this_arg_conv);
13596 }
13597
13598 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
13599         LDKChannelManager this_arg_conv;
13600         this_arg_conv.inner = (void*)(this_arg & (~1));
13601         this_arg_conv.is_owned = false;
13602         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
13603         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
13604         return (uint64_t)ret;
13605 }
13606
13607 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
13608         LDKChannelManager obj_conv;
13609         obj_conv.inner = (void*)(obj & (~1));
13610         obj_conv.is_owned = false;
13611         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
13612         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13613         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13614         CVec_u8Z_free(ret_var);
13615         return ret_arr;
13616 }
13617
13618 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
13619         LDKChannelManagerReadArgs this_obj_conv;
13620         this_obj_conv.inner = (void*)(this_obj & (~1));
13621         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13622         ChannelManagerReadArgs_free(this_obj_conv);
13623 }
13624
13625 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
13626         LDKChannelManagerReadArgs this_ptr_conv;
13627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13628         this_ptr_conv.is_owned = false;
13629         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
13630         return ret_ret;
13631 }
13632
13633 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
13634         LDKChannelManagerReadArgs this_ptr_conv;
13635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13636         this_ptr_conv.is_owned = false;
13637         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
13638         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
13639 }
13640
13641 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
13642         LDKChannelManagerReadArgs this_ptr_conv;
13643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13644         this_ptr_conv.is_owned = false;
13645         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
13646         return ret_ret;
13647 }
13648
13649 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
13650         LDKChannelManagerReadArgs this_ptr_conv;
13651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13652         this_ptr_conv.is_owned = false;
13653         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
13654         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
13655 }
13656
13657 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
13658         LDKChannelManagerReadArgs this_ptr_conv;
13659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13660         this_ptr_conv.is_owned = false;
13661         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
13662         return ret_ret;
13663 }
13664
13665 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
13666         LDKChannelManagerReadArgs this_ptr_conv;
13667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13668         this_ptr_conv.is_owned = false;
13669         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
13670         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
13671 }
13672
13673 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
13674         LDKChannelManagerReadArgs this_ptr_conv;
13675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13676         this_ptr_conv.is_owned = false;
13677         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
13678         return ret_ret;
13679 }
13680
13681 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
13682         LDKChannelManagerReadArgs this_ptr_conv;
13683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13684         this_ptr_conv.is_owned = false;
13685         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
13686         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
13687 }
13688
13689 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
13690         LDKChannelManagerReadArgs this_ptr_conv;
13691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13692         this_ptr_conv.is_owned = false;
13693         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
13694         return ret_ret;
13695 }
13696
13697 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
13698         LDKChannelManagerReadArgs this_ptr_conv;
13699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13700         this_ptr_conv.is_owned = false;
13701         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
13702         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
13703 }
13704
13705 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
13706         LDKChannelManagerReadArgs this_ptr_conv;
13707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13708         this_ptr_conv.is_owned = false;
13709         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
13710         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13711         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13712         uint64_t ret_ref = (uint64_t)ret_var.inner;
13713         if (ret_var.is_owned) {
13714                 ret_ref |= 1;
13715         }
13716         return ret_ref;
13717 }
13718
13719 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
13720         LDKChannelManagerReadArgs this_ptr_conv;
13721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13722         this_ptr_conv.is_owned = false;
13723         LDKUserConfig val_conv;
13724         val_conv.inner = (void*)(val & (~1));
13725         val_conv.is_owned = (val & 1) || (val == 0);
13726         val_conv = UserConfig_clone(&val_conv);
13727         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
13728 }
13729
13730 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) {
13731         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
13732         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13733         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
13734         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
13735         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13736         LDKUserConfig default_config_conv;
13737         default_config_conv.inner = (void*)(default_config & (~1));
13738         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
13739         default_config_conv = UserConfig_clone(&default_config_conv);
13740         LDKCVec_ChannelMonitorZ channel_monitors_constr;
13741         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
13742         if (channel_monitors_constr.datalen > 0)
13743                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
13744         else
13745                 channel_monitors_constr.data = NULL;
13746         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
13747         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
13748                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
13749                 LDKChannelMonitor channel_monitors_conv_16_conv;
13750                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
13751                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
13752                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
13753         }
13754         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);
13755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13757         uint64_t ret_ref = (uint64_t)ret_var.inner;
13758         if (ret_var.is_owned) {
13759                 ret_ref |= 1;
13760         }
13761         return ret_ref;
13762 }
13763
13764 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
13765         LDKu8slice ser_ref;
13766         ser_ref.datalen = *((uint32_t*)ser);
13767         ser_ref.data = (int8_t*)(ser + 4);
13768         LDKChannelManagerReadArgs arg_conv;
13769         arg_conv.inner = (void*)(arg & (~1));
13770         arg_conv.is_owned = (arg & 1) || (arg == 0);
13771         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
13772         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
13773         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
13774         return (uint64_t)ret_conv;
13775 }
13776
13777 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
13778         LDKDecodeError this_obj_conv;
13779         this_obj_conv.inner = (void*)(this_obj & (~1));
13780         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13781         DecodeError_free(this_obj_conv);
13782 }
13783
13784 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
13785         LDKDecodeError orig_conv;
13786         orig_conv.inner = (void*)(orig & (~1));
13787         orig_conv.is_owned = false;
13788         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
13789         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13790         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13791         uint64_t ret_ref = (uint64_t)ret_var.inner;
13792         if (ret_var.is_owned) {
13793                 ret_ref |= 1;
13794         }
13795         return ret_ref;
13796 }
13797
13798 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
13799         LDKInit this_obj_conv;
13800         this_obj_conv.inner = (void*)(this_obj & (~1));
13801         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13802         Init_free(this_obj_conv);
13803 }
13804
13805 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
13806         LDKInit this_ptr_conv;
13807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13808         this_ptr_conv.is_owned = false;
13809         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
13810         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13811         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13812         uint64_t ret_ref = (uint64_t)ret_var.inner;
13813         if (ret_var.is_owned) {
13814                 ret_ref |= 1;
13815         }
13816         return ret_ref;
13817 }
13818
13819 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
13820         LDKInit this_ptr_conv;
13821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13822         this_ptr_conv.is_owned = false;
13823         LDKInitFeatures val_conv;
13824         val_conv.inner = (void*)(val & (~1));
13825         val_conv.is_owned = (val & 1) || (val == 0);
13826         val_conv = InitFeatures_clone(&val_conv);
13827         Init_set_features(&this_ptr_conv, val_conv);
13828 }
13829
13830 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
13831         LDKInitFeatures features_arg_conv;
13832         features_arg_conv.inner = (void*)(features_arg & (~1));
13833         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
13834         features_arg_conv = InitFeatures_clone(&features_arg_conv);
13835         LDKInit ret_var = Init_new(features_arg_conv);
13836         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13837         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13838         uint64_t ret_ref = (uint64_t)ret_var.inner;
13839         if (ret_var.is_owned) {
13840                 ret_ref |= 1;
13841         }
13842         return ret_ref;
13843 }
13844
13845 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
13846         LDKInit orig_conv;
13847         orig_conv.inner = (void*)(orig & (~1));
13848         orig_conv.is_owned = false;
13849         LDKInit ret_var = Init_clone(&orig_conv);
13850         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13851         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13852         uint64_t ret_ref = (uint64_t)ret_var.inner;
13853         if (ret_var.is_owned) {
13854                 ret_ref |= 1;
13855         }
13856         return ret_ref;
13857 }
13858
13859 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
13860         LDKErrorMessage this_obj_conv;
13861         this_obj_conv.inner = (void*)(this_obj & (~1));
13862         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13863         ErrorMessage_free(this_obj_conv);
13864 }
13865
13866 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
13867         LDKErrorMessage this_ptr_conv;
13868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13869         this_ptr_conv.is_owned = false;
13870         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13871         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
13872         return ret_arr;
13873 }
13874
13875 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13876         LDKErrorMessage this_ptr_conv;
13877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13878         this_ptr_conv.is_owned = false;
13879         LDKThirtyTwoBytes val_ref;
13880         CHECK(*((uint32_t*)val) == 32);
13881         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13882         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
13883 }
13884
13885 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
13886         LDKErrorMessage this_ptr_conv;
13887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13888         this_ptr_conv.is_owned = false;
13889         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
13890         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
13891         return ret_conv;
13892 }
13893
13894 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
13895         LDKErrorMessage this_ptr_conv;
13896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13897         this_ptr_conv.is_owned = false;
13898         LDKStr val_conv = str_ref_to_owned_c(val);
13899         ErrorMessage_set_data(&this_ptr_conv, val_conv);
13900 }
13901
13902 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
13903         LDKThirtyTwoBytes channel_id_arg_ref;
13904         CHECK(*((uint32_t*)channel_id_arg) == 32);
13905         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13906         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
13907         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
13908         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13909         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13910         uint64_t ret_ref = (uint64_t)ret_var.inner;
13911         if (ret_var.is_owned) {
13912                 ret_ref |= 1;
13913         }
13914         return ret_ref;
13915 }
13916
13917 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
13918         LDKErrorMessage orig_conv;
13919         orig_conv.inner = (void*)(orig & (~1));
13920         orig_conv.is_owned = false;
13921         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
13922         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13923         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13924         uint64_t ret_ref = (uint64_t)ret_var.inner;
13925         if (ret_var.is_owned) {
13926                 ret_ref |= 1;
13927         }
13928         return ret_ref;
13929 }
13930
13931 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
13932         LDKPing this_obj_conv;
13933         this_obj_conv.inner = (void*)(this_obj & (~1));
13934         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13935         Ping_free(this_obj_conv);
13936 }
13937
13938 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
13939         LDKPing this_ptr_conv;
13940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13941         this_ptr_conv.is_owned = false;
13942         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
13943         return ret_val;
13944 }
13945
13946 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
13947         LDKPing this_ptr_conv;
13948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13949         this_ptr_conv.is_owned = false;
13950         Ping_set_ponglen(&this_ptr_conv, val);
13951 }
13952
13953 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
13954         LDKPing this_ptr_conv;
13955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13956         this_ptr_conv.is_owned = false;
13957         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
13958         return ret_val;
13959 }
13960
13961 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
13962         LDKPing this_ptr_conv;
13963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13964         this_ptr_conv.is_owned = false;
13965         Ping_set_byteslen(&this_ptr_conv, val);
13966 }
13967
13968 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
13969         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
13970         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13971         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13972         uint64_t ret_ref = (uint64_t)ret_var.inner;
13973         if (ret_var.is_owned) {
13974                 ret_ref |= 1;
13975         }
13976         return ret_ref;
13977 }
13978
13979 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
13980         LDKPing orig_conv;
13981         orig_conv.inner = (void*)(orig & (~1));
13982         orig_conv.is_owned = false;
13983         LDKPing ret_var = Ping_clone(&orig_conv);
13984         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13985         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13986         uint64_t ret_ref = (uint64_t)ret_var.inner;
13987         if (ret_var.is_owned) {
13988                 ret_ref |= 1;
13989         }
13990         return ret_ref;
13991 }
13992
13993 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
13994         LDKPong this_obj_conv;
13995         this_obj_conv.inner = (void*)(this_obj & (~1));
13996         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13997         Pong_free(this_obj_conv);
13998 }
13999
14000 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
14001         LDKPong this_ptr_conv;
14002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14003         this_ptr_conv.is_owned = false;
14004         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
14005         return ret_val;
14006 }
14007
14008 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
14009         LDKPong this_ptr_conv;
14010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14011         this_ptr_conv.is_owned = false;
14012         Pong_set_byteslen(&this_ptr_conv, val);
14013 }
14014
14015 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
14016         LDKPong ret_var = Pong_new(byteslen_arg);
14017         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14018         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14019         uint64_t ret_ref = (uint64_t)ret_var.inner;
14020         if (ret_var.is_owned) {
14021                 ret_ref |= 1;
14022         }
14023         return ret_ref;
14024 }
14025
14026 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
14027         LDKPong orig_conv;
14028         orig_conv.inner = (void*)(orig & (~1));
14029         orig_conv.is_owned = false;
14030         LDKPong ret_var = Pong_clone(&orig_conv);
14031         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14032         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14033         uint64_t ret_ref = (uint64_t)ret_var.inner;
14034         if (ret_var.is_owned) {
14035                 ret_ref |= 1;
14036         }
14037         return ret_ref;
14038 }
14039
14040 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
14041         LDKOpenChannel this_obj_conv;
14042         this_obj_conv.inner = (void*)(this_obj & (~1));
14043         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14044         OpenChannel_free(this_obj_conv);
14045 }
14046
14047 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
14048         LDKOpenChannel this_ptr_conv;
14049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14050         this_ptr_conv.is_owned = false;
14051         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14052         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
14053         return ret_arr;
14054 }
14055
14056 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14057         LDKOpenChannel this_ptr_conv;
14058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14059         this_ptr_conv.is_owned = false;
14060         LDKThirtyTwoBytes val_ref;
14061         CHECK(*((uint32_t*)val) == 32);
14062         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14063         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
14064 }
14065
14066 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
14067         LDKOpenChannel this_ptr_conv;
14068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14069         this_ptr_conv.is_owned = false;
14070         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14071         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
14072         return ret_arr;
14073 }
14074
14075 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
14076         LDKOpenChannel this_ptr_conv;
14077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14078         this_ptr_conv.is_owned = false;
14079         LDKThirtyTwoBytes val_ref;
14080         CHECK(*((uint32_t*)val) == 32);
14081         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14082         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
14083 }
14084
14085 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
14086         LDKOpenChannel this_ptr_conv;
14087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14088         this_ptr_conv.is_owned = false;
14089         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
14090         return ret_val;
14091 }
14092
14093 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
14094         LDKOpenChannel this_ptr_conv;
14095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14096         this_ptr_conv.is_owned = false;
14097         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
14098 }
14099
14100 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
14101         LDKOpenChannel this_ptr_conv;
14102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14103         this_ptr_conv.is_owned = false;
14104         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
14105         return ret_val;
14106 }
14107
14108 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
14109         LDKOpenChannel this_ptr_conv;
14110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14111         this_ptr_conv.is_owned = false;
14112         OpenChannel_set_push_msat(&this_ptr_conv, val);
14113 }
14114
14115 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
14116         LDKOpenChannel this_ptr_conv;
14117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14118         this_ptr_conv.is_owned = false;
14119         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
14120         return ret_val;
14121 }
14122
14123 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
14124         LDKOpenChannel this_ptr_conv;
14125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14126         this_ptr_conv.is_owned = false;
14127         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
14128 }
14129
14130 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
14131         LDKOpenChannel this_ptr_conv;
14132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14133         this_ptr_conv.is_owned = false;
14134         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
14135         return ret_val;
14136 }
14137
14138 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
14139         LDKOpenChannel this_ptr_conv;
14140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14141         this_ptr_conv.is_owned = false;
14142         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14143 }
14144
14145 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
14146         LDKOpenChannel this_ptr_conv;
14147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14148         this_ptr_conv.is_owned = false;
14149         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
14150         return ret_val;
14151 }
14152
14153 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
14154         LDKOpenChannel this_ptr_conv;
14155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14156         this_ptr_conv.is_owned = false;
14157         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
14158 }
14159
14160 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
14161         LDKOpenChannel this_ptr_conv;
14162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14163         this_ptr_conv.is_owned = false;
14164         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
14165         return ret_val;
14166 }
14167
14168 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14169         LDKOpenChannel this_ptr_conv;
14170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14171         this_ptr_conv.is_owned = false;
14172         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
14173 }
14174
14175 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
14176         LDKOpenChannel this_ptr_conv;
14177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14178         this_ptr_conv.is_owned = false;
14179         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
14180         return ret_val;
14181 }
14182
14183 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
14184         LDKOpenChannel this_ptr_conv;
14185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14186         this_ptr_conv.is_owned = false;
14187         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
14188 }
14189
14190 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
14191         LDKOpenChannel this_ptr_conv;
14192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14193         this_ptr_conv.is_owned = false;
14194         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
14195         return ret_val;
14196 }
14197
14198 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
14199         LDKOpenChannel this_ptr_conv;
14200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14201         this_ptr_conv.is_owned = false;
14202         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
14203 }
14204
14205 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
14206         LDKOpenChannel this_ptr_conv;
14207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14208         this_ptr_conv.is_owned = false;
14209         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
14210         return ret_val;
14211 }
14212
14213 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
14214         LDKOpenChannel this_ptr_conv;
14215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14216         this_ptr_conv.is_owned = false;
14217         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
14218 }
14219
14220 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
14221         LDKOpenChannel this_ptr_conv;
14222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14223         this_ptr_conv.is_owned = false;
14224         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14225         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
14226         return ret_arr;
14227 }
14228
14229 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
14230         LDKOpenChannel this_ptr_conv;
14231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14232         this_ptr_conv.is_owned = false;
14233         LDKPublicKey val_ref;
14234         CHECK(*((uint32_t*)val) == 33);
14235         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14236         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
14237 }
14238
14239 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
14240         LDKOpenChannel this_ptr_conv;
14241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14242         this_ptr_conv.is_owned = false;
14243         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14244         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
14245         return ret_arr;
14246 }
14247
14248 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
14249         LDKOpenChannel this_ptr_conv;
14250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14251         this_ptr_conv.is_owned = false;
14252         LDKPublicKey val_ref;
14253         CHECK(*((uint32_t*)val) == 33);
14254         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14255         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
14256 }
14257
14258 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
14259         LDKOpenChannel this_ptr_conv;
14260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14261         this_ptr_conv.is_owned = false;
14262         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14263         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
14264         return ret_arr;
14265 }
14266
14267 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
14268         LDKOpenChannel this_ptr_conv;
14269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14270         this_ptr_conv.is_owned = false;
14271         LDKPublicKey val_ref;
14272         CHECK(*((uint32_t*)val) == 33);
14273         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14274         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
14275 }
14276
14277 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
14278         LDKOpenChannel this_ptr_conv;
14279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14280         this_ptr_conv.is_owned = false;
14281         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14282         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
14283         return ret_arr;
14284 }
14285
14286 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
14287         LDKOpenChannel this_ptr_conv;
14288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14289         this_ptr_conv.is_owned = false;
14290         LDKPublicKey val_ref;
14291         CHECK(*((uint32_t*)val) == 33);
14292         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14293         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
14294 }
14295
14296 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
14297         LDKOpenChannel this_ptr_conv;
14298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14299         this_ptr_conv.is_owned = false;
14300         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14301         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
14302         return ret_arr;
14303 }
14304
14305 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
14306         LDKOpenChannel this_ptr_conv;
14307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14308         this_ptr_conv.is_owned = false;
14309         LDKPublicKey val_ref;
14310         CHECK(*((uint32_t*)val) == 33);
14311         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14312         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
14313 }
14314
14315 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
14316         LDKOpenChannel this_ptr_conv;
14317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14318         this_ptr_conv.is_owned = false;
14319         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14320         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14321         return ret_arr;
14322 }
14323
14324 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14325         LDKOpenChannel this_ptr_conv;
14326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14327         this_ptr_conv.is_owned = false;
14328         LDKPublicKey val_ref;
14329         CHECK(*((uint32_t*)val) == 33);
14330         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14331         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
14332 }
14333
14334 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
14335         LDKOpenChannel this_ptr_conv;
14336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14337         this_ptr_conv.is_owned = false;
14338         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
14339         return ret_val;
14340 }
14341
14342 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
14343         LDKOpenChannel this_ptr_conv;
14344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14345         this_ptr_conv.is_owned = false;
14346         OpenChannel_set_channel_flags(&this_ptr_conv, val);
14347 }
14348
14349 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
14350         LDKOpenChannel orig_conv;
14351         orig_conv.inner = (void*)(orig & (~1));
14352         orig_conv.is_owned = false;
14353         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
14354         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14355         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14356         uint64_t ret_ref = (uint64_t)ret_var.inner;
14357         if (ret_var.is_owned) {
14358                 ret_ref |= 1;
14359         }
14360         return ret_ref;
14361 }
14362
14363 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
14364         LDKAcceptChannel this_obj_conv;
14365         this_obj_conv.inner = (void*)(this_obj & (~1));
14366         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14367         AcceptChannel_free(this_obj_conv);
14368 }
14369
14370 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
14371         LDKAcceptChannel this_ptr_conv;
14372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14373         this_ptr_conv.is_owned = false;
14374         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14375         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
14376         return ret_arr;
14377 }
14378
14379 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
14380         LDKAcceptChannel this_ptr_conv;
14381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14382         this_ptr_conv.is_owned = false;
14383         LDKThirtyTwoBytes val_ref;
14384         CHECK(*((uint32_t*)val) == 32);
14385         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14386         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
14387 }
14388
14389 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
14390         LDKAcceptChannel this_ptr_conv;
14391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14392         this_ptr_conv.is_owned = false;
14393         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
14394         return ret_val;
14395 }
14396
14397 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
14398         LDKAcceptChannel this_ptr_conv;
14399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14400         this_ptr_conv.is_owned = false;
14401         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
14402 }
14403
14404 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
14405         LDKAcceptChannel this_ptr_conv;
14406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14407         this_ptr_conv.is_owned = false;
14408         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
14409         return ret_val;
14410 }
14411
14412 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
14413         LDKAcceptChannel this_ptr_conv;
14414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14415         this_ptr_conv.is_owned = false;
14416         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14417 }
14418
14419 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
14420         LDKAcceptChannel this_ptr_conv;
14421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14422         this_ptr_conv.is_owned = false;
14423         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
14424         return ret_val;
14425 }
14426
14427 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
14428         LDKAcceptChannel this_ptr_conv;
14429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14430         this_ptr_conv.is_owned = false;
14431         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
14432 }
14433
14434 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
14435         LDKAcceptChannel this_ptr_conv;
14436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14437         this_ptr_conv.is_owned = false;
14438         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
14439         return ret_val;
14440 }
14441
14442 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14443         LDKAcceptChannel this_ptr_conv;
14444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14445         this_ptr_conv.is_owned = false;
14446         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
14447 }
14448
14449 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
14450         LDKAcceptChannel this_ptr_conv;
14451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14452         this_ptr_conv.is_owned = false;
14453         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
14454         return ret_val;
14455 }
14456
14457 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
14458         LDKAcceptChannel this_ptr_conv;
14459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14460         this_ptr_conv.is_owned = false;
14461         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
14462 }
14463
14464 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
14465         LDKAcceptChannel this_ptr_conv;
14466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14467         this_ptr_conv.is_owned = false;
14468         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
14469         return ret_val;
14470 }
14471
14472 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
14473         LDKAcceptChannel this_ptr_conv;
14474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14475         this_ptr_conv.is_owned = false;
14476         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
14477 }
14478
14479 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
14480         LDKAcceptChannel this_ptr_conv;
14481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14482         this_ptr_conv.is_owned = false;
14483         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
14484         return ret_val;
14485 }
14486
14487 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
14488         LDKAcceptChannel this_ptr_conv;
14489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14490         this_ptr_conv.is_owned = false;
14491         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
14492 }
14493
14494 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
14495         LDKAcceptChannel this_ptr_conv;
14496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14497         this_ptr_conv.is_owned = false;
14498         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14499         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
14500         return ret_arr;
14501 }
14502
14503 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
14504         LDKAcceptChannel this_ptr_conv;
14505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14506         this_ptr_conv.is_owned = false;
14507         LDKPublicKey val_ref;
14508         CHECK(*((uint32_t*)val) == 33);
14509         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14510         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
14511 }
14512
14513 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
14514         LDKAcceptChannel this_ptr_conv;
14515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14516         this_ptr_conv.is_owned = false;
14517         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14518         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
14519         return ret_arr;
14520 }
14521
14522 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
14523         LDKAcceptChannel this_ptr_conv;
14524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14525         this_ptr_conv.is_owned = false;
14526         LDKPublicKey val_ref;
14527         CHECK(*((uint32_t*)val) == 33);
14528         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14529         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
14530 }
14531
14532 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
14533         LDKAcceptChannel this_ptr_conv;
14534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14535         this_ptr_conv.is_owned = false;
14536         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14537         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
14538         return ret_arr;
14539 }
14540
14541 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
14542         LDKAcceptChannel this_ptr_conv;
14543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14544         this_ptr_conv.is_owned = false;
14545         LDKPublicKey val_ref;
14546         CHECK(*((uint32_t*)val) == 33);
14547         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14548         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
14549 }
14550
14551 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
14552         LDKAcceptChannel this_ptr_conv;
14553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14554         this_ptr_conv.is_owned = false;
14555         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14556         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
14557         return ret_arr;
14558 }
14559
14560 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
14561         LDKAcceptChannel this_ptr_conv;
14562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14563         this_ptr_conv.is_owned = false;
14564         LDKPublicKey val_ref;
14565         CHECK(*((uint32_t*)val) == 33);
14566         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14567         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
14568 }
14569
14570 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
14571         LDKAcceptChannel this_ptr_conv;
14572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14573         this_ptr_conv.is_owned = false;
14574         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14575         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
14576         return ret_arr;
14577 }
14578
14579 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
14580         LDKAcceptChannel this_ptr_conv;
14581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14582         this_ptr_conv.is_owned = false;
14583         LDKPublicKey val_ref;
14584         CHECK(*((uint32_t*)val) == 33);
14585         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14586         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
14587 }
14588
14589 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
14590         LDKAcceptChannel this_ptr_conv;
14591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14592         this_ptr_conv.is_owned = false;
14593         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14594         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14595         return ret_arr;
14596 }
14597
14598 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14599         LDKAcceptChannel this_ptr_conv;
14600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14601         this_ptr_conv.is_owned = false;
14602         LDKPublicKey val_ref;
14603         CHECK(*((uint32_t*)val) == 33);
14604         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14605         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
14606 }
14607
14608 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
14609         LDKAcceptChannel orig_conv;
14610         orig_conv.inner = (void*)(orig & (~1));
14611         orig_conv.is_owned = false;
14612         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
14613         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14614         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14615         uint64_t ret_ref = (uint64_t)ret_var.inner;
14616         if (ret_var.is_owned) {
14617                 ret_ref |= 1;
14618         }
14619         return ret_ref;
14620 }
14621
14622 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
14623         LDKFundingCreated this_obj_conv;
14624         this_obj_conv.inner = (void*)(this_obj & (~1));
14625         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14626         FundingCreated_free(this_obj_conv);
14627 }
14628
14629 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
14630         LDKFundingCreated this_ptr_conv;
14631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14632         this_ptr_conv.is_owned = false;
14633         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14634         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
14635         return ret_arr;
14636 }
14637
14638 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
14639         LDKFundingCreated this_ptr_conv;
14640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14641         this_ptr_conv.is_owned = false;
14642         LDKThirtyTwoBytes val_ref;
14643         CHECK(*((uint32_t*)val) == 32);
14644         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14645         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
14646 }
14647
14648 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
14649         LDKFundingCreated this_ptr_conv;
14650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14651         this_ptr_conv.is_owned = false;
14652         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14653         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
14654         return ret_arr;
14655 }
14656
14657 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
14658         LDKFundingCreated this_ptr_conv;
14659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14660         this_ptr_conv.is_owned = false;
14661         LDKThirtyTwoBytes val_ref;
14662         CHECK(*((uint32_t*)val) == 32);
14663         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14664         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
14665 }
14666
14667 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
14668         LDKFundingCreated this_ptr_conv;
14669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14670         this_ptr_conv.is_owned = false;
14671         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
14672         return ret_val;
14673 }
14674
14675 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
14676         LDKFundingCreated this_ptr_conv;
14677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14678         this_ptr_conv.is_owned = false;
14679         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
14680 }
14681
14682 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
14683         LDKFundingCreated this_ptr_conv;
14684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14685         this_ptr_conv.is_owned = false;
14686         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14687         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
14688         return ret_arr;
14689 }
14690
14691 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
14692         LDKFundingCreated this_ptr_conv;
14693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14694         this_ptr_conv.is_owned = false;
14695         LDKSignature val_ref;
14696         CHECK(*((uint32_t*)val) == 64);
14697         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14698         FundingCreated_set_signature(&this_ptr_conv, val_ref);
14699 }
14700
14701 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) {
14702         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
14703         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
14704         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
14705         LDKThirtyTwoBytes funding_txid_arg_ref;
14706         CHECK(*((uint32_t*)funding_txid_arg) == 32);
14707         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
14708         LDKSignature signature_arg_ref;
14709         CHECK(*((uint32_t*)signature_arg) == 64);
14710         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
14711         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
14712         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14713         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14714         uint64_t ret_ref = (uint64_t)ret_var.inner;
14715         if (ret_var.is_owned) {
14716                 ret_ref |= 1;
14717         }
14718         return ret_ref;
14719 }
14720
14721 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
14722         LDKFundingCreated orig_conv;
14723         orig_conv.inner = (void*)(orig & (~1));
14724         orig_conv.is_owned = false;
14725         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
14726         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14727         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14728         uint64_t ret_ref = (uint64_t)ret_var.inner;
14729         if (ret_var.is_owned) {
14730                 ret_ref |= 1;
14731         }
14732         return ret_ref;
14733 }
14734
14735 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
14736         LDKFundingSigned this_obj_conv;
14737         this_obj_conv.inner = (void*)(this_obj & (~1));
14738         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14739         FundingSigned_free(this_obj_conv);
14740 }
14741
14742 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
14743         LDKFundingSigned this_ptr_conv;
14744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14745         this_ptr_conv.is_owned = false;
14746         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14747         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
14748         return ret_arr;
14749 }
14750
14751 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14752         LDKFundingSigned this_ptr_conv;
14753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14754         this_ptr_conv.is_owned = false;
14755         LDKThirtyTwoBytes val_ref;
14756         CHECK(*((uint32_t*)val) == 32);
14757         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14758         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
14759 }
14760
14761 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
14762         LDKFundingSigned this_ptr_conv;
14763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14764         this_ptr_conv.is_owned = false;
14765         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14766         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
14767         return ret_arr;
14768 }
14769
14770 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
14771         LDKFundingSigned this_ptr_conv;
14772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14773         this_ptr_conv.is_owned = false;
14774         LDKSignature val_ref;
14775         CHECK(*((uint32_t*)val) == 64);
14776         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14777         FundingSigned_set_signature(&this_ptr_conv, val_ref);
14778 }
14779
14780 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
14781         LDKThirtyTwoBytes channel_id_arg_ref;
14782         CHECK(*((uint32_t*)channel_id_arg) == 32);
14783         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
14784         LDKSignature signature_arg_ref;
14785         CHECK(*((uint32_t*)signature_arg) == 64);
14786         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
14787         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
14788         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14789         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14790         uint64_t ret_ref = (uint64_t)ret_var.inner;
14791         if (ret_var.is_owned) {
14792                 ret_ref |= 1;
14793         }
14794         return ret_ref;
14795 }
14796
14797 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
14798         LDKFundingSigned orig_conv;
14799         orig_conv.inner = (void*)(orig & (~1));
14800         orig_conv.is_owned = false;
14801         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
14802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14804         uint64_t ret_ref = (uint64_t)ret_var.inner;
14805         if (ret_var.is_owned) {
14806                 ret_ref |= 1;
14807         }
14808         return ret_ref;
14809 }
14810
14811 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
14812         LDKFundingLocked this_obj_conv;
14813         this_obj_conv.inner = (void*)(this_obj & (~1));
14814         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14815         FundingLocked_free(this_obj_conv);
14816 }
14817
14818 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
14819         LDKFundingLocked this_ptr_conv;
14820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14821         this_ptr_conv.is_owned = false;
14822         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14823         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
14824         return ret_arr;
14825 }
14826
14827 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14828         LDKFundingLocked this_ptr_conv;
14829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14830         this_ptr_conv.is_owned = false;
14831         LDKThirtyTwoBytes val_ref;
14832         CHECK(*((uint32_t*)val) == 32);
14833         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14834         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
14835 }
14836
14837 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
14838         LDKFundingLocked this_ptr_conv;
14839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14840         this_ptr_conv.is_owned = false;
14841         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14842         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14843         return ret_arr;
14844 }
14845
14846 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14847         LDKFundingLocked this_ptr_conv;
14848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14849         this_ptr_conv.is_owned = false;
14850         LDKPublicKey val_ref;
14851         CHECK(*((uint32_t*)val) == 33);
14852         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14853         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
14854 }
14855
14856 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
14857         LDKThirtyTwoBytes channel_id_arg_ref;
14858         CHECK(*((uint32_t*)channel_id_arg) == 32);
14859         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
14860         LDKPublicKey next_per_commitment_point_arg_ref;
14861         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
14862         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
14863         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
14864         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14865         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14866         uint64_t ret_ref = (uint64_t)ret_var.inner;
14867         if (ret_var.is_owned) {
14868                 ret_ref |= 1;
14869         }
14870         return ret_ref;
14871 }
14872
14873 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
14874         LDKFundingLocked orig_conv;
14875         orig_conv.inner = (void*)(orig & (~1));
14876         orig_conv.is_owned = false;
14877         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
14878         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14879         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14880         uint64_t ret_ref = (uint64_t)ret_var.inner;
14881         if (ret_var.is_owned) {
14882                 ret_ref |= 1;
14883         }
14884         return ret_ref;
14885 }
14886
14887 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
14888         LDKShutdown this_obj_conv;
14889         this_obj_conv.inner = (void*)(this_obj & (~1));
14890         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14891         Shutdown_free(this_obj_conv);
14892 }
14893
14894 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
14895         LDKShutdown this_ptr_conv;
14896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14897         this_ptr_conv.is_owned = false;
14898         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14899         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
14900         return ret_arr;
14901 }
14902
14903 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14904         LDKShutdown this_ptr_conv;
14905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14906         this_ptr_conv.is_owned = false;
14907         LDKThirtyTwoBytes val_ref;
14908         CHECK(*((uint32_t*)val) == 32);
14909         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14910         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
14911 }
14912
14913 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
14914         LDKShutdown this_ptr_conv;
14915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14916         this_ptr_conv.is_owned = false;
14917         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
14918         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14919         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14920         return ret_arr;
14921 }
14922
14923 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
14924         LDKShutdown this_ptr_conv;
14925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14926         this_ptr_conv.is_owned = false;
14927         LDKCVec_u8Z val_ref;
14928         val_ref.datalen = *((uint32_t*)val);
14929         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14930         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
14931         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
14932 }
14933
14934 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
14935         LDKThirtyTwoBytes channel_id_arg_ref;
14936         CHECK(*((uint32_t*)channel_id_arg) == 32);
14937         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
14938         LDKCVec_u8Z scriptpubkey_arg_ref;
14939         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
14940         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14941         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
14942         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
14943         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14944         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14945         uint64_t ret_ref = (uint64_t)ret_var.inner;
14946         if (ret_var.is_owned) {
14947                 ret_ref |= 1;
14948         }
14949         return ret_ref;
14950 }
14951
14952 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
14953         LDKShutdown orig_conv;
14954         orig_conv.inner = (void*)(orig & (~1));
14955         orig_conv.is_owned = false;
14956         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
14957         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14958         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14959         uint64_t ret_ref = (uint64_t)ret_var.inner;
14960         if (ret_var.is_owned) {
14961                 ret_ref |= 1;
14962         }
14963         return ret_ref;
14964 }
14965
14966 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
14967         LDKClosingSigned this_obj_conv;
14968         this_obj_conv.inner = (void*)(this_obj & (~1));
14969         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14970         ClosingSigned_free(this_obj_conv);
14971 }
14972
14973 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
14974         LDKClosingSigned this_ptr_conv;
14975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14976         this_ptr_conv.is_owned = false;
14977         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14978         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
14979         return ret_arr;
14980 }
14981
14982 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14983         LDKClosingSigned this_ptr_conv;
14984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14985         this_ptr_conv.is_owned = false;
14986         LDKThirtyTwoBytes val_ref;
14987         CHECK(*((uint32_t*)val) == 32);
14988         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14989         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
14990 }
14991
14992 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
14993         LDKClosingSigned this_ptr_conv;
14994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14995         this_ptr_conv.is_owned = false;
14996         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
14997         return ret_val;
14998 }
14999
15000 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
15001         LDKClosingSigned this_ptr_conv;
15002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15003         this_ptr_conv.is_owned = false;
15004         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
15005 }
15006
15007 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
15008         LDKClosingSigned this_ptr_conv;
15009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15010         this_ptr_conv.is_owned = false;
15011         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15012         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
15013         return ret_arr;
15014 }
15015
15016 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
15017         LDKClosingSigned this_ptr_conv;
15018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15019         this_ptr_conv.is_owned = false;
15020         LDKSignature val_ref;
15021         CHECK(*((uint32_t*)val) == 64);
15022         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15023         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
15024 }
15025
15026 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
15027         LDKThirtyTwoBytes channel_id_arg_ref;
15028         CHECK(*((uint32_t*)channel_id_arg) == 32);
15029         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15030         LDKSignature signature_arg_ref;
15031         CHECK(*((uint32_t*)signature_arg) == 64);
15032         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15033         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
15034         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15035         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15036         uint64_t ret_ref = (uint64_t)ret_var.inner;
15037         if (ret_var.is_owned) {
15038                 ret_ref |= 1;
15039         }
15040         return ret_ref;
15041 }
15042
15043 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
15044         LDKClosingSigned orig_conv;
15045         orig_conv.inner = (void*)(orig & (~1));
15046         orig_conv.is_owned = false;
15047         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
15048         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15049         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15050         uint64_t ret_ref = (uint64_t)ret_var.inner;
15051         if (ret_var.is_owned) {
15052                 ret_ref |= 1;
15053         }
15054         return ret_ref;
15055 }
15056
15057 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
15058         LDKUpdateAddHTLC this_obj_conv;
15059         this_obj_conv.inner = (void*)(this_obj & (~1));
15060         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15061         UpdateAddHTLC_free(this_obj_conv);
15062 }
15063
15064 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
15065         LDKUpdateAddHTLC this_ptr_conv;
15066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15067         this_ptr_conv.is_owned = false;
15068         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15069         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
15070         return ret_arr;
15071 }
15072
15073 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15074         LDKUpdateAddHTLC this_ptr_conv;
15075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15076         this_ptr_conv.is_owned = false;
15077         LDKThirtyTwoBytes val_ref;
15078         CHECK(*((uint32_t*)val) == 32);
15079         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15080         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
15081 }
15082
15083 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
15084         LDKUpdateAddHTLC this_ptr_conv;
15085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15086         this_ptr_conv.is_owned = false;
15087         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
15088         return ret_val;
15089 }
15090
15091 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15092         LDKUpdateAddHTLC this_ptr_conv;
15093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15094         this_ptr_conv.is_owned = false;
15095         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
15096 }
15097
15098 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
15099         LDKUpdateAddHTLC this_ptr_conv;
15100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15101         this_ptr_conv.is_owned = false;
15102         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
15103         return ret_val;
15104 }
15105
15106 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
15107         LDKUpdateAddHTLC this_ptr_conv;
15108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15109         this_ptr_conv.is_owned = false;
15110         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
15111 }
15112
15113 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
15114         LDKUpdateAddHTLC this_ptr_conv;
15115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15116         this_ptr_conv.is_owned = false;
15117         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15118         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
15119         return ret_arr;
15120 }
15121
15122 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
15123         LDKUpdateAddHTLC this_ptr_conv;
15124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15125         this_ptr_conv.is_owned = false;
15126         LDKThirtyTwoBytes val_ref;
15127         CHECK(*((uint32_t*)val) == 32);
15128         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15129         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
15130 }
15131
15132 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
15133         LDKUpdateAddHTLC this_ptr_conv;
15134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15135         this_ptr_conv.is_owned = false;
15136         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
15137         return ret_val;
15138 }
15139
15140 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
15141         LDKUpdateAddHTLC this_ptr_conv;
15142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15143         this_ptr_conv.is_owned = false;
15144         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
15145 }
15146
15147 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
15148         LDKUpdateAddHTLC orig_conv;
15149         orig_conv.inner = (void*)(orig & (~1));
15150         orig_conv.is_owned = false;
15151         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
15152         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15153         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15154         uint64_t ret_ref = (uint64_t)ret_var.inner;
15155         if (ret_var.is_owned) {
15156                 ret_ref |= 1;
15157         }
15158         return ret_ref;
15159 }
15160
15161 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
15162         LDKUpdateFulfillHTLC this_obj_conv;
15163         this_obj_conv.inner = (void*)(this_obj & (~1));
15164         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15165         UpdateFulfillHTLC_free(this_obj_conv);
15166 }
15167
15168 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
15169         LDKUpdateFulfillHTLC this_ptr_conv;
15170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15171         this_ptr_conv.is_owned = false;
15172         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15173         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
15174         return ret_arr;
15175 }
15176
15177 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15178         LDKUpdateFulfillHTLC this_ptr_conv;
15179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15180         this_ptr_conv.is_owned = false;
15181         LDKThirtyTwoBytes val_ref;
15182         CHECK(*((uint32_t*)val) == 32);
15183         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15184         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
15185 }
15186
15187 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
15188         LDKUpdateFulfillHTLC this_ptr_conv;
15189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15190         this_ptr_conv.is_owned = false;
15191         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
15192         return ret_val;
15193 }
15194
15195 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15196         LDKUpdateFulfillHTLC this_ptr_conv;
15197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15198         this_ptr_conv.is_owned = false;
15199         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
15200 }
15201
15202 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
15203         LDKUpdateFulfillHTLC this_ptr_conv;
15204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15205         this_ptr_conv.is_owned = false;
15206         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15207         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
15208         return ret_arr;
15209 }
15210
15211 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
15212         LDKUpdateFulfillHTLC this_ptr_conv;
15213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15214         this_ptr_conv.is_owned = false;
15215         LDKThirtyTwoBytes val_ref;
15216         CHECK(*((uint32_t*)val) == 32);
15217         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15218         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
15219 }
15220
15221 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
15222         LDKThirtyTwoBytes channel_id_arg_ref;
15223         CHECK(*((uint32_t*)channel_id_arg) == 32);
15224         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15225         LDKThirtyTwoBytes payment_preimage_arg_ref;
15226         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
15227         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
15228         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
15229         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15230         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15231         uint64_t ret_ref = (uint64_t)ret_var.inner;
15232         if (ret_var.is_owned) {
15233                 ret_ref |= 1;
15234         }
15235         return ret_ref;
15236 }
15237
15238 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
15239         LDKUpdateFulfillHTLC orig_conv;
15240         orig_conv.inner = (void*)(orig & (~1));
15241         orig_conv.is_owned = false;
15242         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
15243         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15244         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15245         uint64_t ret_ref = (uint64_t)ret_var.inner;
15246         if (ret_var.is_owned) {
15247                 ret_ref |= 1;
15248         }
15249         return ret_ref;
15250 }
15251
15252 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
15253         LDKUpdateFailHTLC this_obj_conv;
15254         this_obj_conv.inner = (void*)(this_obj & (~1));
15255         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15256         UpdateFailHTLC_free(this_obj_conv);
15257 }
15258
15259 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
15260         LDKUpdateFailHTLC 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(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15264         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
15265         return ret_arr;
15266 }
15267
15268 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15269         LDKUpdateFailHTLC this_ptr_conv;
15270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15271         this_ptr_conv.is_owned = false;
15272         LDKThirtyTwoBytes val_ref;
15273         CHECK(*((uint32_t*)val) == 32);
15274         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15275         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
15276 }
15277
15278 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
15279         LDKUpdateFailHTLC this_ptr_conv;
15280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15281         this_ptr_conv.is_owned = false;
15282         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
15283         return ret_val;
15284 }
15285
15286 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15287         LDKUpdateFailHTLC this_ptr_conv;
15288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15289         this_ptr_conv.is_owned = false;
15290         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
15291 }
15292
15293 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
15294         LDKUpdateFailHTLC orig_conv;
15295         orig_conv.inner = (void*)(orig & (~1));
15296         orig_conv.is_owned = false;
15297         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
15298         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15299         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15300         uint64_t ret_ref = (uint64_t)ret_var.inner;
15301         if (ret_var.is_owned) {
15302                 ret_ref |= 1;
15303         }
15304         return ret_ref;
15305 }
15306
15307 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
15308         LDKUpdateFailMalformedHTLC this_obj_conv;
15309         this_obj_conv.inner = (void*)(this_obj & (~1));
15310         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15311         UpdateFailMalformedHTLC_free(this_obj_conv);
15312 }
15313
15314 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
15315         LDKUpdateFailMalformedHTLC this_ptr_conv;
15316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15317         this_ptr_conv.is_owned = false;
15318         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15319         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
15320         return ret_arr;
15321 }
15322
15323 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15324         LDKUpdateFailMalformedHTLC this_ptr_conv;
15325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15326         this_ptr_conv.is_owned = false;
15327         LDKThirtyTwoBytes val_ref;
15328         CHECK(*((uint32_t*)val) == 32);
15329         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15330         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
15331 }
15332
15333 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
15334         LDKUpdateFailMalformedHTLC this_ptr_conv;
15335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15336         this_ptr_conv.is_owned = false;
15337         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
15338         return ret_val;
15339 }
15340
15341 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15342         LDKUpdateFailMalformedHTLC this_ptr_conv;
15343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15344         this_ptr_conv.is_owned = false;
15345         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
15346 }
15347
15348 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
15349         LDKUpdateFailMalformedHTLC this_ptr_conv;
15350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15351         this_ptr_conv.is_owned = false;
15352         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
15353         return ret_val;
15354 }
15355
15356 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
15357         LDKUpdateFailMalformedHTLC this_ptr_conv;
15358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15359         this_ptr_conv.is_owned = false;
15360         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
15361 }
15362
15363 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
15364         LDKUpdateFailMalformedHTLC orig_conv;
15365         orig_conv.inner = (void*)(orig & (~1));
15366         orig_conv.is_owned = false;
15367         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
15368         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15369         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15370         uint64_t ret_ref = (uint64_t)ret_var.inner;
15371         if (ret_var.is_owned) {
15372                 ret_ref |= 1;
15373         }
15374         return ret_ref;
15375 }
15376
15377 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
15378         LDKCommitmentSigned this_obj_conv;
15379         this_obj_conv.inner = (void*)(this_obj & (~1));
15380         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15381         CommitmentSigned_free(this_obj_conv);
15382 }
15383
15384 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
15385         LDKCommitmentSigned this_ptr_conv;
15386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15387         this_ptr_conv.is_owned = false;
15388         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15389         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
15390         return ret_arr;
15391 }
15392
15393 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15394         LDKCommitmentSigned this_ptr_conv;
15395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15396         this_ptr_conv.is_owned = false;
15397         LDKThirtyTwoBytes val_ref;
15398         CHECK(*((uint32_t*)val) == 32);
15399         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15400         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
15401 }
15402
15403 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
15404         LDKCommitmentSigned this_ptr_conv;
15405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15406         this_ptr_conv.is_owned = false;
15407         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15408         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
15409         return ret_arr;
15410 }
15411
15412 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
15413         LDKCommitmentSigned this_ptr_conv;
15414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15415         this_ptr_conv.is_owned = false;
15416         LDKSignature val_ref;
15417         CHECK(*((uint32_t*)val) == 64);
15418         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15419         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
15420 }
15421
15422 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
15423         LDKCommitmentSigned this_ptr_conv;
15424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15425         this_ptr_conv.is_owned = false;
15426         LDKCVec_SignatureZ val_constr;
15427         val_constr.datalen = *((uint32_t*)val);
15428         if (val_constr.datalen > 0)
15429                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15430         else
15431                 val_constr.data = NULL;
15432         int8_tArray* val_vals = (int8_tArray*)(val + 4);
15433         for (size_t m = 0; m < val_constr.datalen; m++) {
15434                 int8_tArray val_conv_12 = val_vals[m];
15435                 LDKSignature val_conv_12_ref;
15436                 CHECK(*((uint32_t*)val_conv_12) == 64);
15437                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
15438                 val_constr.data[m] = val_conv_12_ref;
15439         }
15440         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
15441 }
15442
15443 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
15444         LDKThirtyTwoBytes channel_id_arg_ref;
15445         CHECK(*((uint32_t*)channel_id_arg) == 32);
15446         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15447         LDKSignature signature_arg_ref;
15448         CHECK(*((uint32_t*)signature_arg) == 64);
15449         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15450         LDKCVec_SignatureZ htlc_signatures_arg_constr;
15451         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
15452         if (htlc_signatures_arg_constr.datalen > 0)
15453                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15454         else
15455                 htlc_signatures_arg_constr.data = NULL;
15456         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
15457         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
15458                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
15459                 LDKSignature htlc_signatures_arg_conv_12_ref;
15460                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
15461                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
15462                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
15463         }
15464         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
15465         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15466         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15467         uint64_t ret_ref = (uint64_t)ret_var.inner;
15468         if (ret_var.is_owned) {
15469                 ret_ref |= 1;
15470         }
15471         return ret_ref;
15472 }
15473
15474 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
15475         LDKCommitmentSigned orig_conv;
15476         orig_conv.inner = (void*)(orig & (~1));
15477         orig_conv.is_owned = false;
15478         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
15479         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15480         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15481         uint64_t ret_ref = (uint64_t)ret_var.inner;
15482         if (ret_var.is_owned) {
15483                 ret_ref |= 1;
15484         }
15485         return ret_ref;
15486 }
15487
15488 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
15489         LDKRevokeAndACK this_obj_conv;
15490         this_obj_conv.inner = (void*)(this_obj & (~1));
15491         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15492         RevokeAndACK_free(this_obj_conv);
15493 }
15494
15495 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
15496         LDKRevokeAndACK this_ptr_conv;
15497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15498         this_ptr_conv.is_owned = false;
15499         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15500         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
15501         return ret_arr;
15502 }
15503
15504 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15505         LDKRevokeAndACK this_ptr_conv;
15506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15507         this_ptr_conv.is_owned = false;
15508         LDKThirtyTwoBytes val_ref;
15509         CHECK(*((uint32_t*)val) == 32);
15510         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15511         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
15512 }
15513
15514 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
15515         LDKRevokeAndACK this_ptr_conv;
15516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15517         this_ptr_conv.is_owned = false;
15518         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15519         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
15520         return ret_arr;
15521 }
15522
15523 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
15524         LDKRevokeAndACK this_ptr_conv;
15525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15526         this_ptr_conv.is_owned = false;
15527         LDKThirtyTwoBytes val_ref;
15528         CHECK(*((uint32_t*)val) == 32);
15529         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15530         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
15531 }
15532
15533 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
15534         LDKRevokeAndACK this_ptr_conv;
15535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15536         this_ptr_conv.is_owned = false;
15537         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15538         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
15539         return ret_arr;
15540 }
15541
15542 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
15543         LDKRevokeAndACK this_ptr_conv;
15544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15545         this_ptr_conv.is_owned = false;
15546         LDKPublicKey val_ref;
15547         CHECK(*((uint32_t*)val) == 33);
15548         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15549         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
15550 }
15551
15552 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) {
15553         LDKThirtyTwoBytes channel_id_arg_ref;
15554         CHECK(*((uint32_t*)channel_id_arg) == 32);
15555         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15556         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
15557         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
15558         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
15559         LDKPublicKey next_per_commitment_point_arg_ref;
15560         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
15561         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
15562         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
15563         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15564         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15565         uint64_t ret_ref = (uint64_t)ret_var.inner;
15566         if (ret_var.is_owned) {
15567                 ret_ref |= 1;
15568         }
15569         return ret_ref;
15570 }
15571
15572 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
15573         LDKRevokeAndACK orig_conv;
15574         orig_conv.inner = (void*)(orig & (~1));
15575         orig_conv.is_owned = false;
15576         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
15577         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15578         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15579         uint64_t ret_ref = (uint64_t)ret_var.inner;
15580         if (ret_var.is_owned) {
15581                 ret_ref |= 1;
15582         }
15583         return ret_ref;
15584 }
15585
15586 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
15587         LDKUpdateFee this_obj_conv;
15588         this_obj_conv.inner = (void*)(this_obj & (~1));
15589         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15590         UpdateFee_free(this_obj_conv);
15591 }
15592
15593 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
15594         LDKUpdateFee this_ptr_conv;
15595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15596         this_ptr_conv.is_owned = false;
15597         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15598         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
15599         return ret_arr;
15600 }
15601
15602 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15603         LDKUpdateFee this_ptr_conv;
15604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15605         this_ptr_conv.is_owned = false;
15606         LDKThirtyTwoBytes val_ref;
15607         CHECK(*((uint32_t*)val) == 32);
15608         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15609         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
15610 }
15611
15612 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
15613         LDKUpdateFee this_ptr_conv;
15614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15615         this_ptr_conv.is_owned = false;
15616         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
15617         return ret_val;
15618 }
15619
15620 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
15621         LDKUpdateFee this_ptr_conv;
15622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15623         this_ptr_conv.is_owned = false;
15624         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
15625 }
15626
15627 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
15628         LDKThirtyTwoBytes channel_id_arg_ref;
15629         CHECK(*((uint32_t*)channel_id_arg) == 32);
15630         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15631         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
15632         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15633         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15634         uint64_t ret_ref = (uint64_t)ret_var.inner;
15635         if (ret_var.is_owned) {
15636                 ret_ref |= 1;
15637         }
15638         return ret_ref;
15639 }
15640
15641 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
15642         LDKUpdateFee orig_conv;
15643         orig_conv.inner = (void*)(orig & (~1));
15644         orig_conv.is_owned = false;
15645         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
15646         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15647         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15648         uint64_t ret_ref = (uint64_t)ret_var.inner;
15649         if (ret_var.is_owned) {
15650                 ret_ref |= 1;
15651         }
15652         return ret_ref;
15653 }
15654
15655 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
15656         LDKDataLossProtect this_obj_conv;
15657         this_obj_conv.inner = (void*)(this_obj & (~1));
15658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15659         DataLossProtect_free(this_obj_conv);
15660 }
15661
15662 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
15663         LDKDataLossProtect this_ptr_conv;
15664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15665         this_ptr_conv.is_owned = false;
15666         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15667         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
15668         return ret_arr;
15669 }
15670
15671 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
15672         LDKDataLossProtect this_ptr_conv;
15673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15674         this_ptr_conv.is_owned = false;
15675         LDKThirtyTwoBytes val_ref;
15676         CHECK(*((uint32_t*)val) == 32);
15677         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15678         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
15679 }
15680
15681 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
15682         LDKDataLossProtect this_ptr_conv;
15683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15684         this_ptr_conv.is_owned = false;
15685         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15686         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
15687         return ret_arr;
15688 }
15689
15690 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
15691         LDKDataLossProtect this_ptr_conv;
15692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15693         this_ptr_conv.is_owned = false;
15694         LDKPublicKey val_ref;
15695         CHECK(*((uint32_t*)val) == 33);
15696         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15697         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
15698 }
15699
15700 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
15701         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
15702         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
15703         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
15704         LDKPublicKey my_current_per_commitment_point_arg_ref;
15705         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
15706         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
15707         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
15708         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15709         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15710         uint64_t ret_ref = (uint64_t)ret_var.inner;
15711         if (ret_var.is_owned) {
15712                 ret_ref |= 1;
15713         }
15714         return ret_ref;
15715 }
15716
15717 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
15718         LDKDataLossProtect orig_conv;
15719         orig_conv.inner = (void*)(orig & (~1));
15720         orig_conv.is_owned = false;
15721         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
15722         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15723         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15724         uint64_t ret_ref = (uint64_t)ret_var.inner;
15725         if (ret_var.is_owned) {
15726                 ret_ref |= 1;
15727         }
15728         return ret_ref;
15729 }
15730
15731 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
15732         LDKChannelReestablish this_obj_conv;
15733         this_obj_conv.inner = (void*)(this_obj & (~1));
15734         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15735         ChannelReestablish_free(this_obj_conv);
15736 }
15737
15738 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
15739         LDKChannelReestablish this_ptr_conv;
15740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15741         this_ptr_conv.is_owned = false;
15742         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15743         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
15744         return ret_arr;
15745 }
15746
15747 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15748         LDKChannelReestablish this_ptr_conv;
15749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15750         this_ptr_conv.is_owned = false;
15751         LDKThirtyTwoBytes val_ref;
15752         CHECK(*((uint32_t*)val) == 32);
15753         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15754         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
15755 }
15756
15757 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
15758         LDKChannelReestablish this_ptr_conv;
15759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15760         this_ptr_conv.is_owned = false;
15761         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
15762         return ret_val;
15763 }
15764
15765 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
15766         LDKChannelReestablish this_ptr_conv;
15767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15768         this_ptr_conv.is_owned = false;
15769         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
15770 }
15771
15772 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
15773         LDKChannelReestablish this_ptr_conv;
15774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15775         this_ptr_conv.is_owned = false;
15776         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
15777         return ret_val;
15778 }
15779
15780 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
15781         LDKChannelReestablish this_ptr_conv;
15782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15783         this_ptr_conv.is_owned = false;
15784         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
15785 }
15786
15787 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
15788         LDKChannelReestablish orig_conv;
15789         orig_conv.inner = (void*)(orig & (~1));
15790         orig_conv.is_owned = false;
15791         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
15792         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15793         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15794         uint64_t ret_ref = (uint64_t)ret_var.inner;
15795         if (ret_var.is_owned) {
15796                 ret_ref |= 1;
15797         }
15798         return ret_ref;
15799 }
15800
15801 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
15802         LDKAnnouncementSignatures this_obj_conv;
15803         this_obj_conv.inner = (void*)(this_obj & (~1));
15804         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15805         AnnouncementSignatures_free(this_obj_conv);
15806 }
15807
15808 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
15809         LDKAnnouncementSignatures this_ptr_conv;
15810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15811         this_ptr_conv.is_owned = false;
15812         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15813         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
15814         return ret_arr;
15815 }
15816
15817 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15818         LDKAnnouncementSignatures this_ptr_conv;
15819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15820         this_ptr_conv.is_owned = false;
15821         LDKThirtyTwoBytes val_ref;
15822         CHECK(*((uint32_t*)val) == 32);
15823         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15824         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
15825 }
15826
15827 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
15828         LDKAnnouncementSignatures this_ptr_conv;
15829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15830         this_ptr_conv.is_owned = false;
15831         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
15832         return ret_val;
15833 }
15834
15835 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
15836         LDKAnnouncementSignatures this_ptr_conv;
15837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15838         this_ptr_conv.is_owned = false;
15839         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
15840 }
15841
15842 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
15843         LDKAnnouncementSignatures this_ptr_conv;
15844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15845         this_ptr_conv.is_owned = false;
15846         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15847         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
15848         return ret_arr;
15849 }
15850
15851 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
15852         LDKAnnouncementSignatures this_ptr_conv;
15853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15854         this_ptr_conv.is_owned = false;
15855         LDKSignature val_ref;
15856         CHECK(*((uint32_t*)val) == 64);
15857         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15858         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
15859 }
15860
15861 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
15862         LDKAnnouncementSignatures this_ptr_conv;
15863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15864         this_ptr_conv.is_owned = false;
15865         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15866         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
15867         return ret_arr;
15868 }
15869
15870 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
15871         LDKAnnouncementSignatures this_ptr_conv;
15872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15873         this_ptr_conv.is_owned = false;
15874         LDKSignature val_ref;
15875         CHECK(*((uint32_t*)val) == 64);
15876         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15877         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
15878 }
15879
15880 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) {
15881         LDKThirtyTwoBytes channel_id_arg_ref;
15882         CHECK(*((uint32_t*)channel_id_arg) == 32);
15883         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15884         LDKSignature node_signature_arg_ref;
15885         CHECK(*((uint32_t*)node_signature_arg) == 64);
15886         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
15887         LDKSignature bitcoin_signature_arg_ref;
15888         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
15889         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
15890         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
15891         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15892         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15893         uint64_t ret_ref = (uint64_t)ret_var.inner;
15894         if (ret_var.is_owned) {
15895                 ret_ref |= 1;
15896         }
15897         return ret_ref;
15898 }
15899
15900 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
15901         LDKAnnouncementSignatures orig_conv;
15902         orig_conv.inner = (void*)(orig & (~1));
15903         orig_conv.is_owned = false;
15904         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
15905         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15906         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15907         uint64_t ret_ref = (uint64_t)ret_var.inner;
15908         if (ret_var.is_owned) {
15909                 ret_ref |= 1;
15910         }
15911         return ret_ref;
15912 }
15913
15914 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
15915         if ((this_ptr & 1) != 0) return;
15916         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
15917         FREE((void*)this_ptr);
15918         NetAddress_free(this_ptr_conv);
15919 }
15920
15921 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
15922         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
15923         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
15924         *ret_copy = NetAddress_clone(orig_conv);
15925         uint64_t ret_ref = (uint64_t)ret_copy;
15926         return ret_ref;
15927 }
15928
15929 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
15930         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
15931         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
15932         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15933         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15934         CVec_u8Z_free(ret_var);
15935         return ret_arr;
15936 }
15937
15938 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
15939         LDKu8slice ser_ref;
15940         ser_ref.datalen = *((uint32_t*)ser);
15941         ser_ref.data = (int8_t*)(ser + 4);
15942         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
15943         *ret_conv = Result_read(ser_ref);
15944         return (uint64_t)ret_conv;
15945 }
15946
15947 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
15948         LDKu8slice ser_ref;
15949         ser_ref.datalen = *((uint32_t*)ser);
15950         ser_ref.data = (int8_t*)(ser + 4);
15951         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
15952         *ret_conv = NetAddress_read(ser_ref);
15953         return (uint64_t)ret_conv;
15954 }
15955
15956 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
15957         LDKUnsignedNodeAnnouncement this_obj_conv;
15958         this_obj_conv.inner = (void*)(this_obj & (~1));
15959         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15960         UnsignedNodeAnnouncement_free(this_obj_conv);
15961 }
15962
15963 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
15964         LDKUnsignedNodeAnnouncement this_ptr_conv;
15965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15966         this_ptr_conv.is_owned = false;
15967         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
15968         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15969         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15970         uint64_t ret_ref = (uint64_t)ret_var.inner;
15971         if (ret_var.is_owned) {
15972                 ret_ref |= 1;
15973         }
15974         return ret_ref;
15975 }
15976
15977 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
15978         LDKUnsignedNodeAnnouncement this_ptr_conv;
15979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15980         this_ptr_conv.is_owned = false;
15981         LDKNodeFeatures val_conv;
15982         val_conv.inner = (void*)(val & (~1));
15983         val_conv.is_owned = (val & 1) || (val == 0);
15984         val_conv = NodeFeatures_clone(&val_conv);
15985         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
15986 }
15987
15988 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
15989         LDKUnsignedNodeAnnouncement this_ptr_conv;
15990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15991         this_ptr_conv.is_owned = false;
15992         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
15993         return ret_val;
15994 }
15995
15996 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
15997         LDKUnsignedNodeAnnouncement this_ptr_conv;
15998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15999         this_ptr_conv.is_owned = false;
16000         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
16001 }
16002
16003 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
16004         LDKUnsignedNodeAnnouncement this_ptr_conv;
16005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16006         this_ptr_conv.is_owned = false;
16007         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16008         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
16009         return ret_arr;
16010 }
16011
16012 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
16013         LDKUnsignedNodeAnnouncement this_ptr_conv;
16014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16015         this_ptr_conv.is_owned = false;
16016         LDKPublicKey val_ref;
16017         CHECK(*((uint32_t*)val) == 33);
16018         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16019         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
16020 }
16021
16022 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
16023         LDKUnsignedNodeAnnouncement this_ptr_conv;
16024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16025         this_ptr_conv.is_owned = false;
16026         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
16027         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
16028         return ret_arr;
16029 }
16030
16031 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
16032         LDKUnsignedNodeAnnouncement this_ptr_conv;
16033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16034         this_ptr_conv.is_owned = false;
16035         LDKThreeBytes val_ref;
16036         CHECK(*((uint32_t*)val) == 3);
16037         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
16038         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
16039 }
16040
16041 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
16042         LDKUnsignedNodeAnnouncement this_ptr_conv;
16043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16044         this_ptr_conv.is_owned = false;
16045         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16046         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
16047         return ret_arr;
16048 }
16049
16050 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
16051         LDKUnsignedNodeAnnouncement this_ptr_conv;
16052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16053         this_ptr_conv.is_owned = false;
16054         LDKThirtyTwoBytes val_ref;
16055         CHECK(*((uint32_t*)val) == 32);
16056         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16057         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
16058 }
16059
16060 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
16061         LDKUnsignedNodeAnnouncement this_ptr_conv;
16062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16063         this_ptr_conv.is_owned = false;
16064         LDKCVec_NetAddressZ val_constr;
16065         val_constr.datalen = *((uint32_t*)val);
16066         if (val_constr.datalen > 0)
16067                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16068         else
16069                 val_constr.data = NULL;
16070         uint32_t* val_vals = (uint32_t*)(val + 4);
16071         for (size_t m = 0; m < val_constr.datalen; m++) {
16072                 uint32_t val_conv_12 = val_vals[m];
16073                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
16074                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
16075                 val_constr.data[m] = val_conv_12_conv;
16076         }
16077         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
16078 }
16079
16080 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
16081         LDKUnsignedNodeAnnouncement orig_conv;
16082         orig_conv.inner = (void*)(orig & (~1));
16083         orig_conv.is_owned = false;
16084         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
16085         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16086         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16087         uint64_t ret_ref = (uint64_t)ret_var.inner;
16088         if (ret_var.is_owned) {
16089                 ret_ref |= 1;
16090         }
16091         return ret_ref;
16092 }
16093
16094 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
16095         LDKNodeAnnouncement this_obj_conv;
16096         this_obj_conv.inner = (void*)(this_obj & (~1));
16097         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16098         NodeAnnouncement_free(this_obj_conv);
16099 }
16100
16101 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
16102         LDKNodeAnnouncement this_ptr_conv;
16103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16104         this_ptr_conv.is_owned = false;
16105         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16106         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
16107         return ret_arr;
16108 }
16109
16110 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
16111         LDKNodeAnnouncement this_ptr_conv;
16112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16113         this_ptr_conv.is_owned = false;
16114         LDKSignature val_ref;
16115         CHECK(*((uint32_t*)val) == 64);
16116         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16117         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
16118 }
16119
16120 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
16121         LDKNodeAnnouncement this_ptr_conv;
16122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16123         this_ptr_conv.is_owned = false;
16124         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
16125         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16126         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16127         uint64_t ret_ref = (uint64_t)ret_var.inner;
16128         if (ret_var.is_owned) {
16129                 ret_ref |= 1;
16130         }
16131         return ret_ref;
16132 }
16133
16134 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
16135         LDKNodeAnnouncement this_ptr_conv;
16136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16137         this_ptr_conv.is_owned = false;
16138         LDKUnsignedNodeAnnouncement val_conv;
16139         val_conv.inner = (void*)(val & (~1));
16140         val_conv.is_owned = (val & 1) || (val == 0);
16141         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
16142         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
16143 }
16144
16145 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
16146         LDKSignature signature_arg_ref;
16147         CHECK(*((uint32_t*)signature_arg) == 64);
16148         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
16149         LDKUnsignedNodeAnnouncement contents_arg_conv;
16150         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16151         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16152         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
16153         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
16154         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16155         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16156         uint64_t ret_ref = (uint64_t)ret_var.inner;
16157         if (ret_var.is_owned) {
16158                 ret_ref |= 1;
16159         }
16160         return ret_ref;
16161 }
16162
16163 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
16164         LDKNodeAnnouncement orig_conv;
16165         orig_conv.inner = (void*)(orig & (~1));
16166         orig_conv.is_owned = false;
16167         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
16168         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16169         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16170         uint64_t ret_ref = (uint64_t)ret_var.inner;
16171         if (ret_var.is_owned) {
16172                 ret_ref |= 1;
16173         }
16174         return ret_ref;
16175 }
16176
16177 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
16178         LDKUnsignedChannelAnnouncement this_obj_conv;
16179         this_obj_conv.inner = (void*)(this_obj & (~1));
16180         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16181         UnsignedChannelAnnouncement_free(this_obj_conv);
16182 }
16183
16184 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
16185         LDKUnsignedChannelAnnouncement this_ptr_conv;
16186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16187         this_ptr_conv.is_owned = false;
16188         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
16189         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16190         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16191         uint64_t ret_ref = (uint64_t)ret_var.inner;
16192         if (ret_var.is_owned) {
16193                 ret_ref |= 1;
16194         }
16195         return ret_ref;
16196 }
16197
16198 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
16199         LDKUnsignedChannelAnnouncement this_ptr_conv;
16200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16201         this_ptr_conv.is_owned = false;
16202         LDKChannelFeatures val_conv;
16203         val_conv.inner = (void*)(val & (~1));
16204         val_conv.is_owned = (val & 1) || (val == 0);
16205         val_conv = ChannelFeatures_clone(&val_conv);
16206         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
16207 }
16208
16209 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
16210         LDKUnsignedChannelAnnouncement this_ptr_conv;
16211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16212         this_ptr_conv.is_owned = false;
16213         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16214         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
16215         return ret_arr;
16216 }
16217
16218 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16219         LDKUnsignedChannelAnnouncement this_ptr_conv;
16220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16221         this_ptr_conv.is_owned = false;
16222         LDKThirtyTwoBytes val_ref;
16223         CHECK(*((uint32_t*)val) == 32);
16224         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16225         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
16226 }
16227
16228 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
16229         LDKUnsignedChannelAnnouncement this_ptr_conv;
16230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16231         this_ptr_conv.is_owned = false;
16232         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
16233         return ret_val;
16234 }
16235
16236 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
16237         LDKUnsignedChannelAnnouncement this_ptr_conv;
16238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16239         this_ptr_conv.is_owned = false;
16240         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
16241 }
16242
16243 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
16244         LDKUnsignedChannelAnnouncement this_ptr_conv;
16245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16246         this_ptr_conv.is_owned = false;
16247         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16248         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
16249         return ret_arr;
16250 }
16251
16252 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
16253         LDKUnsignedChannelAnnouncement this_ptr_conv;
16254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16255         this_ptr_conv.is_owned = false;
16256         LDKPublicKey val_ref;
16257         CHECK(*((uint32_t*)val) == 33);
16258         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16259         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
16260 }
16261
16262 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
16263         LDKUnsignedChannelAnnouncement this_ptr_conv;
16264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16265         this_ptr_conv.is_owned = false;
16266         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16267         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
16268         return ret_arr;
16269 }
16270
16271 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
16272         LDKUnsignedChannelAnnouncement this_ptr_conv;
16273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16274         this_ptr_conv.is_owned = false;
16275         LDKPublicKey val_ref;
16276         CHECK(*((uint32_t*)val) == 33);
16277         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16278         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
16279 }
16280
16281 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
16282         LDKUnsignedChannelAnnouncement this_ptr_conv;
16283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16284         this_ptr_conv.is_owned = false;
16285         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16286         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
16287         return ret_arr;
16288 }
16289
16290 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
16291         LDKUnsignedChannelAnnouncement this_ptr_conv;
16292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16293         this_ptr_conv.is_owned = false;
16294         LDKPublicKey val_ref;
16295         CHECK(*((uint32_t*)val) == 33);
16296         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16297         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
16298 }
16299
16300 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
16301         LDKUnsignedChannelAnnouncement this_ptr_conv;
16302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16303         this_ptr_conv.is_owned = false;
16304         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16305         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
16306         return ret_arr;
16307 }
16308
16309 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
16310         LDKUnsignedChannelAnnouncement this_ptr_conv;
16311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16312         this_ptr_conv.is_owned = false;
16313         LDKPublicKey val_ref;
16314         CHECK(*((uint32_t*)val) == 33);
16315         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16316         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
16317 }
16318
16319 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
16320         LDKUnsignedChannelAnnouncement orig_conv;
16321         orig_conv.inner = (void*)(orig & (~1));
16322         orig_conv.is_owned = false;
16323         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
16324         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16325         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16326         uint64_t ret_ref = (uint64_t)ret_var.inner;
16327         if (ret_var.is_owned) {
16328                 ret_ref |= 1;
16329         }
16330         return ret_ref;
16331 }
16332
16333 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
16334         LDKChannelAnnouncement this_obj_conv;
16335         this_obj_conv.inner = (void*)(this_obj & (~1));
16336         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16337         ChannelAnnouncement_free(this_obj_conv);
16338 }
16339
16340 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
16341         LDKChannelAnnouncement this_ptr_conv;
16342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16343         this_ptr_conv.is_owned = false;
16344         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16345         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
16346         return ret_arr;
16347 }
16348
16349 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
16350         LDKChannelAnnouncement this_ptr_conv;
16351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16352         this_ptr_conv.is_owned = false;
16353         LDKSignature val_ref;
16354         CHECK(*((uint32_t*)val) == 64);
16355         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16356         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
16357 }
16358
16359 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
16360         LDKChannelAnnouncement this_ptr_conv;
16361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16362         this_ptr_conv.is_owned = false;
16363         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16364         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
16365         return ret_arr;
16366 }
16367
16368 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
16369         LDKChannelAnnouncement this_ptr_conv;
16370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16371         this_ptr_conv.is_owned = false;
16372         LDKSignature val_ref;
16373         CHECK(*((uint32_t*)val) == 64);
16374         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16375         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
16376 }
16377
16378 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
16379         LDKChannelAnnouncement this_ptr_conv;
16380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16381         this_ptr_conv.is_owned = false;
16382         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16383         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
16384         return ret_arr;
16385 }
16386
16387 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
16388         LDKChannelAnnouncement this_ptr_conv;
16389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16390         this_ptr_conv.is_owned = false;
16391         LDKSignature val_ref;
16392         CHECK(*((uint32_t*)val) == 64);
16393         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16394         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
16395 }
16396
16397 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
16398         LDKChannelAnnouncement this_ptr_conv;
16399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16400         this_ptr_conv.is_owned = false;
16401         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16402         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
16403         return ret_arr;
16404 }
16405
16406 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
16407         LDKChannelAnnouncement this_ptr_conv;
16408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16409         this_ptr_conv.is_owned = false;
16410         LDKSignature val_ref;
16411         CHECK(*((uint32_t*)val) == 64);
16412         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16413         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
16414 }
16415
16416 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
16417         LDKChannelAnnouncement this_ptr_conv;
16418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16419         this_ptr_conv.is_owned = false;
16420         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
16421         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16422         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16423         uint64_t ret_ref = (uint64_t)ret_var.inner;
16424         if (ret_var.is_owned) {
16425                 ret_ref |= 1;
16426         }
16427         return ret_ref;
16428 }
16429
16430 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
16431         LDKChannelAnnouncement this_ptr_conv;
16432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16433         this_ptr_conv.is_owned = false;
16434         LDKUnsignedChannelAnnouncement val_conv;
16435         val_conv.inner = (void*)(val & (~1));
16436         val_conv.is_owned = (val & 1) || (val == 0);
16437         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
16438         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
16439 }
16440
16441 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) {
16442         LDKSignature node_signature_1_arg_ref;
16443         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
16444         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
16445         LDKSignature node_signature_2_arg_ref;
16446         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
16447         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
16448         LDKSignature bitcoin_signature_1_arg_ref;
16449         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
16450         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
16451         LDKSignature bitcoin_signature_2_arg_ref;
16452         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
16453         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
16454         LDKUnsignedChannelAnnouncement contents_arg_conv;
16455         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16456         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16457         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
16458         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);
16459         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16460         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16461         uint64_t ret_ref = (uint64_t)ret_var.inner;
16462         if (ret_var.is_owned) {
16463                 ret_ref |= 1;
16464         }
16465         return ret_ref;
16466 }
16467
16468 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
16469         LDKChannelAnnouncement orig_conv;
16470         orig_conv.inner = (void*)(orig & (~1));
16471         orig_conv.is_owned = false;
16472         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
16473         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16474         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16475         uint64_t ret_ref = (uint64_t)ret_var.inner;
16476         if (ret_var.is_owned) {
16477                 ret_ref |= 1;
16478         }
16479         return ret_ref;
16480 }
16481
16482 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
16483         LDKUnsignedChannelUpdate this_obj_conv;
16484         this_obj_conv.inner = (void*)(this_obj & (~1));
16485         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16486         UnsignedChannelUpdate_free(this_obj_conv);
16487 }
16488
16489 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
16490         LDKUnsignedChannelUpdate this_ptr_conv;
16491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16492         this_ptr_conv.is_owned = false;
16493         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16494         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
16495         return ret_arr;
16496 }
16497
16498 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16499         LDKUnsignedChannelUpdate this_ptr_conv;
16500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16501         this_ptr_conv.is_owned = false;
16502         LDKThirtyTwoBytes val_ref;
16503         CHECK(*((uint32_t*)val) == 32);
16504         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16505         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
16506 }
16507
16508 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
16509         LDKUnsignedChannelUpdate this_ptr_conv;
16510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16511         this_ptr_conv.is_owned = false;
16512         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
16513         return ret_val;
16514 }
16515
16516 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
16517         LDKUnsignedChannelUpdate this_ptr_conv;
16518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16519         this_ptr_conv.is_owned = false;
16520         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
16521 }
16522
16523 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
16524         LDKUnsignedChannelUpdate this_ptr_conv;
16525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16526         this_ptr_conv.is_owned = false;
16527         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
16528         return ret_val;
16529 }
16530
16531 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
16532         LDKUnsignedChannelUpdate this_ptr_conv;
16533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16534         this_ptr_conv.is_owned = false;
16535         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
16536 }
16537
16538 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
16539         LDKUnsignedChannelUpdate this_ptr_conv;
16540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16541         this_ptr_conv.is_owned = false;
16542         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
16543         return ret_val;
16544 }
16545
16546 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
16547         LDKUnsignedChannelUpdate this_ptr_conv;
16548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16549         this_ptr_conv.is_owned = false;
16550         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
16551 }
16552
16553 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
16554         LDKUnsignedChannelUpdate this_ptr_conv;
16555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16556         this_ptr_conv.is_owned = false;
16557         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
16558         return ret_val;
16559 }
16560
16561 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
16562         LDKUnsignedChannelUpdate this_ptr_conv;
16563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16564         this_ptr_conv.is_owned = false;
16565         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
16566 }
16567
16568 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
16569         LDKUnsignedChannelUpdate this_ptr_conv;
16570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16571         this_ptr_conv.is_owned = false;
16572         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
16573         return ret_val;
16574 }
16575
16576 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
16577         LDKUnsignedChannelUpdate this_ptr_conv;
16578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16579         this_ptr_conv.is_owned = false;
16580         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
16581 }
16582
16583 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
16584         LDKUnsignedChannelUpdate this_ptr_conv;
16585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16586         this_ptr_conv.is_owned = false;
16587         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
16588         return ret_val;
16589 }
16590
16591 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
16592         LDKUnsignedChannelUpdate this_ptr_conv;
16593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16594         this_ptr_conv.is_owned = false;
16595         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
16596 }
16597
16598 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
16599         LDKUnsignedChannelUpdate this_ptr_conv;
16600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16601         this_ptr_conv.is_owned = false;
16602         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
16603         return ret_val;
16604 }
16605
16606 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
16607         LDKUnsignedChannelUpdate this_ptr_conv;
16608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16609         this_ptr_conv.is_owned = false;
16610         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
16611 }
16612
16613 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
16614         LDKUnsignedChannelUpdate orig_conv;
16615         orig_conv.inner = (void*)(orig & (~1));
16616         orig_conv.is_owned = false;
16617         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
16618         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16619         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16620         uint64_t ret_ref = (uint64_t)ret_var.inner;
16621         if (ret_var.is_owned) {
16622                 ret_ref |= 1;
16623         }
16624         return ret_ref;
16625 }
16626
16627 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
16628         LDKChannelUpdate this_obj_conv;
16629         this_obj_conv.inner = (void*)(this_obj & (~1));
16630         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16631         ChannelUpdate_free(this_obj_conv);
16632 }
16633
16634 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
16635         LDKChannelUpdate this_ptr_conv;
16636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16637         this_ptr_conv.is_owned = false;
16638         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16639         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
16640         return ret_arr;
16641 }
16642
16643 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
16644         LDKChannelUpdate this_ptr_conv;
16645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16646         this_ptr_conv.is_owned = false;
16647         LDKSignature val_ref;
16648         CHECK(*((uint32_t*)val) == 64);
16649         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16650         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
16651 }
16652
16653 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
16654         LDKChannelUpdate this_ptr_conv;
16655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16656         this_ptr_conv.is_owned = false;
16657         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
16658         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16659         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16660         uint64_t ret_ref = (uint64_t)ret_var.inner;
16661         if (ret_var.is_owned) {
16662                 ret_ref |= 1;
16663         }
16664         return ret_ref;
16665 }
16666
16667 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
16668         LDKChannelUpdate this_ptr_conv;
16669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16670         this_ptr_conv.is_owned = false;
16671         LDKUnsignedChannelUpdate val_conv;
16672         val_conv.inner = (void*)(val & (~1));
16673         val_conv.is_owned = (val & 1) || (val == 0);
16674         val_conv = UnsignedChannelUpdate_clone(&val_conv);
16675         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
16676 }
16677
16678 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
16679         LDKSignature signature_arg_ref;
16680         CHECK(*((uint32_t*)signature_arg) == 64);
16681         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
16682         LDKUnsignedChannelUpdate contents_arg_conv;
16683         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16684         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16685         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
16686         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
16687         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16688         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16689         uint64_t ret_ref = (uint64_t)ret_var.inner;
16690         if (ret_var.is_owned) {
16691                 ret_ref |= 1;
16692         }
16693         return ret_ref;
16694 }
16695
16696 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
16697         LDKChannelUpdate orig_conv;
16698         orig_conv.inner = (void*)(orig & (~1));
16699         orig_conv.is_owned = false;
16700         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
16701         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16702         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16703         uint64_t ret_ref = (uint64_t)ret_var.inner;
16704         if (ret_var.is_owned) {
16705                 ret_ref |= 1;
16706         }
16707         return ret_ref;
16708 }
16709
16710 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
16711         LDKQueryChannelRange this_obj_conv;
16712         this_obj_conv.inner = (void*)(this_obj & (~1));
16713         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16714         QueryChannelRange_free(this_obj_conv);
16715 }
16716
16717 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
16718         LDKQueryChannelRange this_ptr_conv;
16719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16720         this_ptr_conv.is_owned = false;
16721         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16722         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
16723         return ret_arr;
16724 }
16725
16726 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16727         LDKQueryChannelRange this_ptr_conv;
16728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16729         this_ptr_conv.is_owned = false;
16730         LDKThirtyTwoBytes val_ref;
16731         CHECK(*((uint32_t*)val) == 32);
16732         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16733         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
16734 }
16735
16736 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
16737         LDKQueryChannelRange this_ptr_conv;
16738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16739         this_ptr_conv.is_owned = false;
16740         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
16741         return ret_val;
16742 }
16743
16744 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
16745         LDKQueryChannelRange this_ptr_conv;
16746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16747         this_ptr_conv.is_owned = false;
16748         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
16749 }
16750
16751 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
16752         LDKQueryChannelRange this_ptr_conv;
16753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16754         this_ptr_conv.is_owned = false;
16755         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
16756         return ret_val;
16757 }
16758
16759 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
16760         LDKQueryChannelRange this_ptr_conv;
16761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16762         this_ptr_conv.is_owned = false;
16763         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
16764 }
16765
16766 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
16767         LDKThirtyTwoBytes chain_hash_arg_ref;
16768         CHECK(*((uint32_t*)chain_hash_arg) == 32);
16769         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
16770         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
16771         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16772         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16773         uint64_t ret_ref = (uint64_t)ret_var.inner;
16774         if (ret_var.is_owned) {
16775                 ret_ref |= 1;
16776         }
16777         return ret_ref;
16778 }
16779
16780 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
16781         LDKQueryChannelRange orig_conv;
16782         orig_conv.inner = (void*)(orig & (~1));
16783         orig_conv.is_owned = false;
16784         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
16785         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16786         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16787         uint64_t ret_ref = (uint64_t)ret_var.inner;
16788         if (ret_var.is_owned) {
16789                 ret_ref |= 1;
16790         }
16791         return ret_ref;
16792 }
16793
16794 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
16795         LDKReplyChannelRange this_obj_conv;
16796         this_obj_conv.inner = (void*)(this_obj & (~1));
16797         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16798         ReplyChannelRange_free(this_obj_conv);
16799 }
16800
16801 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
16802         LDKReplyChannelRange this_ptr_conv;
16803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16804         this_ptr_conv.is_owned = false;
16805         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16806         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
16807         return ret_arr;
16808 }
16809
16810 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16811         LDKReplyChannelRange this_ptr_conv;
16812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16813         this_ptr_conv.is_owned = false;
16814         LDKThirtyTwoBytes val_ref;
16815         CHECK(*((uint32_t*)val) == 32);
16816         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16817         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
16818 }
16819
16820 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
16821         LDKReplyChannelRange this_ptr_conv;
16822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16823         this_ptr_conv.is_owned = false;
16824         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
16825         return ret_val;
16826 }
16827
16828 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
16829         LDKReplyChannelRange this_ptr_conv;
16830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16831         this_ptr_conv.is_owned = false;
16832         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
16833 }
16834
16835 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
16836         LDKReplyChannelRange this_ptr_conv;
16837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16838         this_ptr_conv.is_owned = false;
16839         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
16840         return ret_val;
16841 }
16842
16843 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
16844         LDKReplyChannelRange this_ptr_conv;
16845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16846         this_ptr_conv.is_owned = false;
16847         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
16848 }
16849
16850 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
16851         LDKReplyChannelRange this_ptr_conv;
16852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16853         this_ptr_conv.is_owned = false;
16854         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
16855         return ret_val;
16856 }
16857
16858 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
16859         LDKReplyChannelRange this_ptr_conv;
16860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16861         this_ptr_conv.is_owned = false;
16862         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
16863 }
16864
16865 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
16866         LDKReplyChannelRange this_ptr_conv;
16867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16868         this_ptr_conv.is_owned = false;
16869         LDKCVec_u64Z val_constr;
16870         val_constr.datalen = *((uint32_t*)val);
16871         if (val_constr.datalen > 0)
16872                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16873         else
16874                 val_constr.data = NULL;
16875         int64_t* val_vals = (int64_t*)(val + 4);
16876         for (size_t i = 0; i < val_constr.datalen; i++) {
16877                 int64_t val_conv_8 = val_vals[i];
16878                 val_constr.data[i] = val_conv_8;
16879         }
16880         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
16881 }
16882
16883 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) {
16884         LDKThirtyTwoBytes chain_hash_arg_ref;
16885         CHECK(*((uint32_t*)chain_hash_arg) == 32);
16886         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
16887         LDKCVec_u64Z short_channel_ids_arg_constr;
16888         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
16889         if (short_channel_ids_arg_constr.datalen > 0)
16890                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16891         else
16892                 short_channel_ids_arg_constr.data = NULL;
16893         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
16894         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
16895                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
16896                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
16897         }
16898         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
16899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16901         uint64_t ret_ref = (uint64_t)ret_var.inner;
16902         if (ret_var.is_owned) {
16903                 ret_ref |= 1;
16904         }
16905         return ret_ref;
16906 }
16907
16908 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
16909         LDKReplyChannelRange orig_conv;
16910         orig_conv.inner = (void*)(orig & (~1));
16911         orig_conv.is_owned = false;
16912         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
16913         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16914         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16915         uint64_t ret_ref = (uint64_t)ret_var.inner;
16916         if (ret_var.is_owned) {
16917                 ret_ref |= 1;
16918         }
16919         return ret_ref;
16920 }
16921
16922 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
16923         LDKQueryShortChannelIds this_obj_conv;
16924         this_obj_conv.inner = (void*)(this_obj & (~1));
16925         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16926         QueryShortChannelIds_free(this_obj_conv);
16927 }
16928
16929 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
16930         LDKQueryShortChannelIds this_ptr_conv;
16931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16932         this_ptr_conv.is_owned = false;
16933         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16934         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
16935         return ret_arr;
16936 }
16937
16938 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16939         LDKQueryShortChannelIds this_ptr_conv;
16940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16941         this_ptr_conv.is_owned = false;
16942         LDKThirtyTwoBytes val_ref;
16943         CHECK(*((uint32_t*)val) == 32);
16944         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16945         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
16946 }
16947
16948 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
16949         LDKQueryShortChannelIds this_ptr_conv;
16950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16951         this_ptr_conv.is_owned = false;
16952         LDKCVec_u64Z val_constr;
16953         val_constr.datalen = *((uint32_t*)val);
16954         if (val_constr.datalen > 0)
16955                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16956         else
16957                 val_constr.data = NULL;
16958         int64_t* val_vals = (int64_t*)(val + 4);
16959         for (size_t i = 0; i < val_constr.datalen; i++) {
16960                 int64_t val_conv_8 = val_vals[i];
16961                 val_constr.data[i] = val_conv_8;
16962         }
16963         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
16964 }
16965
16966 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
16967         LDKThirtyTwoBytes chain_hash_arg_ref;
16968         CHECK(*((uint32_t*)chain_hash_arg) == 32);
16969         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
16970         LDKCVec_u64Z short_channel_ids_arg_constr;
16971         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
16972         if (short_channel_ids_arg_constr.datalen > 0)
16973                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16974         else
16975                 short_channel_ids_arg_constr.data = NULL;
16976         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
16977         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
16978                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
16979                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
16980         }
16981         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
16982         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16983         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16984         uint64_t ret_ref = (uint64_t)ret_var.inner;
16985         if (ret_var.is_owned) {
16986                 ret_ref |= 1;
16987         }
16988         return ret_ref;
16989 }
16990
16991 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
16992         LDKQueryShortChannelIds orig_conv;
16993         orig_conv.inner = (void*)(orig & (~1));
16994         orig_conv.is_owned = false;
16995         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
16996         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16997         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16998         uint64_t ret_ref = (uint64_t)ret_var.inner;
16999         if (ret_var.is_owned) {
17000                 ret_ref |= 1;
17001         }
17002         return ret_ref;
17003 }
17004
17005 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
17006         LDKReplyShortChannelIdsEnd this_obj_conv;
17007         this_obj_conv.inner = (void*)(this_obj & (~1));
17008         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17009         ReplyShortChannelIdsEnd_free(this_obj_conv);
17010 }
17011
17012 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
17013         LDKReplyShortChannelIdsEnd this_ptr_conv;
17014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17015         this_ptr_conv.is_owned = false;
17016         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17017         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
17018         return ret_arr;
17019 }
17020
17021 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17022         LDKReplyShortChannelIdsEnd this_ptr_conv;
17023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17024         this_ptr_conv.is_owned = false;
17025         LDKThirtyTwoBytes val_ref;
17026         CHECK(*((uint32_t*)val) == 32);
17027         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17028         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
17029 }
17030
17031 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
17032         LDKReplyShortChannelIdsEnd this_ptr_conv;
17033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17034         this_ptr_conv.is_owned = false;
17035         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
17036         return ret_val;
17037 }
17038
17039 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
17040         LDKReplyShortChannelIdsEnd this_ptr_conv;
17041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17042         this_ptr_conv.is_owned = false;
17043         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
17044 }
17045
17046 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
17047         LDKThirtyTwoBytes chain_hash_arg_ref;
17048         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17049         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17050         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
17051         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17052         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17053         uint64_t ret_ref = (uint64_t)ret_var.inner;
17054         if (ret_var.is_owned) {
17055                 ret_ref |= 1;
17056         }
17057         return ret_ref;
17058 }
17059
17060 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
17061         LDKReplyShortChannelIdsEnd orig_conv;
17062         orig_conv.inner = (void*)(orig & (~1));
17063         orig_conv.is_owned = false;
17064         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
17065         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17066         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17067         uint64_t ret_ref = (uint64_t)ret_var.inner;
17068         if (ret_var.is_owned) {
17069                 ret_ref |= 1;
17070         }
17071         return ret_ref;
17072 }
17073
17074 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
17075         LDKGossipTimestampFilter this_obj_conv;
17076         this_obj_conv.inner = (void*)(this_obj & (~1));
17077         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17078         GossipTimestampFilter_free(this_obj_conv);
17079 }
17080
17081 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
17082         LDKGossipTimestampFilter this_ptr_conv;
17083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17084         this_ptr_conv.is_owned = false;
17085         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17086         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
17087         return ret_arr;
17088 }
17089
17090 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17091         LDKGossipTimestampFilter this_ptr_conv;
17092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17093         this_ptr_conv.is_owned = false;
17094         LDKThirtyTwoBytes val_ref;
17095         CHECK(*((uint32_t*)val) == 32);
17096         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17097         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
17098 }
17099
17100 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
17101         LDKGossipTimestampFilter this_ptr_conv;
17102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17103         this_ptr_conv.is_owned = false;
17104         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
17105         return ret_val;
17106 }
17107
17108 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
17109         LDKGossipTimestampFilter this_ptr_conv;
17110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17111         this_ptr_conv.is_owned = false;
17112         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
17113 }
17114
17115 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
17116         LDKGossipTimestampFilter this_ptr_conv;
17117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17118         this_ptr_conv.is_owned = false;
17119         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
17120         return ret_val;
17121 }
17122
17123 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
17124         LDKGossipTimestampFilter this_ptr_conv;
17125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17126         this_ptr_conv.is_owned = false;
17127         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
17128 }
17129
17130 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
17131         LDKThirtyTwoBytes chain_hash_arg_ref;
17132         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17133         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17134         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
17135         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17136         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17137         uint64_t ret_ref = (uint64_t)ret_var.inner;
17138         if (ret_var.is_owned) {
17139                 ret_ref |= 1;
17140         }
17141         return ret_ref;
17142 }
17143
17144 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
17145         LDKGossipTimestampFilter orig_conv;
17146         orig_conv.inner = (void*)(orig & (~1));
17147         orig_conv.is_owned = false;
17148         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
17149         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17150         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17151         uint64_t ret_ref = (uint64_t)ret_var.inner;
17152         if (ret_var.is_owned) {
17153                 ret_ref |= 1;
17154         }
17155         return ret_ref;
17156 }
17157
17158 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
17159         if ((this_ptr & 1) != 0) return;
17160         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
17161         FREE((void*)this_ptr);
17162         ErrorAction_free(this_ptr_conv);
17163 }
17164
17165 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
17166         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
17167         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
17168         *ret_copy = ErrorAction_clone(orig_conv);
17169         uint64_t ret_ref = (uint64_t)ret_copy;
17170         return ret_ref;
17171 }
17172
17173 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
17174         LDKLightningError this_obj_conv;
17175         this_obj_conv.inner = (void*)(this_obj & (~1));
17176         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17177         LightningError_free(this_obj_conv);
17178 }
17179
17180 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
17181         LDKLightningError this_ptr_conv;
17182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17183         this_ptr_conv.is_owned = false;
17184         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
17185         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17186         return ret_conv;
17187 }
17188
17189 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
17190         LDKLightningError this_ptr_conv;
17191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17192         this_ptr_conv.is_owned = false;
17193         LDKStr val_conv = str_ref_to_owned_c(val);
17194         LightningError_set_err(&this_ptr_conv, val_conv);
17195 }
17196
17197 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
17198         LDKLightningError this_ptr_conv;
17199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17200         this_ptr_conv.is_owned = false;
17201         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
17202         *ret_copy = LightningError_get_action(&this_ptr_conv);
17203         uint64_t ret_ref = (uint64_t)ret_copy;
17204         return ret_ref;
17205 }
17206
17207 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
17208         LDKLightningError this_ptr_conv;
17209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17210         this_ptr_conv.is_owned = false;
17211         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
17212         LightningError_set_action(&this_ptr_conv, val_conv);
17213 }
17214
17215 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
17216         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
17217         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
17218         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
17219         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17220         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17221         uint64_t ret_ref = (uint64_t)ret_var.inner;
17222         if (ret_var.is_owned) {
17223                 ret_ref |= 1;
17224         }
17225         return ret_ref;
17226 }
17227
17228 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
17229         LDKLightningError orig_conv;
17230         orig_conv.inner = (void*)(orig & (~1));
17231         orig_conv.is_owned = false;
17232         LDKLightningError ret_var = LightningError_clone(&orig_conv);
17233         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17234         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17235         uint64_t ret_ref = (uint64_t)ret_var.inner;
17236         if (ret_var.is_owned) {
17237                 ret_ref |= 1;
17238         }
17239         return ret_ref;
17240 }
17241
17242 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
17243         LDKCommitmentUpdate this_obj_conv;
17244         this_obj_conv.inner = (void*)(this_obj & (~1));
17245         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17246         CommitmentUpdate_free(this_obj_conv);
17247 }
17248
17249 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
17250         LDKCommitmentUpdate this_ptr_conv;
17251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17252         this_ptr_conv.is_owned = false;
17253         LDKCVec_UpdateAddHTLCZ val_constr;
17254         val_constr.datalen = *((uint32_t*)val);
17255         if (val_constr.datalen > 0)
17256                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17257         else
17258                 val_constr.data = NULL;
17259         uint32_t* val_vals = (uint32_t*)(val + 4);
17260         for (size_t p = 0; p < val_constr.datalen; p++) {
17261                 uint32_t val_conv_15 = val_vals[p];
17262                 LDKUpdateAddHTLC val_conv_15_conv;
17263                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
17264                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
17265                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
17266                 val_constr.data[p] = val_conv_15_conv;
17267         }
17268         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
17269 }
17270
17271 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
17272         LDKCommitmentUpdate this_ptr_conv;
17273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17274         this_ptr_conv.is_owned = false;
17275         LDKCVec_UpdateFulfillHTLCZ val_constr;
17276         val_constr.datalen = *((uint32_t*)val);
17277         if (val_constr.datalen > 0)
17278                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17279         else
17280                 val_constr.data = NULL;
17281         uint32_t* val_vals = (uint32_t*)(val + 4);
17282         for (size_t t = 0; t < val_constr.datalen; t++) {
17283                 uint32_t val_conv_19 = val_vals[t];
17284                 LDKUpdateFulfillHTLC val_conv_19_conv;
17285                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
17286                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
17287                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
17288                 val_constr.data[t] = val_conv_19_conv;
17289         }
17290         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
17291 }
17292
17293 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
17294         LDKCommitmentUpdate this_ptr_conv;
17295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17296         this_ptr_conv.is_owned = false;
17297         LDKCVec_UpdateFailHTLCZ val_constr;
17298         val_constr.datalen = *((uint32_t*)val);
17299         if (val_constr.datalen > 0)
17300                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17301         else
17302                 val_constr.data = NULL;
17303         uint32_t* val_vals = (uint32_t*)(val + 4);
17304         for (size_t q = 0; q < val_constr.datalen; q++) {
17305                 uint32_t val_conv_16 = val_vals[q];
17306                 LDKUpdateFailHTLC val_conv_16_conv;
17307                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
17308                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
17309                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
17310                 val_constr.data[q] = val_conv_16_conv;
17311         }
17312         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
17313 }
17314
17315 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
17316         LDKCommitmentUpdate this_ptr_conv;
17317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17318         this_ptr_conv.is_owned = false;
17319         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
17320         val_constr.datalen = *((uint32_t*)val);
17321         if (val_constr.datalen > 0)
17322                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17323         else
17324                 val_constr.data = NULL;
17325         uint32_t* val_vals = (uint32_t*)(val + 4);
17326         for (size_t z = 0; z < val_constr.datalen; z++) {
17327                 uint32_t val_conv_25 = val_vals[z];
17328                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
17329                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
17330                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
17331                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
17332                 val_constr.data[z] = val_conv_25_conv;
17333         }
17334         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
17335 }
17336
17337 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
17338         LDKCommitmentUpdate this_ptr_conv;
17339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17340         this_ptr_conv.is_owned = false;
17341         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
17342         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17343         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17344         uint64_t ret_ref = (uint64_t)ret_var.inner;
17345         if (ret_var.is_owned) {
17346                 ret_ref |= 1;
17347         }
17348         return ret_ref;
17349 }
17350
17351 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
17352         LDKCommitmentUpdate this_ptr_conv;
17353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17354         this_ptr_conv.is_owned = false;
17355         LDKUpdateFee val_conv;
17356         val_conv.inner = (void*)(val & (~1));
17357         val_conv.is_owned = (val & 1) || (val == 0);
17358         val_conv = UpdateFee_clone(&val_conv);
17359         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
17360 }
17361
17362 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
17363         LDKCommitmentUpdate this_ptr_conv;
17364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17365         this_ptr_conv.is_owned = false;
17366         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
17367         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17368         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17369         uint64_t ret_ref = (uint64_t)ret_var.inner;
17370         if (ret_var.is_owned) {
17371                 ret_ref |= 1;
17372         }
17373         return ret_ref;
17374 }
17375
17376 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
17377         LDKCommitmentUpdate this_ptr_conv;
17378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17379         this_ptr_conv.is_owned = false;
17380         LDKCommitmentSigned val_conv;
17381         val_conv.inner = (void*)(val & (~1));
17382         val_conv.is_owned = (val & 1) || (val == 0);
17383         val_conv = CommitmentSigned_clone(&val_conv);
17384         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
17385 }
17386
17387 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) {
17388         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
17389         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
17390         if (update_add_htlcs_arg_constr.datalen > 0)
17391                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17392         else
17393                 update_add_htlcs_arg_constr.data = NULL;
17394         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
17395         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
17396                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
17397                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
17398                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
17399                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
17400                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
17401                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
17402         }
17403         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
17404         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
17405         if (update_fulfill_htlcs_arg_constr.datalen > 0)
17406                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17407         else
17408                 update_fulfill_htlcs_arg_constr.data = NULL;
17409         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
17410         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
17411                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
17412                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
17413                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
17414                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
17415                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
17416                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
17417         }
17418         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
17419         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
17420         if (update_fail_htlcs_arg_constr.datalen > 0)
17421                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17422         else
17423                 update_fail_htlcs_arg_constr.data = NULL;
17424         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
17425         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
17426                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
17427                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
17428                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
17429                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
17430                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
17431                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
17432         }
17433         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
17434         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
17435         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
17436                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17437         else
17438                 update_fail_malformed_htlcs_arg_constr.data = NULL;
17439         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
17440         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
17441                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
17442                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
17443                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
17444                 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);
17445                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
17446                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
17447         }
17448         LDKUpdateFee update_fee_arg_conv;
17449         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
17450         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
17451         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
17452         LDKCommitmentSigned commitment_signed_arg_conv;
17453         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
17454         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
17455         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
17456         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);
17457         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17458         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17459         uint64_t ret_ref = (uint64_t)ret_var.inner;
17460         if (ret_var.is_owned) {
17461                 ret_ref |= 1;
17462         }
17463         return ret_ref;
17464 }
17465
17466 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
17467         LDKCommitmentUpdate orig_conv;
17468         orig_conv.inner = (void*)(orig & (~1));
17469         orig_conv.is_owned = false;
17470         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_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 void  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) {
17481         if ((this_ptr & 1) != 0) return;
17482         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
17483         FREE((void*)this_ptr);
17484         HTLCFailChannelUpdate_free(this_ptr_conv);
17485 }
17486
17487 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) {
17488         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
17489         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
17490         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
17491         uint64_t ret_ref = (uint64_t)ret_copy;
17492         return ret_ref;
17493 }
17494
17495 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
17496         if ((this_ptr & 1) != 0) return;
17497         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
17498         FREE((void*)this_ptr);
17499         ChannelMessageHandler_free(this_ptr_conv);
17500 }
17501
17502 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
17503         if ((this_ptr & 1) != 0) return;
17504         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
17505         FREE((void*)this_ptr);
17506         RoutingMessageHandler_free(this_ptr_conv);
17507 }
17508
17509 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
17510         LDKAcceptChannel obj_conv;
17511         obj_conv.inner = (void*)(obj & (~1));
17512         obj_conv.is_owned = false;
17513         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
17514         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17515         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17516         CVec_u8Z_free(ret_var);
17517         return ret_arr;
17518 }
17519
17520 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
17521         LDKu8slice ser_ref;
17522         ser_ref.datalen = *((uint32_t*)ser);
17523         ser_ref.data = (int8_t*)(ser + 4);
17524         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17525         *ret_conv = AcceptChannel_read(ser_ref);
17526         return (uint64_t)ret_conv;
17527 }
17528
17529 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
17530         LDKAnnouncementSignatures obj_conv;
17531         obj_conv.inner = (void*)(obj & (~1));
17532         obj_conv.is_owned = false;
17533         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
17534         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17535         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17536         CVec_u8Z_free(ret_var);
17537         return ret_arr;
17538 }
17539
17540 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
17541         LDKu8slice ser_ref;
17542         ser_ref.datalen = *((uint32_t*)ser);
17543         ser_ref.data = (int8_t*)(ser + 4);
17544         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17545         *ret_conv = AnnouncementSignatures_read(ser_ref);
17546         return (uint64_t)ret_conv;
17547 }
17548
17549 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
17550         LDKChannelReestablish obj_conv;
17551         obj_conv.inner = (void*)(obj & (~1));
17552         obj_conv.is_owned = false;
17553         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
17554         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17555         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17556         CVec_u8Z_free(ret_var);
17557         return ret_arr;
17558 }
17559
17560 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
17561         LDKu8slice ser_ref;
17562         ser_ref.datalen = *((uint32_t*)ser);
17563         ser_ref.data = (int8_t*)(ser + 4);
17564         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17565         *ret_conv = ChannelReestablish_read(ser_ref);
17566         return (uint64_t)ret_conv;
17567 }
17568
17569 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
17570         LDKClosingSigned obj_conv;
17571         obj_conv.inner = (void*)(obj & (~1));
17572         obj_conv.is_owned = false;
17573         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
17574         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17575         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17576         CVec_u8Z_free(ret_var);
17577         return ret_arr;
17578 }
17579
17580 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
17581         LDKu8slice ser_ref;
17582         ser_ref.datalen = *((uint32_t*)ser);
17583         ser_ref.data = (int8_t*)(ser + 4);
17584         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17585         *ret_conv = ClosingSigned_read(ser_ref);
17586         return (uint64_t)ret_conv;
17587 }
17588
17589 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
17590         LDKCommitmentSigned obj_conv;
17591         obj_conv.inner = (void*)(obj & (~1));
17592         obj_conv.is_owned = false;
17593         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
17594         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17595         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17596         CVec_u8Z_free(ret_var);
17597         return ret_arr;
17598 }
17599
17600 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
17601         LDKu8slice ser_ref;
17602         ser_ref.datalen = *((uint32_t*)ser);
17603         ser_ref.data = (int8_t*)(ser + 4);
17604         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17605         *ret_conv = CommitmentSigned_read(ser_ref);
17606         return (uint64_t)ret_conv;
17607 }
17608
17609 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
17610         LDKFundingCreated obj_conv;
17611         obj_conv.inner = (void*)(obj & (~1));
17612         obj_conv.is_owned = false;
17613         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
17614         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17615         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17616         CVec_u8Z_free(ret_var);
17617         return ret_arr;
17618 }
17619
17620 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
17621         LDKu8slice ser_ref;
17622         ser_ref.datalen = *((uint32_t*)ser);
17623         ser_ref.data = (int8_t*)(ser + 4);
17624         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17625         *ret_conv = FundingCreated_read(ser_ref);
17626         return (uint64_t)ret_conv;
17627 }
17628
17629 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
17630         LDKFundingSigned obj_conv;
17631         obj_conv.inner = (void*)(obj & (~1));
17632         obj_conv.is_owned = false;
17633         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
17634         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17635         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17636         CVec_u8Z_free(ret_var);
17637         return ret_arr;
17638 }
17639
17640 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
17641         LDKu8slice ser_ref;
17642         ser_ref.datalen = *((uint32_t*)ser);
17643         ser_ref.data = (int8_t*)(ser + 4);
17644         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17645         *ret_conv = FundingSigned_read(ser_ref);
17646         return (uint64_t)ret_conv;
17647 }
17648
17649 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
17650         LDKFundingLocked obj_conv;
17651         obj_conv.inner = (void*)(obj & (~1));
17652         obj_conv.is_owned = false;
17653         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
17654         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17655         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17656         CVec_u8Z_free(ret_var);
17657         return ret_arr;
17658 }
17659
17660 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
17661         LDKu8slice ser_ref;
17662         ser_ref.datalen = *((uint32_t*)ser);
17663         ser_ref.data = (int8_t*)(ser + 4);
17664         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17665         *ret_conv = FundingLocked_read(ser_ref);
17666         return (uint64_t)ret_conv;
17667 }
17668
17669 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
17670         LDKInit obj_conv;
17671         obj_conv.inner = (void*)(obj & (~1));
17672         obj_conv.is_owned = false;
17673         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
17674         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17675         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17676         CVec_u8Z_free(ret_var);
17677         return ret_arr;
17678 }
17679
17680 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
17681         LDKu8slice ser_ref;
17682         ser_ref.datalen = *((uint32_t*)ser);
17683         ser_ref.data = (int8_t*)(ser + 4);
17684         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17685         *ret_conv = Init_read(ser_ref);
17686         return (uint64_t)ret_conv;
17687 }
17688
17689 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
17690         LDKOpenChannel obj_conv;
17691         obj_conv.inner = (void*)(obj & (~1));
17692         obj_conv.is_owned = false;
17693         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
17694         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17695         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17696         CVec_u8Z_free(ret_var);
17697         return ret_arr;
17698 }
17699
17700 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
17701         LDKu8slice ser_ref;
17702         ser_ref.datalen = *((uint32_t*)ser);
17703         ser_ref.data = (int8_t*)(ser + 4);
17704         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17705         *ret_conv = OpenChannel_read(ser_ref);
17706         return (uint64_t)ret_conv;
17707 }
17708
17709 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
17710         LDKRevokeAndACK obj_conv;
17711         obj_conv.inner = (void*)(obj & (~1));
17712         obj_conv.is_owned = false;
17713         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
17714         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17715         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17716         CVec_u8Z_free(ret_var);
17717         return ret_arr;
17718 }
17719
17720 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
17721         LDKu8slice ser_ref;
17722         ser_ref.datalen = *((uint32_t*)ser);
17723         ser_ref.data = (int8_t*)(ser + 4);
17724         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17725         *ret_conv = RevokeAndACK_read(ser_ref);
17726         return (uint64_t)ret_conv;
17727 }
17728
17729 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
17730         LDKShutdown obj_conv;
17731         obj_conv.inner = (void*)(obj & (~1));
17732         obj_conv.is_owned = false;
17733         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
17734         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17735         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17736         CVec_u8Z_free(ret_var);
17737         return ret_arr;
17738 }
17739
17740 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
17741         LDKu8slice ser_ref;
17742         ser_ref.datalen = *((uint32_t*)ser);
17743         ser_ref.data = (int8_t*)(ser + 4);
17744         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17745         *ret_conv = Shutdown_read(ser_ref);
17746         return (uint64_t)ret_conv;
17747 }
17748
17749 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
17750         LDKUpdateFailHTLC obj_conv;
17751         obj_conv.inner = (void*)(obj & (~1));
17752         obj_conv.is_owned = false;
17753         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
17754         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17755         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17756         CVec_u8Z_free(ret_var);
17757         return ret_arr;
17758 }
17759
17760 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
17761         LDKu8slice ser_ref;
17762         ser_ref.datalen = *((uint32_t*)ser);
17763         ser_ref.data = (int8_t*)(ser + 4);
17764         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17765         *ret_conv = UpdateFailHTLC_read(ser_ref);
17766         return (uint64_t)ret_conv;
17767 }
17768
17769 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
17770         LDKUpdateFailMalformedHTLC obj_conv;
17771         obj_conv.inner = (void*)(obj & (~1));
17772         obj_conv.is_owned = false;
17773         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
17774         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17775         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17776         CVec_u8Z_free(ret_var);
17777         return ret_arr;
17778 }
17779
17780 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
17781         LDKu8slice ser_ref;
17782         ser_ref.datalen = *((uint32_t*)ser);
17783         ser_ref.data = (int8_t*)(ser + 4);
17784         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
17785         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
17786         return (uint64_t)ret_conv;
17787 }
17788
17789 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
17790         LDKUpdateFee obj_conv;
17791         obj_conv.inner = (void*)(obj & (~1));
17792         obj_conv.is_owned = false;
17793         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
17794         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17795         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17796         CVec_u8Z_free(ret_var);
17797         return ret_arr;
17798 }
17799
17800 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
17801         LDKu8slice ser_ref;
17802         ser_ref.datalen = *((uint32_t*)ser);
17803         ser_ref.data = (int8_t*)(ser + 4);
17804         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
17805         *ret_conv = UpdateFee_read(ser_ref);
17806         return (uint64_t)ret_conv;
17807 }
17808
17809 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
17810         LDKUpdateFulfillHTLC obj_conv;
17811         obj_conv.inner = (void*)(obj & (~1));
17812         obj_conv.is_owned = false;
17813         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
17814         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17815         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17816         CVec_u8Z_free(ret_var);
17817         return ret_arr;
17818 }
17819
17820 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
17821         LDKu8slice ser_ref;
17822         ser_ref.datalen = *((uint32_t*)ser);
17823         ser_ref.data = (int8_t*)(ser + 4);
17824         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
17825         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
17826         return (uint64_t)ret_conv;
17827 }
17828
17829 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
17830         LDKUpdateAddHTLC obj_conv;
17831         obj_conv.inner = (void*)(obj & (~1));
17832         obj_conv.is_owned = false;
17833         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
17834         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17835         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17836         CVec_u8Z_free(ret_var);
17837         return ret_arr;
17838 }
17839
17840 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
17841         LDKu8slice ser_ref;
17842         ser_ref.datalen = *((uint32_t*)ser);
17843         ser_ref.data = (int8_t*)(ser + 4);
17844         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
17845         *ret_conv = UpdateAddHTLC_read(ser_ref);
17846         return (uint64_t)ret_conv;
17847 }
17848
17849 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
17850         LDKPing obj_conv;
17851         obj_conv.inner = (void*)(obj & (~1));
17852         obj_conv.is_owned = false;
17853         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
17854         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17855         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17856         CVec_u8Z_free(ret_var);
17857         return ret_arr;
17858 }
17859
17860 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
17861         LDKu8slice ser_ref;
17862         ser_ref.datalen = *((uint32_t*)ser);
17863         ser_ref.data = (int8_t*)(ser + 4);
17864         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
17865         *ret_conv = Ping_read(ser_ref);
17866         return (uint64_t)ret_conv;
17867 }
17868
17869 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
17870         LDKPong obj_conv;
17871         obj_conv.inner = (void*)(obj & (~1));
17872         obj_conv.is_owned = false;
17873         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
17874         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17875         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17876         CVec_u8Z_free(ret_var);
17877         return ret_arr;
17878 }
17879
17880 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
17881         LDKu8slice ser_ref;
17882         ser_ref.datalen = *((uint32_t*)ser);
17883         ser_ref.data = (int8_t*)(ser + 4);
17884         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
17885         *ret_conv = Pong_read(ser_ref);
17886         return (uint64_t)ret_conv;
17887 }
17888
17889 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
17890         LDKUnsignedChannelAnnouncement obj_conv;
17891         obj_conv.inner = (void*)(obj & (~1));
17892         obj_conv.is_owned = false;
17893         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
17894         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17895         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17896         CVec_u8Z_free(ret_var);
17897         return ret_arr;
17898 }
17899
17900 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
17901         LDKu8slice ser_ref;
17902         ser_ref.datalen = *((uint32_t*)ser);
17903         ser_ref.data = (int8_t*)(ser + 4);
17904         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
17905         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
17906         return (uint64_t)ret_conv;
17907 }
17908
17909 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
17910         LDKChannelAnnouncement obj_conv;
17911         obj_conv.inner = (void*)(obj & (~1));
17912         obj_conv.is_owned = false;
17913         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
17914         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17915         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17916         CVec_u8Z_free(ret_var);
17917         return ret_arr;
17918 }
17919
17920 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
17921         LDKu8slice ser_ref;
17922         ser_ref.datalen = *((uint32_t*)ser);
17923         ser_ref.data = (int8_t*)(ser + 4);
17924         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
17925         *ret_conv = ChannelAnnouncement_read(ser_ref);
17926         return (uint64_t)ret_conv;
17927 }
17928
17929 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
17930         LDKUnsignedChannelUpdate obj_conv;
17931         obj_conv.inner = (void*)(obj & (~1));
17932         obj_conv.is_owned = false;
17933         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
17934         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17935         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17936         CVec_u8Z_free(ret_var);
17937         return ret_arr;
17938 }
17939
17940 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
17941         LDKu8slice ser_ref;
17942         ser_ref.datalen = *((uint32_t*)ser);
17943         ser_ref.data = (int8_t*)(ser + 4);
17944         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
17945         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
17946         return (uint64_t)ret_conv;
17947 }
17948
17949 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
17950         LDKChannelUpdate obj_conv;
17951         obj_conv.inner = (void*)(obj & (~1));
17952         obj_conv.is_owned = false;
17953         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
17954         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17955         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17956         CVec_u8Z_free(ret_var);
17957         return ret_arr;
17958 }
17959
17960 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
17961         LDKu8slice ser_ref;
17962         ser_ref.datalen = *((uint32_t*)ser);
17963         ser_ref.data = (int8_t*)(ser + 4);
17964         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
17965         *ret_conv = ChannelUpdate_read(ser_ref);
17966         return (uint64_t)ret_conv;
17967 }
17968
17969 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
17970         LDKErrorMessage obj_conv;
17971         obj_conv.inner = (void*)(obj & (~1));
17972         obj_conv.is_owned = false;
17973         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
17974         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17975         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17976         CVec_u8Z_free(ret_var);
17977         return ret_arr;
17978 }
17979
17980 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
17981         LDKu8slice ser_ref;
17982         ser_ref.datalen = *((uint32_t*)ser);
17983         ser_ref.data = (int8_t*)(ser + 4);
17984         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
17985         *ret_conv = ErrorMessage_read(ser_ref);
17986         return (uint64_t)ret_conv;
17987 }
17988
17989 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
17990         LDKUnsignedNodeAnnouncement obj_conv;
17991         obj_conv.inner = (void*)(obj & (~1));
17992         obj_conv.is_owned = false;
17993         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
17994         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17995         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17996         CVec_u8Z_free(ret_var);
17997         return ret_arr;
17998 }
17999
18000 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
18001         LDKu8slice ser_ref;
18002         ser_ref.datalen = *((uint32_t*)ser);
18003         ser_ref.data = (int8_t*)(ser + 4);
18004         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18005         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
18006         return (uint64_t)ret_conv;
18007 }
18008
18009 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
18010         LDKNodeAnnouncement obj_conv;
18011         obj_conv.inner = (void*)(obj & (~1));
18012         obj_conv.is_owned = false;
18013         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
18014         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18015         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18016         CVec_u8Z_free(ret_var);
18017         return ret_arr;
18018 }
18019
18020 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
18021         LDKu8slice ser_ref;
18022         ser_ref.datalen = *((uint32_t*)ser);
18023         ser_ref.data = (int8_t*)(ser + 4);
18024         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18025         *ret_conv = NodeAnnouncement_read(ser_ref);
18026         return (uint64_t)ret_conv;
18027 }
18028
18029 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
18030         LDKu8slice ser_ref;
18031         ser_ref.datalen = *((uint32_t*)ser);
18032         ser_ref.data = (int8_t*)(ser + 4);
18033         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18034         *ret_conv = QueryShortChannelIds_read(ser_ref);
18035         return (uint64_t)ret_conv;
18036 }
18037
18038 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
18039         LDKQueryShortChannelIds obj_conv;
18040         obj_conv.inner = (void*)(obj & (~1));
18041         obj_conv.is_owned = false;
18042         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
18043         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18044         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18045         CVec_u8Z_free(ret_var);
18046         return ret_arr;
18047 }
18048
18049 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
18050         LDKu8slice ser_ref;
18051         ser_ref.datalen = *((uint32_t*)ser);
18052         ser_ref.data = (int8_t*)(ser + 4);
18053         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18054         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
18055         return (uint64_t)ret_conv;
18056 }
18057
18058 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
18059         LDKReplyShortChannelIdsEnd obj_conv;
18060         obj_conv.inner = (void*)(obj & (~1));
18061         obj_conv.is_owned = false;
18062         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
18063         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18064         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18065         CVec_u8Z_free(ret_var);
18066         return ret_arr;
18067 }
18068
18069 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
18070         LDKQueryChannelRange this_arg_conv;
18071         this_arg_conv.inner = (void*)(this_arg & (~1));
18072         this_arg_conv.is_owned = false;
18073         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
18074         return ret_val;
18075 }
18076
18077 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
18078         LDKu8slice ser_ref;
18079         ser_ref.datalen = *((uint32_t*)ser);
18080         ser_ref.data = (int8_t*)(ser + 4);
18081         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18082         *ret_conv = QueryChannelRange_read(ser_ref);
18083         return (uint64_t)ret_conv;
18084 }
18085
18086 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
18087         LDKQueryChannelRange obj_conv;
18088         obj_conv.inner = (void*)(obj & (~1));
18089         obj_conv.is_owned = false;
18090         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
18091         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18092         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18093         CVec_u8Z_free(ret_var);
18094         return ret_arr;
18095 }
18096
18097 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
18098         LDKu8slice ser_ref;
18099         ser_ref.datalen = *((uint32_t*)ser);
18100         ser_ref.data = (int8_t*)(ser + 4);
18101         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18102         *ret_conv = ReplyChannelRange_read(ser_ref);
18103         return (uint64_t)ret_conv;
18104 }
18105
18106 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
18107         LDKReplyChannelRange obj_conv;
18108         obj_conv.inner = (void*)(obj & (~1));
18109         obj_conv.is_owned = false;
18110         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
18111         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18112         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18113         CVec_u8Z_free(ret_var);
18114         return ret_arr;
18115 }
18116
18117 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
18118         LDKu8slice ser_ref;
18119         ser_ref.datalen = *((uint32_t*)ser);
18120         ser_ref.data = (int8_t*)(ser + 4);
18121         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18122         *ret_conv = GossipTimestampFilter_read(ser_ref);
18123         return (uint64_t)ret_conv;
18124 }
18125
18126 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
18127         LDKGossipTimestampFilter obj_conv;
18128         obj_conv.inner = (void*)(obj & (~1));
18129         obj_conv.is_owned = false;
18130         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
18131         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18132         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18133         CVec_u8Z_free(ret_var);
18134         return ret_arr;
18135 }
18136
18137 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
18138         LDKIgnoringMessageHandler this_obj_conv;
18139         this_obj_conv.inner = (void*)(this_obj & (~1));
18140         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18141         IgnoringMessageHandler_free(this_obj_conv);
18142 }
18143
18144 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
18145         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
18146         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18147         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18148         uint64_t ret_ref = (uint64_t)ret_var.inner;
18149         if (ret_var.is_owned) {
18150                 ret_ref |= 1;
18151         }
18152         return ret_ref;
18153 }
18154
18155 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
18156         LDKIgnoringMessageHandler this_arg_conv;
18157         this_arg_conv.inner = (void*)(this_arg & (~1));
18158         this_arg_conv.is_owned = false;
18159         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18160         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
18161         return (uint64_t)ret;
18162 }
18163
18164 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
18165         LDKIgnoringMessageHandler this_arg_conv;
18166         this_arg_conv.inner = (void*)(this_arg & (~1));
18167         this_arg_conv.is_owned = false;
18168         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
18169         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
18170         return (uint64_t)ret;
18171 }
18172
18173 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
18174         LDKErroringMessageHandler this_obj_conv;
18175         this_obj_conv.inner = (void*)(this_obj & (~1));
18176         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18177         ErroringMessageHandler_free(this_obj_conv);
18178 }
18179
18180 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
18181         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
18182         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18183         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18184         uint64_t ret_ref = (uint64_t)ret_var.inner;
18185         if (ret_var.is_owned) {
18186                 ret_ref |= 1;
18187         }
18188         return ret_ref;
18189 }
18190
18191 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
18192         LDKErroringMessageHandler this_arg_conv;
18193         this_arg_conv.inner = (void*)(this_arg & (~1));
18194         this_arg_conv.is_owned = false;
18195         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18196         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
18197         return (uint64_t)ret;
18198 }
18199
18200 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
18201         LDKErroringMessageHandler this_arg_conv;
18202         this_arg_conv.inner = (void*)(this_arg & (~1));
18203         this_arg_conv.is_owned = false;
18204         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
18205         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
18206         return (uint64_t)ret;
18207 }
18208
18209 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
18210         LDKMessageHandler this_obj_conv;
18211         this_obj_conv.inner = (void*)(this_obj & (~1));
18212         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18213         MessageHandler_free(this_obj_conv);
18214 }
18215
18216 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
18217         LDKMessageHandler this_ptr_conv;
18218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18219         this_ptr_conv.is_owned = false;
18220         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
18221         return ret_ret;
18222 }
18223
18224 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
18225         LDKMessageHandler this_ptr_conv;
18226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18227         this_ptr_conv.is_owned = false;
18228         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
18229         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
18230 }
18231
18232 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
18233         LDKMessageHandler this_ptr_conv;
18234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18235         this_ptr_conv.is_owned = false;
18236         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
18237         return ret_ret;
18238 }
18239
18240 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
18241         LDKMessageHandler this_ptr_conv;
18242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18243         this_ptr_conv.is_owned = false;
18244         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
18245         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
18246 }
18247
18248 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
18249         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
18250         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
18251         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
18252         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18253         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18254         uint64_t ret_ref = (uint64_t)ret_var.inner;
18255         if (ret_var.is_owned) {
18256                 ret_ref |= 1;
18257         }
18258         return ret_ref;
18259 }
18260
18261 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
18262         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
18263         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
18264         *ret = SocketDescriptor_clone(orig_conv);
18265         return (uint64_t)ret;
18266 }
18267
18268 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
18269         if ((this_ptr & 1) != 0) return;
18270         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
18271         FREE((void*)this_ptr);
18272         SocketDescriptor_free(this_ptr_conv);
18273 }
18274
18275 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
18276         LDKPeerHandleError this_obj_conv;
18277         this_obj_conv.inner = (void*)(this_obj & (~1));
18278         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18279         PeerHandleError_free(this_obj_conv);
18280 }
18281
18282 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
18283         LDKPeerHandleError this_ptr_conv;
18284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18285         this_ptr_conv.is_owned = false;
18286         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
18287         return ret_val;
18288 }
18289
18290 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
18291         LDKPeerHandleError this_ptr_conv;
18292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18293         this_ptr_conv.is_owned = false;
18294         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
18295 }
18296
18297 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
18298         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
18299         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18300         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18301         uint64_t ret_ref = (uint64_t)ret_var.inner;
18302         if (ret_var.is_owned) {
18303                 ret_ref |= 1;
18304         }
18305         return ret_ref;
18306 }
18307
18308 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
18309         LDKPeerHandleError orig_conv;
18310         orig_conv.inner = (void*)(orig & (~1));
18311         orig_conv.is_owned = false;
18312         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
18313         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18314         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18315         uint64_t ret_ref = (uint64_t)ret_var.inner;
18316         if (ret_var.is_owned) {
18317                 ret_ref |= 1;
18318         }
18319         return ret_ref;
18320 }
18321
18322 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
18323         LDKPeerManager this_obj_conv;
18324         this_obj_conv.inner = (void*)(this_obj & (~1));
18325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18326         PeerManager_free(this_obj_conv);
18327 }
18328
18329 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) {
18330         LDKMessageHandler message_handler_conv;
18331         message_handler_conv.inner = (void*)(message_handler & (~1));
18332         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
18333         // Warning: we need a move here but no clone is available for LDKMessageHandler
18334         LDKSecretKey our_node_secret_ref;
18335         CHECK(*((uint32_t*)our_node_secret) == 32);
18336         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
18337         unsigned char ephemeral_random_data_arr[32];
18338         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
18339         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
18340         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
18341         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18342         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
18343         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18344         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18345         uint64_t ret_ref = (uint64_t)ret_var.inner;
18346         if (ret_var.is_owned) {
18347                 ret_ref |= 1;
18348         }
18349         return ret_ref;
18350 }
18351
18352 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
18353         LDKPeerManager this_arg_conv;
18354         this_arg_conv.inner = (void*)(this_arg & (~1));
18355         this_arg_conv.is_owned = false;
18356         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
18357         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
18358         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
18359         for (size_t m = 0; m < ret_var.datalen; m++) {
18360                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18361                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
18362                 ret_arr_ptr[m] = ret_conv_12_arr;
18363         }
18364         FREE(ret_var.data);
18365         return ret_arr;
18366 }
18367
18368 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
18369         LDKPeerManager this_arg_conv;
18370         this_arg_conv.inner = (void*)(this_arg & (~1));
18371         this_arg_conv.is_owned = false;
18372         LDKPublicKey their_node_id_ref;
18373         CHECK(*((uint32_t*)their_node_id) == 33);
18374         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
18375         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18376         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18377         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
18378         return (uint64_t)ret_conv;
18379 }
18380
18381 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
18382         LDKPeerManager this_arg_conv;
18383         this_arg_conv.inner = (void*)(this_arg & (~1));
18384         this_arg_conv.is_owned = false;
18385         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18386         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18387         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
18388         return (uint64_t)ret_conv;
18389 }
18390
18391 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
18392         LDKPeerManager this_arg_conv;
18393         this_arg_conv.inner = (void*)(this_arg & (~1));
18394         this_arg_conv.is_owned = false;
18395         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18396         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18397         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
18398         return (uint64_t)ret_conv;
18399 }
18400
18401 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
18402         LDKPeerManager this_arg_conv;
18403         this_arg_conv.inner = (void*)(this_arg & (~1));
18404         this_arg_conv.is_owned = false;
18405         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
18406         LDKu8slice data_ref;
18407         data_ref.datalen = *((uint32_t*)data);
18408         data_ref.data = (int8_t*)(data + 4);
18409         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18410         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
18411         return (uint64_t)ret_conv;
18412 }
18413
18414 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
18415         LDKPeerManager this_arg_conv;
18416         this_arg_conv.inner = (void*)(this_arg & (~1));
18417         this_arg_conv.is_owned = false;
18418         PeerManager_process_events(&this_arg_conv);
18419 }
18420
18421 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
18422         LDKPeerManager this_arg_conv;
18423         this_arg_conv.inner = (void*)(this_arg & (~1));
18424         this_arg_conv.is_owned = false;
18425         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18426         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
18427 }
18428
18429 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
18430         LDKPeerManager this_arg_conv;
18431         this_arg_conv.inner = (void*)(this_arg & (~1));
18432         this_arg_conv.is_owned = false;
18433         LDKPublicKey node_id_ref;
18434         CHECK(*((uint32_t*)node_id) == 33);
18435         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
18436         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
18437 }
18438
18439 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
18440         LDKPeerManager this_arg_conv;
18441         this_arg_conv.inner = (void*)(this_arg & (~1));
18442         this_arg_conv.is_owned = false;
18443         PeerManager_timer_tick_occurred(&this_arg_conv);
18444 }
18445
18446 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
18447         unsigned char commitment_seed_arr[32];
18448         CHECK(*((uint32_t*)commitment_seed) == 32);
18449         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
18450         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
18451         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18452         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
18453         return ret_arr;
18454 }
18455
18456 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
18457         LDKPublicKey per_commitment_point_ref;
18458         CHECK(*((uint32_t*)per_commitment_point) == 33);
18459         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18460         unsigned char base_secret_arr[32];
18461         CHECK(*((uint32_t*)base_secret) == 32);
18462         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
18463         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
18464         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
18465         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
18466         return (uint64_t)ret_conv;
18467 }
18468
18469 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
18470         LDKPublicKey per_commitment_point_ref;
18471         CHECK(*((uint32_t*)per_commitment_point) == 33);
18472         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18473         LDKPublicKey base_point_ref;
18474         CHECK(*((uint32_t*)base_point) == 33);
18475         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
18476         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
18477         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
18478         return (uint64_t)ret_conv;
18479 }
18480
18481 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
18482         unsigned char per_commitment_secret_arr[32];
18483         CHECK(*((uint32_t*)per_commitment_secret) == 32);
18484         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
18485         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
18486         unsigned char countersignatory_revocation_base_secret_arr[32];
18487         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
18488         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
18489         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
18490         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
18491         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
18492         return (uint64_t)ret_conv;
18493 }
18494
18495 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
18496         LDKPublicKey per_commitment_point_ref;
18497         CHECK(*((uint32_t*)per_commitment_point) == 33);
18498         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18499         LDKPublicKey countersignatory_revocation_base_point_ref;
18500         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
18501         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
18502         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
18503         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
18504         return (uint64_t)ret_conv;
18505 }
18506
18507 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
18508         LDKTxCreationKeys this_obj_conv;
18509         this_obj_conv.inner = (void*)(this_obj & (~1));
18510         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18511         TxCreationKeys_free(this_obj_conv);
18512 }
18513
18514 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
18515         LDKTxCreationKeys this_ptr_conv;
18516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18517         this_ptr_conv.is_owned = false;
18518         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18519         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
18520         return ret_arr;
18521 }
18522
18523 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
18524         LDKTxCreationKeys this_ptr_conv;
18525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18526         this_ptr_conv.is_owned = false;
18527         LDKPublicKey val_ref;
18528         CHECK(*((uint32_t*)val) == 33);
18529         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18530         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
18531 }
18532
18533 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
18534         LDKTxCreationKeys this_ptr_conv;
18535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18536         this_ptr_conv.is_owned = false;
18537         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18538         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
18539         return ret_arr;
18540 }
18541
18542 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
18543         LDKTxCreationKeys this_ptr_conv;
18544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18545         this_ptr_conv.is_owned = false;
18546         LDKPublicKey val_ref;
18547         CHECK(*((uint32_t*)val) == 33);
18548         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18549         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
18550 }
18551
18552 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
18553         LDKTxCreationKeys this_ptr_conv;
18554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18555         this_ptr_conv.is_owned = false;
18556         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18557         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
18558         return ret_arr;
18559 }
18560
18561 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
18562         LDKTxCreationKeys this_ptr_conv;
18563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18564         this_ptr_conv.is_owned = false;
18565         LDKPublicKey val_ref;
18566         CHECK(*((uint32_t*)val) == 33);
18567         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18568         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
18569 }
18570
18571 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
18572         LDKTxCreationKeys this_ptr_conv;
18573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18574         this_ptr_conv.is_owned = false;
18575         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18576         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
18577         return ret_arr;
18578 }
18579
18580 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
18581         LDKTxCreationKeys this_ptr_conv;
18582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18583         this_ptr_conv.is_owned = false;
18584         LDKPublicKey val_ref;
18585         CHECK(*((uint32_t*)val) == 33);
18586         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18587         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
18588 }
18589
18590 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
18591         LDKTxCreationKeys this_ptr_conv;
18592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18593         this_ptr_conv.is_owned = false;
18594         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18595         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
18596         return ret_arr;
18597 }
18598
18599 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
18600         LDKTxCreationKeys this_ptr_conv;
18601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18602         this_ptr_conv.is_owned = false;
18603         LDKPublicKey val_ref;
18604         CHECK(*((uint32_t*)val) == 33);
18605         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18606         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
18607 }
18608
18609 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) {
18610         LDKPublicKey per_commitment_point_arg_ref;
18611         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
18612         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
18613         LDKPublicKey revocation_key_arg_ref;
18614         CHECK(*((uint32_t*)revocation_key_arg) == 33);
18615         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
18616         LDKPublicKey broadcaster_htlc_key_arg_ref;
18617         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
18618         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
18619         LDKPublicKey countersignatory_htlc_key_arg_ref;
18620         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
18621         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
18622         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
18623         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
18624         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
18625         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);
18626         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18627         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18628         uint64_t ret_ref = (uint64_t)ret_var.inner;
18629         if (ret_var.is_owned) {
18630                 ret_ref |= 1;
18631         }
18632         return ret_ref;
18633 }
18634
18635 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
18636         LDKTxCreationKeys orig_conv;
18637         orig_conv.inner = (void*)(orig & (~1));
18638         orig_conv.is_owned = false;
18639         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
18640         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18641         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18642         uint64_t ret_ref = (uint64_t)ret_var.inner;
18643         if (ret_var.is_owned) {
18644                 ret_ref |= 1;
18645         }
18646         return ret_ref;
18647 }
18648
18649 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
18650         LDKTxCreationKeys obj_conv;
18651         obj_conv.inner = (void*)(obj & (~1));
18652         obj_conv.is_owned = false;
18653         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
18654         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18655         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18656         CVec_u8Z_free(ret_var);
18657         return ret_arr;
18658 }
18659
18660 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
18661         LDKu8slice ser_ref;
18662         ser_ref.datalen = *((uint32_t*)ser);
18663         ser_ref.data = (int8_t*)(ser + 4);
18664         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
18665         *ret_conv = TxCreationKeys_read(ser_ref);
18666         return (uint64_t)ret_conv;
18667 }
18668
18669 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
18670         LDKChannelPublicKeys this_obj_conv;
18671         this_obj_conv.inner = (void*)(this_obj & (~1));
18672         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18673         ChannelPublicKeys_free(this_obj_conv);
18674 }
18675
18676 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
18677         LDKChannelPublicKeys this_ptr_conv;
18678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18679         this_ptr_conv.is_owned = false;
18680         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18681         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
18682         return ret_arr;
18683 }
18684
18685 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
18686         LDKChannelPublicKeys this_ptr_conv;
18687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18688         this_ptr_conv.is_owned = false;
18689         LDKPublicKey val_ref;
18690         CHECK(*((uint32_t*)val) == 33);
18691         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18692         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
18693 }
18694
18695 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
18696         LDKChannelPublicKeys this_ptr_conv;
18697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18698         this_ptr_conv.is_owned = false;
18699         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18700         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
18701         return ret_arr;
18702 }
18703
18704 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
18705         LDKChannelPublicKeys this_ptr_conv;
18706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18707         this_ptr_conv.is_owned = false;
18708         LDKPublicKey val_ref;
18709         CHECK(*((uint32_t*)val) == 33);
18710         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18711         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
18712 }
18713
18714 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
18715         LDKChannelPublicKeys this_ptr_conv;
18716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18717         this_ptr_conv.is_owned = false;
18718         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18719         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
18720         return ret_arr;
18721 }
18722
18723 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
18724         LDKChannelPublicKeys this_ptr_conv;
18725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18726         this_ptr_conv.is_owned = false;
18727         LDKPublicKey val_ref;
18728         CHECK(*((uint32_t*)val) == 33);
18729         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18730         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
18731 }
18732
18733 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
18734         LDKChannelPublicKeys this_ptr_conv;
18735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18736         this_ptr_conv.is_owned = false;
18737         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18738         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
18739         return ret_arr;
18740 }
18741
18742 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
18743         LDKChannelPublicKeys this_ptr_conv;
18744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18745         this_ptr_conv.is_owned = false;
18746         LDKPublicKey val_ref;
18747         CHECK(*((uint32_t*)val) == 33);
18748         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18749         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
18750 }
18751
18752 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
18753         LDKChannelPublicKeys this_ptr_conv;
18754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18755         this_ptr_conv.is_owned = false;
18756         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18757         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
18758         return ret_arr;
18759 }
18760
18761 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
18762         LDKChannelPublicKeys this_ptr_conv;
18763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18764         this_ptr_conv.is_owned = false;
18765         LDKPublicKey val_ref;
18766         CHECK(*((uint32_t*)val) == 33);
18767         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18768         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
18769 }
18770
18771 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) {
18772         LDKPublicKey funding_pubkey_arg_ref;
18773         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
18774         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
18775         LDKPublicKey revocation_basepoint_arg_ref;
18776         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
18777         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
18778         LDKPublicKey payment_point_arg_ref;
18779         CHECK(*((uint32_t*)payment_point_arg) == 33);
18780         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
18781         LDKPublicKey delayed_payment_basepoint_arg_ref;
18782         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
18783         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
18784         LDKPublicKey htlc_basepoint_arg_ref;
18785         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
18786         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
18787         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);
18788         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18789         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18790         uint64_t ret_ref = (uint64_t)ret_var.inner;
18791         if (ret_var.is_owned) {
18792                 ret_ref |= 1;
18793         }
18794         return ret_ref;
18795 }
18796
18797 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
18798         LDKChannelPublicKeys orig_conv;
18799         orig_conv.inner = (void*)(orig & (~1));
18800         orig_conv.is_owned = false;
18801         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
18802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18804         uint64_t ret_ref = (uint64_t)ret_var.inner;
18805         if (ret_var.is_owned) {
18806                 ret_ref |= 1;
18807         }
18808         return ret_ref;
18809 }
18810
18811 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
18812         LDKChannelPublicKeys obj_conv;
18813         obj_conv.inner = (void*)(obj & (~1));
18814         obj_conv.is_owned = false;
18815         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
18816         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18817         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18818         CVec_u8Z_free(ret_var);
18819         return ret_arr;
18820 }
18821
18822 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
18823         LDKu8slice ser_ref;
18824         ser_ref.datalen = *((uint32_t*)ser);
18825         ser_ref.data = (int8_t*)(ser + 4);
18826         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
18827         *ret_conv = ChannelPublicKeys_read(ser_ref);
18828         return (uint64_t)ret_conv;
18829 }
18830
18831 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) {
18832         LDKPublicKey per_commitment_point_ref;
18833         CHECK(*((uint32_t*)per_commitment_point) == 33);
18834         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18835         LDKPublicKey broadcaster_delayed_payment_base_ref;
18836         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
18837         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
18838         LDKPublicKey broadcaster_htlc_base_ref;
18839         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
18840         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
18841         LDKPublicKey countersignatory_revocation_base_ref;
18842         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
18843         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
18844         LDKPublicKey countersignatory_htlc_base_ref;
18845         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
18846         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
18847         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
18848         *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);
18849         return (uint64_t)ret_conv;
18850 }
18851
18852 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
18853         LDKPublicKey per_commitment_point_ref;
18854         CHECK(*((uint32_t*)per_commitment_point) == 33);
18855         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18856         LDKChannelPublicKeys broadcaster_keys_conv;
18857         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
18858         broadcaster_keys_conv.is_owned = false;
18859         LDKChannelPublicKeys countersignatory_keys_conv;
18860         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
18861         countersignatory_keys_conv.is_owned = false;
18862         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
18863         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
18864         return (uint64_t)ret_conv;
18865 }
18866
18867 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
18868         LDKPublicKey revocation_key_ref;
18869         CHECK(*((uint32_t*)revocation_key) == 33);
18870         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
18871         LDKPublicKey broadcaster_delayed_payment_key_ref;
18872         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
18873         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
18874         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
18875         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18876         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18877         CVec_u8Z_free(ret_var);
18878         return ret_arr;
18879 }
18880
18881 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
18882         LDKHTLCOutputInCommitment this_obj_conv;
18883         this_obj_conv.inner = (void*)(this_obj & (~1));
18884         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18885         HTLCOutputInCommitment_free(this_obj_conv);
18886 }
18887
18888 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
18889         LDKHTLCOutputInCommitment this_ptr_conv;
18890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18891         this_ptr_conv.is_owned = false;
18892         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
18893         return ret_val;
18894 }
18895
18896 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
18897         LDKHTLCOutputInCommitment this_ptr_conv;
18898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18899         this_ptr_conv.is_owned = false;
18900         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
18901 }
18902
18903 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
18904         LDKHTLCOutputInCommitment this_ptr_conv;
18905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18906         this_ptr_conv.is_owned = false;
18907         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
18908         return ret_val;
18909 }
18910
18911 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
18912         LDKHTLCOutputInCommitment this_ptr_conv;
18913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18914         this_ptr_conv.is_owned = false;
18915         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
18916 }
18917
18918 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
18919         LDKHTLCOutputInCommitment this_ptr_conv;
18920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18921         this_ptr_conv.is_owned = false;
18922         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
18923         return ret_val;
18924 }
18925
18926 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
18927         LDKHTLCOutputInCommitment this_ptr_conv;
18928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18929         this_ptr_conv.is_owned = false;
18930         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
18931 }
18932
18933 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
18934         LDKHTLCOutputInCommitment this_ptr_conv;
18935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18936         this_ptr_conv.is_owned = false;
18937         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18938         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
18939         return ret_arr;
18940 }
18941
18942 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
18943         LDKHTLCOutputInCommitment this_ptr_conv;
18944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18945         this_ptr_conv.is_owned = false;
18946         LDKThirtyTwoBytes val_ref;
18947         CHECK(*((uint32_t*)val) == 32);
18948         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18949         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
18950 }
18951
18952 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
18953         LDKHTLCOutputInCommitment this_ptr_conv;
18954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18955         this_ptr_conv.is_owned = false;
18956         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
18957         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
18958         uint64_t ret_ref = (uint64_t)ret_copy;
18959         return ret_ref;
18960 }
18961
18962 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
18963         LDKHTLCOutputInCommitment this_ptr_conv;
18964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18965         this_ptr_conv.is_owned = false;
18966         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
18967         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
18968 }
18969
18970 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) {
18971         LDKThirtyTwoBytes payment_hash_arg_ref;
18972         CHECK(*((uint32_t*)payment_hash_arg) == 32);
18973         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
18974         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
18975         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
18976         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18977         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18978         uint64_t ret_ref = (uint64_t)ret_var.inner;
18979         if (ret_var.is_owned) {
18980                 ret_ref |= 1;
18981         }
18982         return ret_ref;
18983 }
18984
18985 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
18986         LDKHTLCOutputInCommitment orig_conv;
18987         orig_conv.inner = (void*)(orig & (~1));
18988         orig_conv.is_owned = false;
18989         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
18990         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18991         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18992         uint64_t ret_ref = (uint64_t)ret_var.inner;
18993         if (ret_var.is_owned) {
18994                 ret_ref |= 1;
18995         }
18996         return ret_ref;
18997 }
18998
18999 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
19000         LDKHTLCOutputInCommitment obj_conv;
19001         obj_conv.inner = (void*)(obj & (~1));
19002         obj_conv.is_owned = false;
19003         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
19004         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19005         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19006         CVec_u8Z_free(ret_var);
19007         return ret_arr;
19008 }
19009
19010 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
19011         LDKu8slice ser_ref;
19012         ser_ref.datalen = *((uint32_t*)ser);
19013         ser_ref.data = (int8_t*)(ser + 4);
19014         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
19015         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
19016         return (uint64_t)ret_conv;
19017 }
19018
19019 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
19020         LDKHTLCOutputInCommitment htlc_conv;
19021         htlc_conv.inner = (void*)(htlc & (~1));
19022         htlc_conv.is_owned = false;
19023         LDKTxCreationKeys keys_conv;
19024         keys_conv.inner = (void*)(keys & (~1));
19025         keys_conv.is_owned = false;
19026         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
19027         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19028         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19029         CVec_u8Z_free(ret_var);
19030         return ret_arr;
19031 }
19032
19033 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
19034         LDKPublicKey broadcaster_ref;
19035         CHECK(*((uint32_t*)broadcaster) == 33);
19036         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
19037         LDKPublicKey countersignatory_ref;
19038         CHECK(*((uint32_t*)countersignatory) == 33);
19039         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
19040         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
19041         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19042         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19043         CVec_u8Z_free(ret_var);
19044         return ret_arr;
19045 }
19046
19047 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) {
19048         unsigned char commitment_txid_arr[32];
19049         CHECK(*((uint32_t*)commitment_txid) == 32);
19050         memcpy(commitment_txid_arr, (uint8_t*)(commitment_txid + 4), 32);
19051         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
19052         LDKHTLCOutputInCommitment htlc_conv;
19053         htlc_conv.inner = (void*)(htlc & (~1));
19054         htlc_conv.is_owned = false;
19055         LDKPublicKey broadcaster_delayed_payment_key_ref;
19056         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
19057         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
19058         LDKPublicKey revocation_key_ref;
19059         CHECK(*((uint32_t*)revocation_key) == 33);
19060         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
19061         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
19062         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19063         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19064         Transaction_free(ret_var);
19065         return ret_arr;
19066 }
19067
19068 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
19069         LDKChannelTransactionParameters this_obj_conv;
19070         this_obj_conv.inner = (void*)(this_obj & (~1));
19071         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19072         ChannelTransactionParameters_free(this_obj_conv);
19073 }
19074
19075 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
19076         LDKChannelTransactionParameters this_ptr_conv;
19077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19078         this_ptr_conv.is_owned = false;
19079         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
19080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19082         uint64_t ret_ref = (uint64_t)ret_var.inner;
19083         if (ret_var.is_owned) {
19084                 ret_ref |= 1;
19085         }
19086         return ret_ref;
19087 }
19088
19089 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
19090         LDKChannelTransactionParameters this_ptr_conv;
19091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19092         this_ptr_conv.is_owned = false;
19093         LDKChannelPublicKeys val_conv;
19094         val_conv.inner = (void*)(val & (~1));
19095         val_conv.is_owned = (val & 1) || (val == 0);
19096         val_conv = ChannelPublicKeys_clone(&val_conv);
19097         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
19098 }
19099
19100 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
19101         LDKChannelTransactionParameters this_ptr_conv;
19102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19103         this_ptr_conv.is_owned = false;
19104         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
19105         return ret_val;
19106 }
19107
19108 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
19109         LDKChannelTransactionParameters this_ptr_conv;
19110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19111         this_ptr_conv.is_owned = false;
19112         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
19113 }
19114
19115 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
19116         LDKChannelTransactionParameters this_ptr_conv;
19117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19118         this_ptr_conv.is_owned = false;
19119         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
19120         return ret_val;
19121 }
19122
19123 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
19124         LDKChannelTransactionParameters this_ptr_conv;
19125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19126         this_ptr_conv.is_owned = false;
19127         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
19128 }
19129
19130 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
19131         LDKChannelTransactionParameters this_ptr_conv;
19132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19133         this_ptr_conv.is_owned = false;
19134         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
19135         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19136         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19137         uint64_t ret_ref = (uint64_t)ret_var.inner;
19138         if (ret_var.is_owned) {
19139                 ret_ref |= 1;
19140         }
19141         return ret_ref;
19142 }
19143
19144 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
19145         LDKChannelTransactionParameters this_ptr_conv;
19146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19147         this_ptr_conv.is_owned = false;
19148         LDKCounterpartyChannelTransactionParameters val_conv;
19149         val_conv.inner = (void*)(val & (~1));
19150         val_conv.is_owned = (val & 1) || (val == 0);
19151         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
19152         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
19153 }
19154
19155 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
19156         LDKChannelTransactionParameters this_ptr_conv;
19157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19158         this_ptr_conv.is_owned = false;
19159         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
19160         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19161         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19162         uint64_t ret_ref = (uint64_t)ret_var.inner;
19163         if (ret_var.is_owned) {
19164                 ret_ref |= 1;
19165         }
19166         return ret_ref;
19167 }
19168
19169 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
19170         LDKChannelTransactionParameters this_ptr_conv;
19171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19172         this_ptr_conv.is_owned = false;
19173         LDKOutPoint val_conv;
19174         val_conv.inner = (void*)(val & (~1));
19175         val_conv.is_owned = (val & 1) || (val == 0);
19176         val_conv = OutPoint_clone(&val_conv);
19177         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
19178 }
19179
19180 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) {
19181         LDKChannelPublicKeys holder_pubkeys_arg_conv;
19182         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
19183         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
19184         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
19185         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
19186         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
19187         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
19188         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
19189         LDKOutPoint funding_outpoint_arg_conv;
19190         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
19191         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
19192         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
19193         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);
19194         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19195         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19196         uint64_t ret_ref = (uint64_t)ret_var.inner;
19197         if (ret_var.is_owned) {
19198                 ret_ref |= 1;
19199         }
19200         return ret_ref;
19201 }
19202
19203 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
19204         LDKChannelTransactionParameters orig_conv;
19205         orig_conv.inner = (void*)(orig & (~1));
19206         orig_conv.is_owned = false;
19207         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
19208         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19209         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19210         uint64_t ret_ref = (uint64_t)ret_var.inner;
19211         if (ret_var.is_owned) {
19212                 ret_ref |= 1;
19213         }
19214         return ret_ref;
19215 }
19216
19217 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
19218         LDKCounterpartyChannelTransactionParameters this_obj_conv;
19219         this_obj_conv.inner = (void*)(this_obj & (~1));
19220         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19221         CounterpartyChannelTransactionParameters_free(this_obj_conv);
19222 }
19223
19224 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
19225         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19227         this_ptr_conv.is_owned = false;
19228         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
19229         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19230         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19231         uint64_t ret_ref = (uint64_t)ret_var.inner;
19232         if (ret_var.is_owned) {
19233                 ret_ref |= 1;
19234         }
19235         return ret_ref;
19236 }
19237
19238 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
19239         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19241         this_ptr_conv.is_owned = false;
19242         LDKChannelPublicKeys val_conv;
19243         val_conv.inner = (void*)(val & (~1));
19244         val_conv.is_owned = (val & 1) || (val == 0);
19245         val_conv = ChannelPublicKeys_clone(&val_conv);
19246         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
19247 }
19248
19249 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
19250         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19252         this_ptr_conv.is_owned = false;
19253         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
19254         return ret_val;
19255 }
19256
19257 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
19258         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19260         this_ptr_conv.is_owned = false;
19261         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
19262 }
19263
19264 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
19265         LDKChannelPublicKeys pubkeys_arg_conv;
19266         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
19267         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
19268         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
19269         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
19270         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19271         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19272         uint64_t ret_ref = (uint64_t)ret_var.inner;
19273         if (ret_var.is_owned) {
19274                 ret_ref |= 1;
19275         }
19276         return ret_ref;
19277 }
19278
19279 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
19280         LDKCounterpartyChannelTransactionParameters orig_conv;
19281         orig_conv.inner = (void*)(orig & (~1));
19282         orig_conv.is_owned = false;
19283         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
19284         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19285         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19286         uint64_t ret_ref = (uint64_t)ret_var.inner;
19287         if (ret_var.is_owned) {
19288                 ret_ref |= 1;
19289         }
19290         return ret_ref;
19291 }
19292
19293 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
19294         LDKChannelTransactionParameters this_arg_conv;
19295         this_arg_conv.inner = (void*)(this_arg & (~1));
19296         this_arg_conv.is_owned = false;
19297         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
19298         return ret_val;
19299 }
19300
19301 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
19302         LDKChannelTransactionParameters this_arg_conv;
19303         this_arg_conv.inner = (void*)(this_arg & (~1));
19304         this_arg_conv.is_owned = false;
19305         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
19306         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19307         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19308         uint64_t ret_ref = (uint64_t)ret_var.inner;
19309         if (ret_var.is_owned) {
19310                 ret_ref |= 1;
19311         }
19312         return ret_ref;
19313 }
19314
19315 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
19316         LDKChannelTransactionParameters this_arg_conv;
19317         this_arg_conv.inner = (void*)(this_arg & (~1));
19318         this_arg_conv.is_owned = false;
19319         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
19320         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19321         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19322         uint64_t ret_ref = (uint64_t)ret_var.inner;
19323         if (ret_var.is_owned) {
19324                 ret_ref |= 1;
19325         }
19326         return ret_ref;
19327 }
19328
19329 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
19330         LDKCounterpartyChannelTransactionParameters obj_conv;
19331         obj_conv.inner = (void*)(obj & (~1));
19332         obj_conv.is_owned = false;
19333         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
19334         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19335         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19336         CVec_u8Z_free(ret_var);
19337         return ret_arr;
19338 }
19339
19340 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
19341         LDKu8slice ser_ref;
19342         ser_ref.datalen = *((uint32_t*)ser);
19343         ser_ref.data = (int8_t*)(ser + 4);
19344         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
19345         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
19346         return (uint64_t)ret_conv;
19347 }
19348
19349 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
19350         LDKChannelTransactionParameters obj_conv;
19351         obj_conv.inner = (void*)(obj & (~1));
19352         obj_conv.is_owned = false;
19353         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
19354         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19355         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19356         CVec_u8Z_free(ret_var);
19357         return ret_arr;
19358 }
19359
19360 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
19361         LDKu8slice ser_ref;
19362         ser_ref.datalen = *((uint32_t*)ser);
19363         ser_ref.data = (int8_t*)(ser + 4);
19364         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
19365         *ret_conv = ChannelTransactionParameters_read(ser_ref);
19366         return (uint64_t)ret_conv;
19367 }
19368
19369 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
19370         LDKDirectedChannelTransactionParameters this_obj_conv;
19371         this_obj_conv.inner = (void*)(this_obj & (~1));
19372         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19373         DirectedChannelTransactionParameters_free(this_obj_conv);
19374 }
19375
19376 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
19377         LDKDirectedChannelTransactionParameters this_arg_conv;
19378         this_arg_conv.inner = (void*)(this_arg & (~1));
19379         this_arg_conv.is_owned = false;
19380         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
19381         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19382         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19383         uint64_t ret_ref = (uint64_t)ret_var.inner;
19384         if (ret_var.is_owned) {
19385                 ret_ref |= 1;
19386         }
19387         return ret_ref;
19388 }
19389
19390 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
19391         LDKDirectedChannelTransactionParameters this_arg_conv;
19392         this_arg_conv.inner = (void*)(this_arg & (~1));
19393         this_arg_conv.is_owned = false;
19394         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
19395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19397         uint64_t ret_ref = (uint64_t)ret_var.inner;
19398         if (ret_var.is_owned) {
19399                 ret_ref |= 1;
19400         }
19401         return ret_ref;
19402 }
19403
19404 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
19405         LDKDirectedChannelTransactionParameters this_arg_conv;
19406         this_arg_conv.inner = (void*)(this_arg & (~1));
19407         this_arg_conv.is_owned = false;
19408         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
19409         return ret_val;
19410 }
19411
19412 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
19413         LDKDirectedChannelTransactionParameters this_arg_conv;
19414         this_arg_conv.inner = (void*)(this_arg & (~1));
19415         this_arg_conv.is_owned = false;
19416         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
19417         return ret_val;
19418 }
19419
19420 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
19421         LDKDirectedChannelTransactionParameters this_arg_conv;
19422         this_arg_conv.inner = (void*)(this_arg & (~1));
19423         this_arg_conv.is_owned = false;
19424         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
19425         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19426         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19427         uint64_t ret_ref = (uint64_t)ret_var.inner;
19428         if (ret_var.is_owned) {
19429                 ret_ref |= 1;
19430         }
19431         return ret_ref;
19432 }
19433
19434 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
19435         LDKHolderCommitmentTransaction this_obj_conv;
19436         this_obj_conv.inner = (void*)(this_obj & (~1));
19437         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19438         HolderCommitmentTransaction_free(this_obj_conv);
19439 }
19440
19441 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
19442         LDKHolderCommitmentTransaction this_ptr_conv;
19443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19444         this_ptr_conv.is_owned = false;
19445         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19446         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
19447         return ret_arr;
19448 }
19449
19450 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
19451         LDKHolderCommitmentTransaction this_ptr_conv;
19452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19453         this_ptr_conv.is_owned = false;
19454         LDKSignature val_ref;
19455         CHECK(*((uint32_t*)val) == 64);
19456         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19457         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
19458 }
19459
19460 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
19461         LDKHolderCommitmentTransaction this_ptr_conv;
19462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19463         this_ptr_conv.is_owned = false;
19464         LDKCVec_SignatureZ val_constr;
19465         val_constr.datalen = *((uint32_t*)val);
19466         if (val_constr.datalen > 0)
19467                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19468         else
19469                 val_constr.data = NULL;
19470         int8_tArray* val_vals = (int8_tArray*)(val + 4);
19471         for (size_t m = 0; m < val_constr.datalen; m++) {
19472                 int8_tArray val_conv_12 = val_vals[m];
19473                 LDKSignature val_conv_12_ref;
19474                 CHECK(*((uint32_t*)val_conv_12) == 64);
19475                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
19476                 val_constr.data[m] = val_conv_12_ref;
19477         }
19478         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
19479 }
19480
19481 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
19482         LDKHolderCommitmentTransaction orig_conv;
19483         orig_conv.inner = (void*)(orig & (~1));
19484         orig_conv.is_owned = false;
19485         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
19486         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19487         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19488         uint64_t ret_ref = (uint64_t)ret_var.inner;
19489         if (ret_var.is_owned) {
19490                 ret_ref |= 1;
19491         }
19492         return ret_ref;
19493 }
19494
19495 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
19496         LDKHolderCommitmentTransaction obj_conv;
19497         obj_conv.inner = (void*)(obj & (~1));
19498         obj_conv.is_owned = false;
19499         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
19500         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19501         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19502         CVec_u8Z_free(ret_var);
19503         return ret_arr;
19504 }
19505
19506 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
19507         LDKu8slice ser_ref;
19508         ser_ref.datalen = *((uint32_t*)ser);
19509         ser_ref.data = (int8_t*)(ser + 4);
19510         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
19511         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
19512         return (uint64_t)ret_conv;
19513 }
19514
19515 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) {
19516         LDKCommitmentTransaction commitment_tx_conv;
19517         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
19518         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
19519         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
19520         LDKSignature counterparty_sig_ref;
19521         CHECK(*((uint32_t*)counterparty_sig) == 64);
19522         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
19523         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
19524         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
19525         if (counterparty_htlc_sigs_constr.datalen > 0)
19526                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19527         else
19528                 counterparty_htlc_sigs_constr.data = NULL;
19529         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
19530         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
19531                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
19532                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
19533                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
19534                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
19535                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
19536         }
19537         LDKPublicKey holder_funding_key_ref;
19538         CHECK(*((uint32_t*)holder_funding_key) == 33);
19539         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
19540         LDKPublicKey counterparty_funding_key_ref;
19541         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
19542         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
19543         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
19544         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19545         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19546         uint64_t ret_ref = (uint64_t)ret_var.inner;
19547         if (ret_var.is_owned) {
19548                 ret_ref |= 1;
19549         }
19550         return ret_ref;
19551 }
19552
19553 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
19554         LDKBuiltCommitmentTransaction this_obj_conv;
19555         this_obj_conv.inner = (void*)(this_obj & (~1));
19556         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19557         BuiltCommitmentTransaction_free(this_obj_conv);
19558 }
19559
19560 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
19561         LDKBuiltCommitmentTransaction this_ptr_conv;
19562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19563         this_ptr_conv.is_owned = false;
19564         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
19565         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19566         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19567         Transaction_free(ret_var);
19568         return ret_arr;
19569 }
19570
19571 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
19572         LDKBuiltCommitmentTransaction this_ptr_conv;
19573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19574         this_ptr_conv.is_owned = false;
19575         LDKTransaction val_ref;
19576         val_ref.datalen = *((uint32_t*)val);
19577         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
19578         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
19579         val_ref.data_is_owned = true;
19580         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
19581 }
19582
19583 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
19584         LDKBuiltCommitmentTransaction this_ptr_conv;
19585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19586         this_ptr_conv.is_owned = false;
19587         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19588         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
19589         return ret_arr;
19590 }
19591
19592 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
19593         LDKBuiltCommitmentTransaction this_ptr_conv;
19594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19595         this_ptr_conv.is_owned = false;
19596         LDKThirtyTwoBytes val_ref;
19597         CHECK(*((uint32_t*)val) == 32);
19598         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19599         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
19600 }
19601
19602 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
19603         LDKTransaction transaction_arg_ref;
19604         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
19605         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
19606         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
19607         transaction_arg_ref.data_is_owned = true;
19608         LDKThirtyTwoBytes txid_arg_ref;
19609         CHECK(*((uint32_t*)txid_arg) == 32);
19610         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
19611         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
19612         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19613         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19614         uint64_t ret_ref = (uint64_t)ret_var.inner;
19615         if (ret_var.is_owned) {
19616                 ret_ref |= 1;
19617         }
19618         return ret_ref;
19619 }
19620
19621 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
19622         LDKBuiltCommitmentTransaction orig_conv;
19623         orig_conv.inner = (void*)(orig & (~1));
19624         orig_conv.is_owned = false;
19625         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
19626         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19627         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19628         uint64_t ret_ref = (uint64_t)ret_var.inner;
19629         if (ret_var.is_owned) {
19630                 ret_ref |= 1;
19631         }
19632         return ret_ref;
19633 }
19634
19635 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
19636         LDKBuiltCommitmentTransaction obj_conv;
19637         obj_conv.inner = (void*)(obj & (~1));
19638         obj_conv.is_owned = false;
19639         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
19640         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19641         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19642         CVec_u8Z_free(ret_var);
19643         return ret_arr;
19644 }
19645
19646 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
19647         LDKu8slice ser_ref;
19648         ser_ref.datalen = *((uint32_t*)ser);
19649         ser_ref.data = (int8_t*)(ser + 4);
19650         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
19651         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
19652         return (uint64_t)ret_conv;
19653 }
19654
19655 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
19656         LDKBuiltCommitmentTransaction this_arg_conv;
19657         this_arg_conv.inner = (void*)(this_arg & (~1));
19658         this_arg_conv.is_owned = false;
19659         LDKu8slice funding_redeemscript_ref;
19660         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
19661         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
19662         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19663         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
19664         return ret_arr;
19665 }
19666
19667 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) {
19668         LDKBuiltCommitmentTransaction this_arg_conv;
19669         this_arg_conv.inner = (void*)(this_arg & (~1));
19670         this_arg_conv.is_owned = false;
19671         unsigned char funding_key_arr[32];
19672         CHECK(*((uint32_t*)funding_key) == 32);
19673         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
19674         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
19675         LDKu8slice funding_redeemscript_ref;
19676         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
19677         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
19678         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19679         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
19680         return ret_arr;
19681 }
19682
19683 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
19684         LDKCommitmentTransaction this_obj_conv;
19685         this_obj_conv.inner = (void*)(this_obj & (~1));
19686         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19687         CommitmentTransaction_free(this_obj_conv);
19688 }
19689
19690 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
19691         LDKCommitmentTransaction orig_conv;
19692         orig_conv.inner = (void*)(orig & (~1));
19693         orig_conv.is_owned = false;
19694         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
19695         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19696         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19697         uint64_t ret_ref = (uint64_t)ret_var.inner;
19698         if (ret_var.is_owned) {
19699                 ret_ref |= 1;
19700         }
19701         return ret_ref;
19702 }
19703
19704 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
19705         LDKCommitmentTransaction obj_conv;
19706         obj_conv.inner = (void*)(obj & (~1));
19707         obj_conv.is_owned = false;
19708         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
19709         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19710         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19711         CVec_u8Z_free(ret_var);
19712         return ret_arr;
19713 }
19714
19715 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
19716         LDKu8slice ser_ref;
19717         ser_ref.datalen = *((uint32_t*)ser);
19718         ser_ref.data = (int8_t*)(ser + 4);
19719         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
19720         *ret_conv = CommitmentTransaction_read(ser_ref);
19721         return (uint64_t)ret_conv;
19722 }
19723
19724 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
19725         LDKCommitmentTransaction this_arg_conv;
19726         this_arg_conv.inner = (void*)(this_arg & (~1));
19727         this_arg_conv.is_owned = false;
19728         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
19729         return ret_val;
19730 }
19731
19732 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
19733         LDKCommitmentTransaction this_arg_conv;
19734         this_arg_conv.inner = (void*)(this_arg & (~1));
19735         this_arg_conv.is_owned = false;
19736         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
19737         return ret_val;
19738 }
19739
19740 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
19741         LDKCommitmentTransaction this_arg_conv;
19742         this_arg_conv.inner = (void*)(this_arg & (~1));
19743         this_arg_conv.is_owned = false;
19744         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
19745         return ret_val;
19746 }
19747
19748 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
19749         LDKCommitmentTransaction this_arg_conv;
19750         this_arg_conv.inner = (void*)(this_arg & (~1));
19751         this_arg_conv.is_owned = false;
19752         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
19753         return ret_val;
19754 }
19755
19756 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
19757         LDKCommitmentTransaction this_arg_conv;
19758         this_arg_conv.inner = (void*)(this_arg & (~1));
19759         this_arg_conv.is_owned = false;
19760         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
19761         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19762         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19763         uint64_t ret_ref = (uint64_t)ret_var.inner;
19764         if (ret_var.is_owned) {
19765                 ret_ref |= 1;
19766         }
19767         return ret_ref;
19768 }
19769
19770 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
19771         LDKCommitmentTransaction this_arg_conv;
19772         this_arg_conv.inner = (void*)(this_arg & (~1));
19773         this_arg_conv.is_owned = false;
19774         LDKDirectedChannelTransactionParameters channel_parameters_conv;
19775         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
19776         channel_parameters_conv.is_owned = false;
19777         LDKChannelPublicKeys broadcaster_keys_conv;
19778         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
19779         broadcaster_keys_conv.is_owned = false;
19780         LDKChannelPublicKeys countersignatory_keys_conv;
19781         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
19782         countersignatory_keys_conv.is_owned = false;
19783         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
19784         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
19785         return (uint64_t)ret_conv;
19786 }
19787
19788 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
19789         LDKTrustedCommitmentTransaction this_obj_conv;
19790         this_obj_conv.inner = (void*)(this_obj & (~1));
19791         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19792         TrustedCommitmentTransaction_free(this_obj_conv);
19793 }
19794
19795 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
19796         LDKTrustedCommitmentTransaction this_arg_conv;
19797         this_arg_conv.inner = (void*)(this_arg & (~1));
19798         this_arg_conv.is_owned = false;
19799         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19800         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
19801         return ret_arr;
19802 }
19803
19804 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
19805         LDKTrustedCommitmentTransaction this_arg_conv;
19806         this_arg_conv.inner = (void*)(this_arg & (~1));
19807         this_arg_conv.is_owned = false;
19808         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
19809         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19810         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19811         uint64_t ret_ref = (uint64_t)ret_var.inner;
19812         if (ret_var.is_owned) {
19813                 ret_ref |= 1;
19814         }
19815         return ret_ref;
19816 }
19817
19818 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
19819         LDKTrustedCommitmentTransaction this_arg_conv;
19820         this_arg_conv.inner = (void*)(this_arg & (~1));
19821         this_arg_conv.is_owned = false;
19822         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
19823         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19824         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19825         uint64_t ret_ref = (uint64_t)ret_var.inner;
19826         if (ret_var.is_owned) {
19827                 ret_ref |= 1;
19828         }
19829         return ret_ref;
19830 }
19831
19832 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
19833         LDKTrustedCommitmentTransaction this_arg_conv;
19834         this_arg_conv.inner = (void*)(this_arg & (~1));
19835         this_arg_conv.is_owned = false;
19836         unsigned char htlc_base_key_arr[32];
19837         CHECK(*((uint32_t*)htlc_base_key) == 32);
19838         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
19839         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
19840         LDKDirectedChannelTransactionParameters channel_parameters_conv;
19841         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
19842         channel_parameters_conv.is_owned = false;
19843         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
19844         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
19845         return (uint64_t)ret_conv;
19846 }
19847
19848 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) {
19849         LDKPublicKey broadcaster_payment_basepoint_ref;
19850         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
19851         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
19852         LDKPublicKey countersignatory_payment_basepoint_ref;
19853         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
19854         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
19855         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
19856         return ret_val;
19857 }
19858
19859 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
19860         LDKInitFeatures a_conv;
19861         a_conv.inner = (void*)(a & (~1));
19862         a_conv.is_owned = false;
19863         LDKInitFeatures b_conv;
19864         b_conv.inner = (void*)(b & (~1));
19865         b_conv.is_owned = false;
19866         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
19867         return ret_val;
19868 }
19869
19870 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
19871         LDKNodeFeatures a_conv;
19872         a_conv.inner = (void*)(a & (~1));
19873         a_conv.is_owned = false;
19874         LDKNodeFeatures b_conv;
19875         b_conv.inner = (void*)(b & (~1));
19876         b_conv.is_owned = false;
19877         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
19878         return ret_val;
19879 }
19880
19881 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
19882         LDKChannelFeatures a_conv;
19883         a_conv.inner = (void*)(a & (~1));
19884         a_conv.is_owned = false;
19885         LDKChannelFeatures b_conv;
19886         b_conv.inner = (void*)(b & (~1));
19887         b_conv.is_owned = false;
19888         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
19889         return ret_val;
19890 }
19891
19892 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
19893         LDKInvoiceFeatures a_conv;
19894         a_conv.inner = (void*)(a & (~1));
19895         a_conv.is_owned = false;
19896         LDKInvoiceFeatures b_conv;
19897         b_conv.inner = (void*)(b & (~1));
19898         b_conv.is_owned = false;
19899         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
19900         return ret_val;
19901 }
19902
19903 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
19904         LDKInitFeatures orig_conv;
19905         orig_conv.inner = (void*)(orig & (~1));
19906         orig_conv.is_owned = false;
19907         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
19908         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19909         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19910         uint64_t ret_ref = (uint64_t)ret_var.inner;
19911         if (ret_var.is_owned) {
19912                 ret_ref |= 1;
19913         }
19914         return ret_ref;
19915 }
19916
19917 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
19918         LDKNodeFeatures orig_conv;
19919         orig_conv.inner = (void*)(orig & (~1));
19920         orig_conv.is_owned = false;
19921         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
19922         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19923         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19924         uint64_t ret_ref = (uint64_t)ret_var.inner;
19925         if (ret_var.is_owned) {
19926                 ret_ref |= 1;
19927         }
19928         return ret_ref;
19929 }
19930
19931 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
19932         LDKChannelFeatures orig_conv;
19933         orig_conv.inner = (void*)(orig & (~1));
19934         orig_conv.is_owned = false;
19935         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
19936         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19937         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19938         uint64_t ret_ref = (uint64_t)ret_var.inner;
19939         if (ret_var.is_owned) {
19940                 ret_ref |= 1;
19941         }
19942         return ret_ref;
19943 }
19944
19945 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
19946         LDKInvoiceFeatures orig_conv;
19947         orig_conv.inner = (void*)(orig & (~1));
19948         orig_conv.is_owned = false;
19949         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
19950         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19951         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19952         uint64_t ret_ref = (uint64_t)ret_var.inner;
19953         if (ret_var.is_owned) {
19954                 ret_ref |= 1;
19955         }
19956         return ret_ref;
19957 }
19958
19959 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
19960         LDKInitFeatures this_obj_conv;
19961         this_obj_conv.inner = (void*)(this_obj & (~1));
19962         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19963         InitFeatures_free(this_obj_conv);
19964 }
19965
19966 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
19967         LDKNodeFeatures this_obj_conv;
19968         this_obj_conv.inner = (void*)(this_obj & (~1));
19969         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19970         NodeFeatures_free(this_obj_conv);
19971 }
19972
19973 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
19974         LDKChannelFeatures this_obj_conv;
19975         this_obj_conv.inner = (void*)(this_obj & (~1));
19976         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19977         ChannelFeatures_free(this_obj_conv);
19978 }
19979
19980 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
19981         LDKInvoiceFeatures this_obj_conv;
19982         this_obj_conv.inner = (void*)(this_obj & (~1));
19983         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19984         InvoiceFeatures_free(this_obj_conv);
19985 }
19986
19987 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
19988         LDKInitFeatures ret_var = InitFeatures_empty();
19989         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19990         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19991         uint64_t ret_ref = (uint64_t)ret_var.inner;
19992         if (ret_var.is_owned) {
19993                 ret_ref |= 1;
19994         }
19995         return ret_ref;
19996 }
19997
19998 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
19999         LDKInitFeatures ret_var = InitFeatures_known();
20000         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20001         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20002         uint64_t ret_ref = (uint64_t)ret_var.inner;
20003         if (ret_var.is_owned) {
20004                 ret_ref |= 1;
20005         }
20006         return ret_ref;
20007 }
20008
20009 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
20010         LDKNodeFeatures ret_var = NodeFeatures_empty();
20011         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20012         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20013         uint64_t ret_ref = (uint64_t)ret_var.inner;
20014         if (ret_var.is_owned) {
20015                 ret_ref |= 1;
20016         }
20017         return ret_ref;
20018 }
20019
20020 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
20021         LDKNodeFeatures ret_var = NodeFeatures_known();
20022         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20023         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20024         uint64_t ret_ref = (uint64_t)ret_var.inner;
20025         if (ret_var.is_owned) {
20026                 ret_ref |= 1;
20027         }
20028         return ret_ref;
20029 }
20030
20031 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
20032         LDKChannelFeatures ret_var = ChannelFeatures_empty();
20033         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20034         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20035         uint64_t ret_ref = (uint64_t)ret_var.inner;
20036         if (ret_var.is_owned) {
20037                 ret_ref |= 1;
20038         }
20039         return ret_ref;
20040 }
20041
20042 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
20043         LDKChannelFeatures ret_var = ChannelFeatures_known();
20044         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20045         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20046         uint64_t ret_ref = (uint64_t)ret_var.inner;
20047         if (ret_var.is_owned) {
20048                 ret_ref |= 1;
20049         }
20050         return ret_ref;
20051 }
20052
20053 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
20054         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
20055         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20056         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20057         uint64_t ret_ref = (uint64_t)ret_var.inner;
20058         if (ret_var.is_owned) {
20059                 ret_ref |= 1;
20060         }
20061         return ret_ref;
20062 }
20063
20064 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
20065         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
20066         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20067         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20068         uint64_t ret_ref = (uint64_t)ret_var.inner;
20069         if (ret_var.is_owned) {
20070                 ret_ref |= 1;
20071         }
20072         return ret_ref;
20073 }
20074
20075 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
20076         LDKInitFeatures this_arg_conv;
20077         this_arg_conv.inner = (void*)(this_arg & (~1));
20078         this_arg_conv.is_owned = false;
20079         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
20080         return ret_val;
20081 }
20082
20083 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
20084         LDKNodeFeatures this_arg_conv;
20085         this_arg_conv.inner = (void*)(this_arg & (~1));
20086         this_arg_conv.is_owned = false;
20087         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
20088         return ret_val;
20089 }
20090
20091 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
20092         LDKInvoiceFeatures this_arg_conv;
20093         this_arg_conv.inner = (void*)(this_arg & (~1));
20094         this_arg_conv.is_owned = false;
20095         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
20096         return ret_val;
20097 }
20098
20099 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
20100         LDKInitFeatures obj_conv;
20101         obj_conv.inner = (void*)(obj & (~1));
20102         obj_conv.is_owned = false;
20103         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
20104         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20105         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20106         CVec_u8Z_free(ret_var);
20107         return ret_arr;
20108 }
20109
20110 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
20111         LDKNodeFeatures obj_conv;
20112         obj_conv.inner = (void*)(obj & (~1));
20113         obj_conv.is_owned = false;
20114         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
20115         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20116         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20117         CVec_u8Z_free(ret_var);
20118         return ret_arr;
20119 }
20120
20121 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
20122         LDKChannelFeatures obj_conv;
20123         obj_conv.inner = (void*)(obj & (~1));
20124         obj_conv.is_owned = false;
20125         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
20126         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20127         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20128         CVec_u8Z_free(ret_var);
20129         return ret_arr;
20130 }
20131
20132 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
20133         LDKInvoiceFeatures obj_conv;
20134         obj_conv.inner = (void*)(obj & (~1));
20135         obj_conv.is_owned = false;
20136         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
20137         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20138         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20139         CVec_u8Z_free(ret_var);
20140         return ret_arr;
20141 }
20142
20143 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
20144         LDKu8slice ser_ref;
20145         ser_ref.datalen = *((uint32_t*)ser);
20146         ser_ref.data = (int8_t*)(ser + 4);
20147         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
20148         *ret_conv = InitFeatures_read(ser_ref);
20149         return (uint64_t)ret_conv;
20150 }
20151
20152 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
20153         LDKu8slice ser_ref;
20154         ser_ref.datalen = *((uint32_t*)ser);
20155         ser_ref.data = (int8_t*)(ser + 4);
20156         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
20157         *ret_conv = NodeFeatures_read(ser_ref);
20158         return (uint64_t)ret_conv;
20159 }
20160
20161 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
20162         LDKu8slice ser_ref;
20163         ser_ref.datalen = *((uint32_t*)ser);
20164         ser_ref.data = (int8_t*)(ser + 4);
20165         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
20166         *ret_conv = ChannelFeatures_read(ser_ref);
20167         return (uint64_t)ret_conv;
20168 }
20169
20170 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
20171         LDKu8slice ser_ref;
20172         ser_ref.datalen = *((uint32_t*)ser);
20173         ser_ref.data = (int8_t*)(ser + 4);
20174         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
20175         *ret_conv = InvoiceFeatures_read(ser_ref);
20176         return (uint64_t)ret_conv;
20177 }
20178
20179 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
20180         LDKRouteHop this_obj_conv;
20181         this_obj_conv.inner = (void*)(this_obj & (~1));
20182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20183         RouteHop_free(this_obj_conv);
20184 }
20185
20186 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
20187         LDKRouteHop this_ptr_conv;
20188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20189         this_ptr_conv.is_owned = false;
20190         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20191         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
20192         return ret_arr;
20193 }
20194
20195 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
20196         LDKRouteHop this_ptr_conv;
20197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20198         this_ptr_conv.is_owned = false;
20199         LDKPublicKey val_ref;
20200         CHECK(*((uint32_t*)val) == 33);
20201         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20202         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
20203 }
20204
20205 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
20206         LDKRouteHop this_ptr_conv;
20207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20208         this_ptr_conv.is_owned = false;
20209         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
20210         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20211         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20212         uint64_t ret_ref = (uint64_t)ret_var.inner;
20213         if (ret_var.is_owned) {
20214                 ret_ref |= 1;
20215         }
20216         return ret_ref;
20217 }
20218
20219 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
20220         LDKRouteHop this_ptr_conv;
20221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20222         this_ptr_conv.is_owned = false;
20223         LDKNodeFeatures val_conv;
20224         val_conv.inner = (void*)(val & (~1));
20225         val_conv.is_owned = (val & 1) || (val == 0);
20226         val_conv = NodeFeatures_clone(&val_conv);
20227         RouteHop_set_node_features(&this_ptr_conv, val_conv);
20228 }
20229
20230 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
20231         LDKRouteHop this_ptr_conv;
20232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20233         this_ptr_conv.is_owned = false;
20234         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
20235         return ret_val;
20236 }
20237
20238 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
20239         LDKRouteHop this_ptr_conv;
20240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20241         this_ptr_conv.is_owned = false;
20242         RouteHop_set_short_channel_id(&this_ptr_conv, val);
20243 }
20244
20245 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
20246         LDKRouteHop this_ptr_conv;
20247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20248         this_ptr_conv.is_owned = false;
20249         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
20250         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20251         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20252         uint64_t ret_ref = (uint64_t)ret_var.inner;
20253         if (ret_var.is_owned) {
20254                 ret_ref |= 1;
20255         }
20256         return ret_ref;
20257 }
20258
20259 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
20260         LDKRouteHop this_ptr_conv;
20261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20262         this_ptr_conv.is_owned = false;
20263         LDKChannelFeatures val_conv;
20264         val_conv.inner = (void*)(val & (~1));
20265         val_conv.is_owned = (val & 1) || (val == 0);
20266         val_conv = ChannelFeatures_clone(&val_conv);
20267         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
20268 }
20269
20270 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
20271         LDKRouteHop this_ptr_conv;
20272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20273         this_ptr_conv.is_owned = false;
20274         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
20275         return ret_val;
20276 }
20277
20278 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
20279         LDKRouteHop this_ptr_conv;
20280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20281         this_ptr_conv.is_owned = false;
20282         RouteHop_set_fee_msat(&this_ptr_conv, val);
20283 }
20284
20285 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
20286         LDKRouteHop this_ptr_conv;
20287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20288         this_ptr_conv.is_owned = false;
20289         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
20290         return ret_val;
20291 }
20292
20293 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
20294         LDKRouteHop this_ptr_conv;
20295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20296         this_ptr_conv.is_owned = false;
20297         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
20298 }
20299
20300 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) {
20301         LDKPublicKey pubkey_arg_ref;
20302         CHECK(*((uint32_t*)pubkey_arg) == 33);
20303         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
20304         LDKNodeFeatures node_features_arg_conv;
20305         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
20306         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
20307         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
20308         LDKChannelFeatures channel_features_arg_conv;
20309         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
20310         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
20311         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
20312         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);
20313         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20314         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20315         uint64_t ret_ref = (uint64_t)ret_var.inner;
20316         if (ret_var.is_owned) {
20317                 ret_ref |= 1;
20318         }
20319         return ret_ref;
20320 }
20321
20322 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
20323         LDKRouteHop orig_conv;
20324         orig_conv.inner = (void*)(orig & (~1));
20325         orig_conv.is_owned = false;
20326         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
20327         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20328         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20329         uint64_t ret_ref = (uint64_t)ret_var.inner;
20330         if (ret_var.is_owned) {
20331                 ret_ref |= 1;
20332         }
20333         return ret_ref;
20334 }
20335
20336 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) {
20337         LDKRouteHop obj_conv;
20338         obj_conv.inner = (void*)(obj & (~1));
20339         obj_conv.is_owned = false;
20340         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
20341         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20342         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20343         CVec_u8Z_free(ret_var);
20344         return ret_arr;
20345 }
20346
20347 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_read(int8_tArray ser) {
20348         LDKu8slice ser_ref;
20349         ser_ref.datalen = *((uint32_t*)ser);
20350         ser_ref.data = (int8_t*)(ser + 4);
20351         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
20352         *ret_conv = RouteHop_read(ser_ref);
20353         return (uint64_t)ret_conv;
20354 }
20355
20356 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
20357         LDKRoute this_obj_conv;
20358         this_obj_conv.inner = (void*)(this_obj & (~1));
20359         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20360         Route_free(this_obj_conv);
20361 }
20362
20363 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
20364         LDKRoute this_ptr_conv;
20365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20366         this_ptr_conv.is_owned = false;
20367         LDKCVec_CVec_RouteHopZZ val_constr;
20368         val_constr.datalen = *((uint32_t*)val);
20369         if (val_constr.datalen > 0)
20370                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
20371         else
20372                 val_constr.data = NULL;
20373         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
20374         for (size_t m = 0; m < val_constr.datalen; m++) {
20375                 uint32_tArray val_conv_12 = val_vals[m];
20376                 LDKCVec_RouteHopZ val_conv_12_constr;
20377                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
20378                 if (val_conv_12_constr.datalen > 0)
20379                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20380                 else
20381                         val_conv_12_constr.data = NULL;
20382                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
20383                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
20384                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
20385                         LDKRouteHop val_conv_12_conv_10_conv;
20386                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
20387                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
20388                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
20389                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
20390                 }
20391                 val_constr.data[m] = val_conv_12_constr;
20392         }
20393         Route_set_paths(&this_ptr_conv, val_constr);
20394 }
20395
20396 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
20397         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
20398         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
20399         if (paths_arg_constr.datalen > 0)
20400                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
20401         else
20402                 paths_arg_constr.data = NULL;
20403         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
20404         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
20405                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
20406                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
20407                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
20408                 if (paths_arg_conv_12_constr.datalen > 0)
20409                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20410                 else
20411                         paths_arg_conv_12_constr.data = NULL;
20412                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
20413                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
20414                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
20415                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
20416                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
20417                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
20418                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
20419                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
20420                 }
20421                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
20422         }
20423         LDKRoute ret_var = Route_new(paths_arg_constr);
20424         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20425         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20426         uint64_t ret_ref = (uint64_t)ret_var.inner;
20427         if (ret_var.is_owned) {
20428                 ret_ref |= 1;
20429         }
20430         return ret_ref;
20431 }
20432
20433 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
20434         LDKRoute orig_conv;
20435         orig_conv.inner = (void*)(orig & (~1));
20436         orig_conv.is_owned = false;
20437         LDKRoute ret_var = Route_clone(&orig_conv);
20438         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20439         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20440         uint64_t ret_ref = (uint64_t)ret_var.inner;
20441         if (ret_var.is_owned) {
20442                 ret_ref |= 1;
20443         }
20444         return ret_ref;
20445 }
20446
20447 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
20448         LDKRoute obj_conv;
20449         obj_conv.inner = (void*)(obj & (~1));
20450         obj_conv.is_owned = false;
20451         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
20452         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20453         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20454         CVec_u8Z_free(ret_var);
20455         return ret_arr;
20456 }
20457
20458 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
20459         LDKu8slice ser_ref;
20460         ser_ref.datalen = *((uint32_t*)ser);
20461         ser_ref.data = (int8_t*)(ser + 4);
20462         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
20463         *ret_conv = Route_read(ser_ref);
20464         return (uint64_t)ret_conv;
20465 }
20466
20467 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
20468         LDKRouteHint this_obj_conv;
20469         this_obj_conv.inner = (void*)(this_obj & (~1));
20470         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20471         RouteHint_free(this_obj_conv);
20472 }
20473
20474 jboolean  __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
20475         LDKRouteHint a_conv;
20476         a_conv.inner = (void*)(a & (~1));
20477         a_conv.is_owned = false;
20478         LDKRouteHint b_conv;
20479         b_conv.inner = (void*)(b & (~1));
20480         b_conv.is_owned = false;
20481         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
20482         return ret_val;
20483 }
20484
20485 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
20486         LDKRouteHint orig_conv;
20487         orig_conv.inner = (void*)(orig & (~1));
20488         orig_conv.is_owned = false;
20489         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
20490         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20491         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20492         uint64_t ret_ref = (uint64_t)ret_var.inner;
20493         if (ret_var.is_owned) {
20494                 ret_ref |= 1;
20495         }
20496         return ret_ref;
20497 }
20498
20499 void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
20500         LDKRouteHintHop this_obj_conv;
20501         this_obj_conv.inner = (void*)(this_obj & (~1));
20502         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20503         RouteHintHop_free(this_obj_conv);
20504 }
20505
20506 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
20507         LDKRouteHintHop this_ptr_conv;
20508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20509         this_ptr_conv.is_owned = false;
20510         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20511         memcpy((uint8_t*)(ret_arr + 4), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
20512         return ret_arr;
20513 }
20514
20515 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
20516         LDKRouteHintHop this_ptr_conv;
20517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20518         this_ptr_conv.is_owned = false;
20519         LDKPublicKey val_ref;
20520         CHECK(*((uint32_t*)val) == 33);
20521         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20522         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
20523 }
20524
20525 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
20526         LDKRouteHintHop this_ptr_conv;
20527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20528         this_ptr_conv.is_owned = false;
20529         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
20530         return ret_val;
20531 }
20532
20533 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
20534         LDKRouteHintHop this_ptr_conv;
20535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20536         this_ptr_conv.is_owned = false;
20537         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
20538 }
20539
20540 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
20541         LDKRouteHintHop this_ptr_conv;
20542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20543         this_ptr_conv.is_owned = false;
20544         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
20545         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20546         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20547         uint64_t ret_ref = (uint64_t)ret_var.inner;
20548         if (ret_var.is_owned) {
20549                 ret_ref |= 1;
20550         }
20551         return ret_ref;
20552 }
20553
20554 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
20555         LDKRouteHintHop this_ptr_conv;
20556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20557         this_ptr_conv.is_owned = false;
20558         LDKRoutingFees val_conv;
20559         val_conv.inner = (void*)(val & (~1));
20560         val_conv.is_owned = (val & 1) || (val == 0);
20561         val_conv = RoutingFees_clone(&val_conv);
20562         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
20563 }
20564
20565 int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
20566         LDKRouteHintHop this_ptr_conv;
20567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20568         this_ptr_conv.is_owned = false;
20569         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
20570         return ret_val;
20571 }
20572
20573 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20574         LDKRouteHintHop this_ptr_conv;
20575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20576         this_ptr_conv.is_owned = false;
20577         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
20578 }
20579
20580 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
20581         LDKRouteHintHop this_ptr_conv;
20582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20583         this_ptr_conv.is_owned = false;
20584         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20585         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
20586         uint64_t ret_ref = (uint64_t)ret_copy;
20587         return ret_ref;
20588 }
20589
20590 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
20591         LDKRouteHintHop this_ptr_conv;
20592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20593         this_ptr_conv.is_owned = false;
20594         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20595         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
20596 }
20597
20598 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
20599         LDKRouteHintHop this_ptr_conv;
20600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20601         this_ptr_conv.is_owned = false;
20602         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20603         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
20604         uint64_t ret_ref = (uint64_t)ret_copy;
20605         return ret_ref;
20606 }
20607
20608 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
20609         LDKRouteHintHop this_ptr_conv;
20610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20611         this_ptr_conv.is_owned = false;
20612         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20613         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
20614 }
20615
20616 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) {
20617         LDKPublicKey src_node_id_arg_ref;
20618         CHECK(*((uint32_t*)src_node_id_arg) == 33);
20619         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
20620         LDKRoutingFees fees_arg_conv;
20621         fees_arg_conv.inner = (void*)(fees_arg & (~1));
20622         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
20623         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
20624         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
20625         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
20626         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);
20627         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20628         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20629         uint64_t ret_ref = (uint64_t)ret_var.inner;
20630         if (ret_var.is_owned) {
20631                 ret_ref |= 1;
20632         }
20633         return ret_ref;
20634 }
20635
20636 jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
20637         LDKRouteHintHop a_conv;
20638         a_conv.inner = (void*)(a & (~1));
20639         a_conv.is_owned = false;
20640         LDKRouteHintHop b_conv;
20641         b_conv.inner = (void*)(b & (~1));
20642         b_conv.is_owned = false;
20643         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
20644         return ret_val;
20645 }
20646
20647 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) {
20648         LDKRouteHintHop orig_conv;
20649         orig_conv.inner = (void*)(orig & (~1));
20650         orig_conv.is_owned = false;
20651         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
20652         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20653         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20654         uint64_t ret_ref = (uint64_t)ret_var.inner;
20655         if (ret_var.is_owned) {
20656                 ret_ref |= 1;
20657         }
20658         return ret_ref;
20659 }
20660
20661 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) {
20662         LDKPublicKey our_node_id_ref;
20663         CHECK(*((uint32_t*)our_node_id) == 33);
20664         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
20665         LDKNetworkGraph network_conv;
20666         network_conv.inner = (void*)(network & (~1));
20667         network_conv.is_owned = false;
20668         LDKPublicKey payee_ref;
20669         CHECK(*((uint32_t*)payee) == 33);
20670         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
20671         LDKInvoiceFeatures payee_features_conv;
20672         payee_features_conv.inner = (void*)(payee_features & (~1));
20673         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
20674         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
20675         LDKCVec_ChannelDetailsZ first_hops_constr;
20676         first_hops_constr.datalen = *((uint32_t*)first_hops);
20677         if (first_hops_constr.datalen > 0)
20678                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
20679         else
20680                 first_hops_constr.data = NULL;
20681         uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
20682         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
20683                 uint32_t first_hops_conv_16 = first_hops_vals[q];
20684                 LDKChannelDetails first_hops_conv_16_conv;
20685                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
20686                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
20687                 first_hops_constr.data[q] = first_hops_conv_16_conv;
20688         }
20689         LDKCVec_RouteHintZ last_hops_constr;
20690         last_hops_constr.datalen = *((uint32_t*)last_hops);
20691         if (last_hops_constr.datalen > 0)
20692                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
20693         else
20694                 last_hops_constr.data = NULL;
20695         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
20696         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
20697                 uint32_t last_hops_conv_11 = last_hops_vals[l];
20698                 LDKRouteHint last_hops_conv_11_conv;
20699                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
20700                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
20701                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
20702                 last_hops_constr.data[l] = last_hops_conv_11_conv;
20703         }
20704         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20705         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
20706         *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);
20707         FREE(first_hops_constr.data);
20708         return (uint64_t)ret_conv;
20709 }
20710
20711 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
20712         LDKNetworkGraph this_obj_conv;
20713         this_obj_conv.inner = (void*)(this_obj & (~1));
20714         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20715         NetworkGraph_free(this_obj_conv);
20716 }
20717
20718 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
20719         LDKNetworkGraph orig_conv;
20720         orig_conv.inner = (void*)(orig & (~1));
20721         orig_conv.is_owned = false;
20722         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
20723         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20724         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20725         uint64_t ret_ref = (uint64_t)ret_var.inner;
20726         if (ret_var.is_owned) {
20727                 ret_ref |= 1;
20728         }
20729         return ret_ref;
20730 }
20731
20732 void  __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_obj) {
20733         LDKLockedNetworkGraph this_obj_conv;
20734         this_obj_conv.inner = (void*)(this_obj & (~1));
20735         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20736         LockedNetworkGraph_free(this_obj_conv);
20737 }
20738
20739 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
20740         LDKNetGraphMsgHandler this_obj_conv;
20741         this_obj_conv.inner = (void*)(this_obj & (~1));
20742         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20743         NetGraphMsgHandler_free(this_obj_conv);
20744 }
20745
20746 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
20747         LDKThirtyTwoBytes genesis_hash_ref;
20748         CHECK(*((uint32_t*)genesis_hash) == 32);
20749         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
20750         LDKAccess *chain_access_conv_ptr = NULL;
20751         if (chain_access != 0) {
20752                 LDKAccess chain_access_conv;
20753                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20754                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20755                 *chain_access_conv_ptr = chain_access_conv;
20756         }
20757         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20758         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
20759         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20760         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20761         uint64_t ret_ref = (uint64_t)ret_var.inner;
20762         if (ret_var.is_owned) {
20763                 ret_ref |= 1;
20764         }
20765         return ret_ref;
20766 }
20767
20768 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
20769         LDKAccess *chain_access_conv_ptr = NULL;
20770         if (chain_access != 0) {
20771                 LDKAccess chain_access_conv;
20772                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20773                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20774                 *chain_access_conv_ptr = chain_access_conv;
20775         }
20776         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20777         LDKNetworkGraph network_graph_conv;
20778         network_graph_conv.inner = (void*)(network_graph & (~1));
20779         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
20780         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
20781         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
20782         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20783         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20784         uint64_t ret_ref = (uint64_t)ret_var.inner;
20785         if (ret_var.is_owned) {
20786                 ret_ref |= 1;
20787         }
20788         return ret_ref;
20789 }
20790
20791 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
20792         LDKNetGraphMsgHandler this_arg_conv;
20793         this_arg_conv.inner = (void*)(this_arg & (~1));
20794         this_arg_conv.is_owned = false;
20795         LDKAccess *chain_access_conv_ptr = NULL;
20796         if (chain_access != 0) {
20797                 LDKAccess chain_access_conv;
20798                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20799                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20800                 *chain_access_conv_ptr = chain_access_conv;
20801         }
20802         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
20803 }
20804
20805 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) {
20806         LDKNetGraphMsgHandler this_arg_conv;
20807         this_arg_conv.inner = (void*)(this_arg & (~1));
20808         this_arg_conv.is_owned = false;
20809         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
20810         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20811         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20812         uint64_t ret_ref = (uint64_t)ret_var.inner;
20813         if (ret_var.is_owned) {
20814                 ret_ref |= 1;
20815         }
20816         return ret_ref;
20817 }
20818
20819 uint32_t  __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) {
20820         LDKLockedNetworkGraph this_arg_conv;
20821         this_arg_conv.inner = (void*)(this_arg & (~1));
20822         this_arg_conv.is_owned = false;
20823         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
20824         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20825         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20826         uint64_t ret_ref = (uint64_t)ret_var.inner;
20827         if (ret_var.is_owned) {
20828                 ret_ref |= 1;
20829         }
20830         return ret_ref;
20831 }
20832
20833 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
20834         LDKNetGraphMsgHandler this_arg_conv;
20835         this_arg_conv.inner = (void*)(this_arg & (~1));
20836         this_arg_conv.is_owned = false;
20837         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
20838         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
20839         return (uint64_t)ret;
20840 }
20841
20842 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
20843         LDKNetGraphMsgHandler this_arg_conv;
20844         this_arg_conv.inner = (void*)(this_arg & (~1));
20845         this_arg_conv.is_owned = false;
20846         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20847         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
20848         return (uint64_t)ret;
20849 }
20850
20851 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
20852         LDKDirectionalChannelInfo this_obj_conv;
20853         this_obj_conv.inner = (void*)(this_obj & (~1));
20854         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20855         DirectionalChannelInfo_free(this_obj_conv);
20856 }
20857
20858 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
20859         LDKDirectionalChannelInfo this_ptr_conv;
20860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20861         this_ptr_conv.is_owned = false;
20862         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
20863         return ret_val;
20864 }
20865
20866 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
20867         LDKDirectionalChannelInfo this_ptr_conv;
20868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20869         this_ptr_conv.is_owned = false;
20870         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
20871 }
20872
20873 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
20874         LDKDirectionalChannelInfo this_ptr_conv;
20875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20876         this_ptr_conv.is_owned = false;
20877         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
20878         return ret_val;
20879 }
20880
20881 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
20882         LDKDirectionalChannelInfo this_ptr_conv;
20883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20884         this_ptr_conv.is_owned = false;
20885         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
20886 }
20887
20888 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
20889         LDKDirectionalChannelInfo this_ptr_conv;
20890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20891         this_ptr_conv.is_owned = false;
20892         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
20893         return ret_val;
20894 }
20895
20896 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20897         LDKDirectionalChannelInfo this_ptr_conv;
20898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20899         this_ptr_conv.is_owned = false;
20900         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
20901 }
20902
20903 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
20904         LDKDirectionalChannelInfo this_ptr_conv;
20905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20906         this_ptr_conv.is_owned = false;
20907         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
20908         return ret_val;
20909 }
20910
20911 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
20912         LDKDirectionalChannelInfo this_ptr_conv;
20913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20914         this_ptr_conv.is_owned = false;
20915         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
20916 }
20917
20918 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
20919         LDKDirectionalChannelInfo this_ptr_conv;
20920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20921         this_ptr_conv.is_owned = false;
20922         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20923         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
20924         uint64_t ret_ref = (uint64_t)ret_copy;
20925         return ret_ref;
20926 }
20927
20928 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
20929         LDKDirectionalChannelInfo this_ptr_conv;
20930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20931         this_ptr_conv.is_owned = false;
20932         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20933         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
20934 }
20935
20936 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
20937         LDKDirectionalChannelInfo this_ptr_conv;
20938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20939         this_ptr_conv.is_owned = false;
20940         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
20941         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20942         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20943         uint64_t ret_ref = (uint64_t)ret_var.inner;
20944         if (ret_var.is_owned) {
20945                 ret_ref |= 1;
20946         }
20947         return ret_ref;
20948 }
20949
20950 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
20951         LDKDirectionalChannelInfo this_ptr_conv;
20952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20953         this_ptr_conv.is_owned = false;
20954         LDKRoutingFees val_conv;
20955         val_conv.inner = (void*)(val & (~1));
20956         val_conv.is_owned = (val & 1) || (val == 0);
20957         val_conv = RoutingFees_clone(&val_conv);
20958         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
20959 }
20960
20961 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
20962         LDKDirectionalChannelInfo this_ptr_conv;
20963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20964         this_ptr_conv.is_owned = false;
20965         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
20966         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20967         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20968         uint64_t ret_ref = (uint64_t)ret_var.inner;
20969         if (ret_var.is_owned) {
20970                 ret_ref |= 1;
20971         }
20972         return ret_ref;
20973 }
20974
20975 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
20976         LDKDirectionalChannelInfo this_ptr_conv;
20977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20978         this_ptr_conv.is_owned = false;
20979         LDKChannelUpdate val_conv;
20980         val_conv.inner = (void*)(val & (~1));
20981         val_conv.is_owned = (val & 1) || (val == 0);
20982         val_conv = ChannelUpdate_clone(&val_conv);
20983         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
20984 }
20985
20986 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) {
20987         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
20988         LDKRoutingFees fees_arg_conv;
20989         fees_arg_conv.inner = (void*)(fees_arg & (~1));
20990         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
20991         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
20992         LDKChannelUpdate last_update_message_arg_conv;
20993         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
20994         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
20995         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
20996         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);
20997         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20998         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20999         uint64_t ret_ref = (uint64_t)ret_var.inner;
21000         if (ret_var.is_owned) {
21001                 ret_ref |= 1;
21002         }
21003         return ret_ref;
21004 }
21005
21006 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
21007         LDKDirectionalChannelInfo orig_conv;
21008         orig_conv.inner = (void*)(orig & (~1));
21009         orig_conv.is_owned = false;
21010         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_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 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
21021         LDKDirectionalChannelInfo obj_conv;
21022         obj_conv.inner = (void*)(obj & (~1));
21023         obj_conv.is_owned = false;
21024         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
21025         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21026         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21027         CVec_u8Z_free(ret_var);
21028         return ret_arr;
21029 }
21030
21031 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
21032         LDKu8slice ser_ref;
21033         ser_ref.datalen = *((uint32_t*)ser);
21034         ser_ref.data = (int8_t*)(ser + 4);
21035         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
21036         *ret_conv = DirectionalChannelInfo_read(ser_ref);
21037         return (uint64_t)ret_conv;
21038 }
21039
21040 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
21041         LDKChannelInfo this_obj_conv;
21042         this_obj_conv.inner = (void*)(this_obj & (~1));
21043         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21044         ChannelInfo_free(this_obj_conv);
21045 }
21046
21047 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
21048         LDKChannelInfo this_ptr_conv;
21049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21050         this_ptr_conv.is_owned = false;
21051         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
21052         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21053         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21054         uint64_t ret_ref = (uint64_t)ret_var.inner;
21055         if (ret_var.is_owned) {
21056                 ret_ref |= 1;
21057         }
21058         return ret_ref;
21059 }
21060
21061 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
21062         LDKChannelInfo this_ptr_conv;
21063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21064         this_ptr_conv.is_owned = false;
21065         LDKChannelFeatures val_conv;
21066         val_conv.inner = (void*)(val & (~1));
21067         val_conv.is_owned = (val & 1) || (val == 0);
21068         val_conv = ChannelFeatures_clone(&val_conv);
21069         ChannelInfo_set_features(&this_ptr_conv, val_conv);
21070 }
21071
21072 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
21073         LDKChannelInfo this_ptr_conv;
21074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21075         this_ptr_conv.is_owned = false;
21076         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21077         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
21078         return ret_arr;
21079 }
21080
21081 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
21082         LDKChannelInfo this_ptr_conv;
21083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21084         this_ptr_conv.is_owned = false;
21085         LDKPublicKey val_ref;
21086         CHECK(*((uint32_t*)val) == 33);
21087         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21088         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
21089 }
21090
21091 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
21092         LDKChannelInfo this_ptr_conv;
21093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21094         this_ptr_conv.is_owned = false;
21095         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
21096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21098         uint64_t ret_ref = (uint64_t)ret_var.inner;
21099         if (ret_var.is_owned) {
21100                 ret_ref |= 1;
21101         }
21102         return ret_ref;
21103 }
21104
21105 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
21106         LDKChannelInfo this_ptr_conv;
21107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21108         this_ptr_conv.is_owned = false;
21109         LDKDirectionalChannelInfo val_conv;
21110         val_conv.inner = (void*)(val & (~1));
21111         val_conv.is_owned = (val & 1) || (val == 0);
21112         val_conv = DirectionalChannelInfo_clone(&val_conv);
21113         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
21114 }
21115
21116 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
21117         LDKChannelInfo this_ptr_conv;
21118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21119         this_ptr_conv.is_owned = false;
21120         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21121         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
21122         return ret_arr;
21123 }
21124
21125 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
21126         LDKChannelInfo this_ptr_conv;
21127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21128         this_ptr_conv.is_owned = false;
21129         LDKPublicKey val_ref;
21130         CHECK(*((uint32_t*)val) == 33);
21131         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21132         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
21133 }
21134
21135 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
21136         LDKChannelInfo this_ptr_conv;
21137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21138         this_ptr_conv.is_owned = false;
21139         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
21140         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21141         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21142         uint64_t ret_ref = (uint64_t)ret_var.inner;
21143         if (ret_var.is_owned) {
21144                 ret_ref |= 1;
21145         }
21146         return ret_ref;
21147 }
21148
21149 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
21150         LDKChannelInfo this_ptr_conv;
21151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21152         this_ptr_conv.is_owned = false;
21153         LDKDirectionalChannelInfo val_conv;
21154         val_conv.inner = (void*)(val & (~1));
21155         val_conv.is_owned = (val & 1) || (val == 0);
21156         val_conv = DirectionalChannelInfo_clone(&val_conv);
21157         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
21158 }
21159
21160 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
21161         LDKChannelInfo this_ptr_conv;
21162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21163         this_ptr_conv.is_owned = false;
21164         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21165         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
21166         uint64_t ret_ref = (uint64_t)ret_copy;
21167         return ret_ref;
21168 }
21169
21170 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
21171         LDKChannelInfo this_ptr_conv;
21172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21173         this_ptr_conv.is_owned = false;
21174         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
21175         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
21176 }
21177
21178 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
21179         LDKChannelInfo this_ptr_conv;
21180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21181         this_ptr_conv.is_owned = false;
21182         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
21183         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21184         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21185         uint64_t ret_ref = (uint64_t)ret_var.inner;
21186         if (ret_var.is_owned) {
21187                 ret_ref |= 1;
21188         }
21189         return ret_ref;
21190 }
21191
21192 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
21193         LDKChannelInfo this_ptr_conv;
21194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21195         this_ptr_conv.is_owned = false;
21196         LDKChannelAnnouncement val_conv;
21197         val_conv.inner = (void*)(val & (~1));
21198         val_conv.is_owned = (val & 1) || (val == 0);
21199         val_conv = ChannelAnnouncement_clone(&val_conv);
21200         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
21201 }
21202
21203 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) {
21204         LDKChannelFeatures features_arg_conv;
21205         features_arg_conv.inner = (void*)(features_arg & (~1));
21206         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21207         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
21208         LDKPublicKey node_one_arg_ref;
21209         CHECK(*((uint32_t*)node_one_arg) == 33);
21210         memcpy(node_one_arg_ref.compressed_form, (uint8_t*)(node_one_arg + 4), 33);
21211         LDKDirectionalChannelInfo one_to_two_arg_conv;
21212         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
21213         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
21214         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
21215         LDKPublicKey node_two_arg_ref;
21216         CHECK(*((uint32_t*)node_two_arg) == 33);
21217         memcpy(node_two_arg_ref.compressed_form, (uint8_t*)(node_two_arg + 4), 33);
21218         LDKDirectionalChannelInfo two_to_one_arg_conv;
21219         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
21220         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
21221         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
21222         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
21223         LDKChannelAnnouncement announcement_message_arg_conv;
21224         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
21225         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
21226         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
21227         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);
21228         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21229         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21230         uint64_t ret_ref = (uint64_t)ret_var.inner;
21231         if (ret_var.is_owned) {
21232                 ret_ref |= 1;
21233         }
21234         return ret_ref;
21235 }
21236
21237 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
21238         LDKChannelInfo orig_conv;
21239         orig_conv.inner = (void*)(orig & (~1));
21240         orig_conv.is_owned = false;
21241         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
21242         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21243         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21244         uint64_t ret_ref = (uint64_t)ret_var.inner;
21245         if (ret_var.is_owned) {
21246                 ret_ref |= 1;
21247         }
21248         return ret_ref;
21249 }
21250
21251 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
21252         LDKChannelInfo obj_conv;
21253         obj_conv.inner = (void*)(obj & (~1));
21254         obj_conv.is_owned = false;
21255         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
21256         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21257         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21258         CVec_u8Z_free(ret_var);
21259         return ret_arr;
21260 }
21261
21262 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
21263         LDKu8slice ser_ref;
21264         ser_ref.datalen = *((uint32_t*)ser);
21265         ser_ref.data = (int8_t*)(ser + 4);
21266         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
21267         *ret_conv = ChannelInfo_read(ser_ref);
21268         return (uint64_t)ret_conv;
21269 }
21270
21271 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
21272         LDKRoutingFees this_obj_conv;
21273         this_obj_conv.inner = (void*)(this_obj & (~1));
21274         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21275         RoutingFees_free(this_obj_conv);
21276 }
21277
21278 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
21279         LDKRoutingFees this_ptr_conv;
21280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21281         this_ptr_conv.is_owned = false;
21282         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
21283         return ret_val;
21284 }
21285
21286 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
21287         LDKRoutingFees this_ptr_conv;
21288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21289         this_ptr_conv.is_owned = false;
21290         RoutingFees_set_base_msat(&this_ptr_conv, val);
21291 }
21292
21293 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
21294         LDKRoutingFees this_ptr_conv;
21295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21296         this_ptr_conv.is_owned = false;
21297         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
21298         return ret_val;
21299 }
21300
21301 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
21302         LDKRoutingFees this_ptr_conv;
21303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21304         this_ptr_conv.is_owned = false;
21305         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
21306 }
21307
21308 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
21309         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
21310         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21311         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21312         uint64_t ret_ref = (uint64_t)ret_var.inner;
21313         if (ret_var.is_owned) {
21314                 ret_ref |= 1;
21315         }
21316         return ret_ref;
21317 }
21318
21319 jboolean  __attribute__((visibility("default"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
21320         LDKRoutingFees a_conv;
21321         a_conv.inner = (void*)(a & (~1));
21322         a_conv.is_owned = false;
21323         LDKRoutingFees b_conv;
21324         b_conv.inner = (void*)(b & (~1));
21325         b_conv.is_owned = false;
21326         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
21327         return ret_val;
21328 }
21329
21330 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
21331         LDKRoutingFees orig_conv;
21332         orig_conv.inner = (void*)(orig & (~1));
21333         orig_conv.is_owned = false;
21334         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
21335         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21336         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21337         uint64_t ret_ref = (uint64_t)ret_var.inner;
21338         if (ret_var.is_owned) {
21339                 ret_ref |= 1;
21340         }
21341         return ret_ref;
21342 }
21343
21344 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
21345         LDKRoutingFees obj_conv;
21346         obj_conv.inner = (void*)(obj & (~1));
21347         obj_conv.is_owned = false;
21348         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
21349         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21350         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21351         CVec_u8Z_free(ret_var);
21352         return ret_arr;
21353 }
21354
21355 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
21356         LDKu8slice ser_ref;
21357         ser_ref.datalen = *((uint32_t*)ser);
21358         ser_ref.data = (int8_t*)(ser + 4);
21359         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
21360         *ret_conv = RoutingFees_read(ser_ref);
21361         return (uint64_t)ret_conv;
21362 }
21363
21364 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
21365         LDKNodeAnnouncementInfo this_obj_conv;
21366         this_obj_conv.inner = (void*)(this_obj & (~1));
21367         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21368         NodeAnnouncementInfo_free(this_obj_conv);
21369 }
21370
21371 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
21372         LDKNodeAnnouncementInfo this_ptr_conv;
21373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21374         this_ptr_conv.is_owned = false;
21375         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
21376         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21377         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21378         uint64_t ret_ref = (uint64_t)ret_var.inner;
21379         if (ret_var.is_owned) {
21380                 ret_ref |= 1;
21381         }
21382         return ret_ref;
21383 }
21384
21385 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
21386         LDKNodeAnnouncementInfo this_ptr_conv;
21387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21388         this_ptr_conv.is_owned = false;
21389         LDKNodeFeatures val_conv;
21390         val_conv.inner = (void*)(val & (~1));
21391         val_conv.is_owned = (val & 1) || (val == 0);
21392         val_conv = NodeFeatures_clone(&val_conv);
21393         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
21394 }
21395
21396 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
21397         LDKNodeAnnouncementInfo this_ptr_conv;
21398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21399         this_ptr_conv.is_owned = false;
21400         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
21401         return ret_val;
21402 }
21403
21404 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
21405         LDKNodeAnnouncementInfo this_ptr_conv;
21406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21407         this_ptr_conv.is_owned = false;
21408         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
21409 }
21410
21411 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
21412         LDKNodeAnnouncementInfo this_ptr_conv;
21413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21414         this_ptr_conv.is_owned = false;
21415         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
21416         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
21417         return ret_arr;
21418 }
21419
21420 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
21421         LDKNodeAnnouncementInfo this_ptr_conv;
21422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21423         this_ptr_conv.is_owned = false;
21424         LDKThreeBytes val_ref;
21425         CHECK(*((uint32_t*)val) == 3);
21426         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
21427         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
21428 }
21429
21430 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
21431         LDKNodeAnnouncementInfo this_ptr_conv;
21432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21433         this_ptr_conv.is_owned = false;
21434         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21435         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
21436         return ret_arr;
21437 }
21438
21439 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
21440         LDKNodeAnnouncementInfo this_ptr_conv;
21441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21442         this_ptr_conv.is_owned = false;
21443         LDKThirtyTwoBytes val_ref;
21444         CHECK(*((uint32_t*)val) == 32);
21445         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
21446         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
21447 }
21448
21449 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
21450         LDKNodeAnnouncementInfo this_ptr_conv;
21451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21452         this_ptr_conv.is_owned = false;
21453         LDKCVec_NetAddressZ val_constr;
21454         val_constr.datalen = *((uint32_t*)val);
21455         if (val_constr.datalen > 0)
21456                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21457         else
21458                 val_constr.data = NULL;
21459         uint32_t* val_vals = (uint32_t*)(val + 4);
21460         for (size_t m = 0; m < val_constr.datalen; m++) {
21461                 uint32_t val_conv_12 = val_vals[m];
21462                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
21463                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
21464                 val_constr.data[m] = val_conv_12_conv;
21465         }
21466         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
21467 }
21468
21469 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
21470         LDKNodeAnnouncementInfo this_ptr_conv;
21471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21472         this_ptr_conv.is_owned = false;
21473         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
21474         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21475         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21476         uint64_t ret_ref = (uint64_t)ret_var.inner;
21477         if (ret_var.is_owned) {
21478                 ret_ref |= 1;
21479         }
21480         return ret_ref;
21481 }
21482
21483 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
21484         LDKNodeAnnouncementInfo this_ptr_conv;
21485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21486         this_ptr_conv.is_owned = false;
21487         LDKNodeAnnouncement val_conv;
21488         val_conv.inner = (void*)(val & (~1));
21489         val_conv.is_owned = (val & 1) || (val == 0);
21490         val_conv = NodeAnnouncement_clone(&val_conv);
21491         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
21492 }
21493
21494 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) {
21495         LDKNodeFeatures features_arg_conv;
21496         features_arg_conv.inner = (void*)(features_arg & (~1));
21497         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21498         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
21499         LDKThreeBytes rgb_arg_ref;
21500         CHECK(*((uint32_t*)rgb_arg) == 3);
21501         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
21502         LDKThirtyTwoBytes alias_arg_ref;
21503         CHECK(*((uint32_t*)alias_arg) == 32);
21504         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
21505         LDKCVec_NetAddressZ addresses_arg_constr;
21506         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
21507         if (addresses_arg_constr.datalen > 0)
21508                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21509         else
21510                 addresses_arg_constr.data = NULL;
21511         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
21512         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
21513                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
21514                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
21515                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
21516         }
21517         LDKNodeAnnouncement announcement_message_arg_conv;
21518         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
21519         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
21520         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
21521         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
21522         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21523         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21524         uint64_t ret_ref = (uint64_t)ret_var.inner;
21525         if (ret_var.is_owned) {
21526                 ret_ref |= 1;
21527         }
21528         return ret_ref;
21529 }
21530
21531 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
21532         LDKNodeAnnouncementInfo orig_conv;
21533         orig_conv.inner = (void*)(orig & (~1));
21534         orig_conv.is_owned = false;
21535         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
21536         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21537         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21538         uint64_t ret_ref = (uint64_t)ret_var.inner;
21539         if (ret_var.is_owned) {
21540                 ret_ref |= 1;
21541         }
21542         return ret_ref;
21543 }
21544
21545 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
21546         LDKNodeAnnouncementInfo obj_conv;
21547         obj_conv.inner = (void*)(obj & (~1));
21548         obj_conv.is_owned = false;
21549         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
21550         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21551         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21552         CVec_u8Z_free(ret_var);
21553         return ret_arr;
21554 }
21555
21556 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
21557         LDKu8slice ser_ref;
21558         ser_ref.datalen = *((uint32_t*)ser);
21559         ser_ref.data = (int8_t*)(ser + 4);
21560         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
21561         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
21562         return (uint64_t)ret_conv;
21563 }
21564
21565 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
21566         LDKNodeInfo this_obj_conv;
21567         this_obj_conv.inner = (void*)(this_obj & (~1));
21568         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21569         NodeInfo_free(this_obj_conv);
21570 }
21571
21572 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
21573         LDKNodeInfo this_ptr_conv;
21574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21575         this_ptr_conv.is_owned = false;
21576         LDKCVec_u64Z val_constr;
21577         val_constr.datalen = *((uint32_t*)val);
21578         if (val_constr.datalen > 0)
21579                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21580         else
21581                 val_constr.data = NULL;
21582         int64_t* val_vals = (int64_t*)(val + 4);
21583         for (size_t i = 0; i < val_constr.datalen; i++) {
21584                 int64_t val_conv_8 = val_vals[i];
21585                 val_constr.data[i] = val_conv_8;
21586         }
21587         NodeInfo_set_channels(&this_ptr_conv, val_constr);
21588 }
21589
21590 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
21591         LDKNodeInfo this_ptr_conv;
21592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21593         this_ptr_conv.is_owned = false;
21594         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
21595         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21596         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21597         uint64_t ret_ref = (uint64_t)ret_var.inner;
21598         if (ret_var.is_owned) {
21599                 ret_ref |= 1;
21600         }
21601         return ret_ref;
21602 }
21603
21604 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
21605         LDKNodeInfo this_ptr_conv;
21606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21607         this_ptr_conv.is_owned = false;
21608         LDKRoutingFees val_conv;
21609         val_conv.inner = (void*)(val & (~1));
21610         val_conv.is_owned = (val & 1) || (val == 0);
21611         val_conv = RoutingFees_clone(&val_conv);
21612         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
21613 }
21614
21615 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
21616         LDKNodeInfo this_ptr_conv;
21617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21618         this_ptr_conv.is_owned = false;
21619         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
21620         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21621         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21622         uint64_t ret_ref = (uint64_t)ret_var.inner;
21623         if (ret_var.is_owned) {
21624                 ret_ref |= 1;
21625         }
21626         return ret_ref;
21627 }
21628
21629 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
21630         LDKNodeInfo this_ptr_conv;
21631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21632         this_ptr_conv.is_owned = false;
21633         LDKNodeAnnouncementInfo val_conv;
21634         val_conv.inner = (void*)(val & (~1));
21635         val_conv.is_owned = (val & 1) || (val == 0);
21636         val_conv = NodeAnnouncementInfo_clone(&val_conv);
21637         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
21638 }
21639
21640 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
21641         LDKCVec_u64Z channels_arg_constr;
21642         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
21643         if (channels_arg_constr.datalen > 0)
21644                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21645         else
21646                 channels_arg_constr.data = NULL;
21647         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
21648         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
21649                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
21650                 channels_arg_constr.data[i] = channels_arg_conv_8;
21651         }
21652         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
21653         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
21654         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
21655         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
21656         LDKNodeAnnouncementInfo announcement_info_arg_conv;
21657         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
21658         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
21659         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
21660         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
21661         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21662         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21663         uint64_t ret_ref = (uint64_t)ret_var.inner;
21664         if (ret_var.is_owned) {
21665                 ret_ref |= 1;
21666         }
21667         return ret_ref;
21668 }
21669
21670 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
21671         LDKNodeInfo orig_conv;
21672         orig_conv.inner = (void*)(orig & (~1));
21673         orig_conv.is_owned = false;
21674         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
21675         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21676         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21677         uint64_t ret_ref = (uint64_t)ret_var.inner;
21678         if (ret_var.is_owned) {
21679                 ret_ref |= 1;
21680         }
21681         return ret_ref;
21682 }
21683
21684 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
21685         LDKNodeInfo obj_conv;
21686         obj_conv.inner = (void*)(obj & (~1));
21687         obj_conv.is_owned = false;
21688         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
21689         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21690         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21691         CVec_u8Z_free(ret_var);
21692         return ret_arr;
21693 }
21694
21695 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
21696         LDKu8slice ser_ref;
21697         ser_ref.datalen = *((uint32_t*)ser);
21698         ser_ref.data = (int8_t*)(ser + 4);
21699         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
21700         *ret_conv = NodeInfo_read(ser_ref);
21701         return (uint64_t)ret_conv;
21702 }
21703
21704 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
21705         LDKNetworkGraph obj_conv;
21706         obj_conv.inner = (void*)(obj & (~1));
21707         obj_conv.is_owned = false;
21708         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
21709         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21710         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21711         CVec_u8Z_free(ret_var);
21712         return ret_arr;
21713 }
21714
21715 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
21716         LDKu8slice ser_ref;
21717         ser_ref.datalen = *((uint32_t*)ser);
21718         ser_ref.data = (int8_t*)(ser + 4);
21719         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
21720         *ret_conv = NetworkGraph_read(ser_ref);
21721         return (uint64_t)ret_conv;
21722 }
21723
21724 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
21725         LDKThirtyTwoBytes genesis_hash_ref;
21726         CHECK(*((uint32_t*)genesis_hash) == 32);
21727         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
21728         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
21729         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21730         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21731         uint64_t ret_ref = (uint64_t)ret_var.inner;
21732         if (ret_var.is_owned) {
21733                 ret_ref |= 1;
21734         }
21735         return ret_ref;
21736 }
21737
21738 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
21739         LDKNetworkGraph this_arg_conv;
21740         this_arg_conv.inner = (void*)(this_arg & (~1));
21741         this_arg_conv.is_owned = false;
21742         LDKNodeAnnouncement msg_conv;
21743         msg_conv.inner = (void*)(msg & (~1));
21744         msg_conv.is_owned = false;
21745         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21746         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
21747         return (uint64_t)ret_conv;
21748 }
21749
21750 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
21751         LDKNetworkGraph this_arg_conv;
21752         this_arg_conv.inner = (void*)(this_arg & (~1));
21753         this_arg_conv.is_owned = false;
21754         LDKUnsignedNodeAnnouncement msg_conv;
21755         msg_conv.inner = (void*)(msg & (~1));
21756         msg_conv.is_owned = false;
21757         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21758         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
21759         return (uint64_t)ret_conv;
21760 }
21761
21762 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
21763         LDKNetworkGraph this_arg_conv;
21764         this_arg_conv.inner = (void*)(this_arg & (~1));
21765         this_arg_conv.is_owned = false;
21766         LDKChannelAnnouncement msg_conv;
21767         msg_conv.inner = (void*)(msg & (~1));
21768         msg_conv.is_owned = false;
21769         LDKAccess *chain_access_conv_ptr = NULL;
21770         if (chain_access != 0) {
21771                 LDKAccess chain_access_conv;
21772                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21773                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21774                 *chain_access_conv_ptr = chain_access_conv;
21775         }
21776         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21777         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
21778         return (uint64_t)ret_conv;
21779 }
21780
21781 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
21782         LDKNetworkGraph this_arg_conv;
21783         this_arg_conv.inner = (void*)(this_arg & (~1));
21784         this_arg_conv.is_owned = false;
21785         LDKUnsignedChannelAnnouncement msg_conv;
21786         msg_conv.inner = (void*)(msg & (~1));
21787         msg_conv.is_owned = false;
21788         LDKAccess *chain_access_conv_ptr = NULL;
21789         if (chain_access != 0) {
21790                 LDKAccess chain_access_conv;
21791                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21792                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21793                 *chain_access_conv_ptr = chain_access_conv;
21794         }
21795         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21796         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
21797         return (uint64_t)ret_conv;
21798 }
21799
21800 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
21801         LDKNetworkGraph this_arg_conv;
21802         this_arg_conv.inner = (void*)(this_arg & (~1));
21803         this_arg_conv.is_owned = false;
21804         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
21805 }
21806
21807 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
21808         LDKNetworkGraph this_arg_conv;
21809         this_arg_conv.inner = (void*)(this_arg & (~1));
21810         this_arg_conv.is_owned = false;
21811         LDKChannelUpdate msg_conv;
21812         msg_conv.inner = (void*)(msg & (~1));
21813         msg_conv.is_owned = false;
21814         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21815         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
21816         return (uint64_t)ret_conv;
21817 }
21818
21819 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
21820         LDKNetworkGraph this_arg_conv;
21821         this_arg_conv.inner = (void*)(this_arg & (~1));
21822         this_arg_conv.is_owned = false;
21823         LDKUnsignedChannelUpdate msg_conv;
21824         msg_conv.inner = (void*)(msg & (~1));
21825         msg_conv.is_owned = false;
21826         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21827         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
21828         return (uint64_t)ret_conv;
21829 }
21830
21831 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
21832         LDKFilesystemPersister this_obj_conv;
21833         this_obj_conv.inner = (void*)(this_obj & (~1));
21834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21835         FilesystemPersister_free(this_obj_conv);
21836 }
21837
21838 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
21839         LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
21840         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
21841         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21842         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21843         uint64_t ret_ref = (uint64_t)ret_var.inner;
21844         if (ret_var.is_owned) {
21845                 ret_ref |= 1;
21846         }
21847         return ret_ref;
21848 }
21849
21850 jstring  __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_dir(uint32_t this_arg) {
21851         LDKFilesystemPersister this_arg_conv;
21852         this_arg_conv.inner = (void*)(this_arg & (~1));
21853         this_arg_conv.is_owned = false;
21854         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
21855         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21856         return ret_conv;
21857 }
21858
21859 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_persist_manager(jstring data_dir, uint32_t manager) {
21860         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
21861         LDKChannelManager manager_conv;
21862         manager_conv.inner = (void*)(manager & (~1));
21863         manager_conv.is_owned = false;
21864         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
21865         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
21866         return (uint64_t)ret_conv;
21867 }
21868
21869 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_channelmonitors(uint32_t this_arg, uint32_t keys_manager) {
21870         LDKFilesystemPersister this_arg_conv;
21871         this_arg_conv.inner = (void*)(this_arg & (~1));
21872         this_arg_conv.is_owned = false;
21873         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
21874         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21875         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
21876         return (uint64_t)ret_conv;
21877 }
21878
21879 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persist(uint32_t this_arg) {
21880         LDKFilesystemPersister this_arg_conv;
21881         this_arg_conv.inner = (void*)(this_arg & (~1));
21882         this_arg_conv.is_owned = false;
21883         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
21884         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
21885         return (uint64_t)ret;
21886 }
21887
21888 void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) {
21889         LDKBackgroundProcessor this_obj_conv;
21890         this_obj_conv.inner = (void*)(this_obj & (~1));
21891         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21892         BackgroundProcessor_free(this_obj_conv);
21893 }
21894
21895 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
21896         if ((this_ptr & 1) != 0) return;
21897         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
21898         FREE((void*)this_ptr);
21899         ChannelManagerPersister_free(this_ptr_conv);
21900 }
21901
21902 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) {
21903         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
21904         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
21905         LDKChainMonitor chain_monitor_conv;
21906         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
21907         chain_monitor_conv.is_owned = false;
21908         LDKChannelManager channel_manager_conv;
21909         channel_manager_conv.inner = (void*)(channel_manager & (~1));
21910         channel_manager_conv.is_owned = false;
21911         LDKPeerManager peer_manager_conv;
21912         peer_manager_conv.inner = (void*)(peer_manager & (~1));
21913         peer_manager_conv.is_owned = false;
21914         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
21915         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
21916         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21917         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21918         uint64_t ret_ref = (uint64_t)ret_var.inner;
21919         if (ret_var.is_owned) {
21920                 ret_ref |= 1;
21921         }
21922         return ret_ref;
21923 }
21924
21925 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_stop(uint32_t this_arg) {
21926         LDKBackgroundProcessor this_arg_conv;
21927         this_arg_conv.inner = (void*)(this_arg & (~1));
21928         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
21929         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
21930         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
21931         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
21932         return (uint64_t)ret_conv;
21933 }
21934
21935 void  __attribute__((visibility("default"))) TS_check_platform() {
21936         check_platform();
21937 }
21938
21939 void  __attribute__((visibility("default"))) TS_Invoice_free(uint32_t this_obj) {
21940         LDKInvoice this_obj_conv;
21941         this_obj_conv.inner = (void*)(this_obj & (~1));
21942         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21943         Invoice_free(this_obj_conv);
21944 }
21945
21946 jboolean  __attribute__((visibility("default"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
21947         LDKInvoice a_conv;
21948         a_conv.inner = (void*)(a & (~1));
21949         a_conv.is_owned = false;
21950         LDKInvoice b_conv;
21951         b_conv.inner = (void*)(b & (~1));
21952         b_conv.is_owned = false;
21953         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
21954         return ret_val;
21955 }
21956
21957 uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig) {
21958         LDKInvoice orig_conv;
21959         orig_conv.inner = (void*)(orig & (~1));
21960         orig_conv.is_owned = false;
21961         LDKInvoice ret_var = Invoice_clone(&orig_conv);
21962         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21963         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21964         uint64_t ret_ref = (uint64_t)ret_var.inner;
21965         if (ret_var.is_owned) {
21966                 ret_ref |= 1;
21967         }
21968         return ret_ref;
21969 }
21970
21971 void  __attribute__((visibility("default"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
21972         LDKSignedRawInvoice this_obj_conv;
21973         this_obj_conv.inner = (void*)(this_obj & (~1));
21974         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21975         SignedRawInvoice_free(this_obj_conv);
21976 }
21977
21978 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
21979         LDKSignedRawInvoice a_conv;
21980         a_conv.inner = (void*)(a & (~1));
21981         a_conv.is_owned = false;
21982         LDKSignedRawInvoice b_conv;
21983         b_conv.inner = (void*)(b & (~1));
21984         b_conv.is_owned = false;
21985         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
21986         return ret_val;
21987 }
21988
21989 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint32_t orig) {
21990         LDKSignedRawInvoice orig_conv;
21991         orig_conv.inner = (void*)(orig & (~1));
21992         orig_conv.is_owned = false;
21993         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
21994         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21995         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21996         uint64_t ret_ref = (uint64_t)ret_var.inner;
21997         if (ret_var.is_owned) {
21998                 ret_ref |= 1;
21999         }
22000         return ret_ref;
22001 }
22002
22003 void  __attribute__((visibility("default"))) TS_RawInvoice_free(uint32_t this_obj) {
22004         LDKRawInvoice this_obj_conv;
22005         this_obj_conv.inner = (void*)(this_obj & (~1));
22006         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22007         RawInvoice_free(this_obj_conv);
22008 }
22009
22010 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
22011         LDKRawInvoice this_ptr_conv;
22012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22013         this_ptr_conv.is_owned = false;
22014         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
22015         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22016         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22017         uint64_t ret_ref = (uint64_t)ret_var.inner;
22018         if (ret_var.is_owned) {
22019                 ret_ref |= 1;
22020         }
22021         return ret_ref;
22022 }
22023
22024 void  __attribute__((visibility("default"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
22025         LDKRawInvoice this_ptr_conv;
22026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22027         this_ptr_conv.is_owned = false;
22028         LDKRawDataPart val_conv;
22029         val_conv.inner = (void*)(val & (~1));
22030         val_conv.is_owned = (val & 1) || (val == 0);
22031         val_conv = RawDataPart_clone(&val_conv);
22032         RawInvoice_set_data(&this_ptr_conv, val_conv);
22033 }
22034
22035 jboolean  __attribute__((visibility("default"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
22036         LDKRawInvoice a_conv;
22037         a_conv.inner = (void*)(a & (~1));
22038         a_conv.is_owned = false;
22039         LDKRawInvoice b_conv;
22040         b_conv.inner = (void*)(b & (~1));
22041         b_conv.is_owned = false;
22042         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
22043         return ret_val;
22044 }
22045
22046 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t orig) {
22047         LDKRawInvoice orig_conv;
22048         orig_conv.inner = (void*)(orig & (~1));
22049         orig_conv.is_owned = false;
22050         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
22051         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22052         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22053         uint64_t ret_ref = (uint64_t)ret_var.inner;
22054         if (ret_var.is_owned) {
22055                 ret_ref |= 1;
22056         }
22057         return ret_ref;
22058 }
22059
22060 void  __attribute__((visibility("default"))) TS_RawDataPart_free(uint32_t this_obj) {
22061         LDKRawDataPart this_obj_conv;
22062         this_obj_conv.inner = (void*)(this_obj & (~1));
22063         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22064         RawDataPart_free(this_obj_conv);
22065 }
22066
22067 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
22068         LDKRawDataPart this_ptr_conv;
22069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22070         this_ptr_conv.is_owned = false;
22071         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
22072         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22073         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22074         uint64_t ret_ref = (uint64_t)ret_var.inner;
22075         if (ret_var.is_owned) {
22076                 ret_ref |= 1;
22077         }
22078         return ret_ref;
22079 }
22080
22081 void  __attribute__((visibility("default"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
22082         LDKRawDataPart this_ptr_conv;
22083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22084         this_ptr_conv.is_owned = false;
22085         LDKPositiveTimestamp val_conv;
22086         val_conv.inner = (void*)(val & (~1));
22087         val_conv.is_owned = (val & 1) || (val == 0);
22088         val_conv = PositiveTimestamp_clone(&val_conv);
22089         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
22090 }
22091
22092 jboolean  __attribute__((visibility("default"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
22093         LDKRawDataPart a_conv;
22094         a_conv.inner = (void*)(a & (~1));
22095         a_conv.is_owned = false;
22096         LDKRawDataPart b_conv;
22097         b_conv.inner = (void*)(b & (~1));
22098         b_conv.is_owned = false;
22099         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
22100         return ret_val;
22101 }
22102
22103 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t orig) {
22104         LDKRawDataPart orig_conv;
22105         orig_conv.inner = (void*)(orig & (~1));
22106         orig_conv.is_owned = false;
22107         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
22108         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22109         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22110         uint64_t ret_ref = (uint64_t)ret_var.inner;
22111         if (ret_var.is_owned) {
22112                 ret_ref |= 1;
22113         }
22114         return ret_ref;
22115 }
22116
22117 void  __attribute__((visibility("default"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
22118         LDKPositiveTimestamp this_obj_conv;
22119         this_obj_conv.inner = (void*)(this_obj & (~1));
22120         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22121         PositiveTimestamp_free(this_obj_conv);
22122 }
22123
22124 jboolean  __attribute__((visibility("default"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
22125         LDKPositiveTimestamp a_conv;
22126         a_conv.inner = (void*)(a & (~1));
22127         a_conv.is_owned = false;
22128         LDKPositiveTimestamp b_conv;
22129         b_conv.inner = (void*)(b & (~1));
22130         b_conv.is_owned = false;
22131         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
22132         return ret_val;
22133 }
22134
22135 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint32_t orig) {
22136         LDKPositiveTimestamp orig_conv;
22137         orig_conv.inner = (void*)(orig & (~1));
22138         orig_conv.is_owned = false;
22139         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
22140         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22141         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22142         uint64_t ret_ref = (uint64_t)ret_var.inner;
22143         if (ret_var.is_owned) {
22144                 ret_ref |= 1;
22145         }
22146         return ret_ref;
22147 }
22148
22149 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_clone(uint32_t orig) {
22150         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
22151         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
22152         return ret_conv;
22153 }
22154
22155 jboolean  __attribute__((visibility("default"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
22156         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
22157         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
22158         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
22159         return ret_val;
22160 }
22161
22162 int64_t  __attribute__((visibility("default"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
22163         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
22164         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
22165         return ret_val;
22166 }
22167
22168 uint32_t  __attribute__((visibility("default"))) TS_Currency_clone(uint32_t orig) {
22169         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
22170         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
22171         return ret_conv;
22172 }
22173
22174 jboolean  __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) {
22175         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
22176         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
22177         jboolean ret_val = Currency_eq(a_conv, b_conv);
22178         return ret_val;
22179 }
22180
22181 void  __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) {
22182         LDKSha256 this_obj_conv;
22183         this_obj_conv.inner = (void*)(this_obj & (~1));
22184         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22185         Sha256_free(this_obj_conv);
22186 }
22187
22188 jboolean  __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
22189         LDKSha256 a_conv;
22190         a_conv.inner = (void*)(a & (~1));
22191         a_conv.is_owned = false;
22192         LDKSha256 b_conv;
22193         b_conv.inner = (void*)(b & (~1));
22194         b_conv.is_owned = false;
22195         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
22196         return ret_val;
22197 }
22198
22199 uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) {
22200         LDKSha256 orig_conv;
22201         orig_conv.inner = (void*)(orig & (~1));
22202         orig_conv.is_owned = false;
22203         LDKSha256 ret_var = Sha256_clone(&orig_conv);
22204         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22205         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22206         uint64_t ret_ref = (uint64_t)ret_var.inner;
22207         if (ret_var.is_owned) {
22208                 ret_ref |= 1;
22209         }
22210         return ret_ref;
22211 }
22212
22213 void  __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) {
22214         LDKDescription this_obj_conv;
22215         this_obj_conv.inner = (void*)(this_obj & (~1));
22216         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22217         Description_free(this_obj_conv);
22218 }
22219
22220 jboolean  __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) {
22221         LDKDescription a_conv;
22222         a_conv.inner = (void*)(a & (~1));
22223         a_conv.is_owned = false;
22224         LDKDescription b_conv;
22225         b_conv.inner = (void*)(b & (~1));
22226         b_conv.is_owned = false;
22227         jboolean ret_val = Description_eq(&a_conv, &b_conv);
22228         return ret_val;
22229 }
22230
22231 uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) {
22232         LDKDescription orig_conv;
22233         orig_conv.inner = (void*)(orig & (~1));
22234         orig_conv.is_owned = false;
22235         LDKDescription ret_var = Description_clone(&orig_conv);
22236         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22237         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22238         uint64_t ret_ref = (uint64_t)ret_var.inner;
22239         if (ret_var.is_owned) {
22240                 ret_ref |= 1;
22241         }
22242         return ret_ref;
22243 }
22244
22245 void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) {
22246         LDKPayeePubKey this_obj_conv;
22247         this_obj_conv.inner = (void*)(this_obj & (~1));
22248         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22249         PayeePubKey_free(this_obj_conv);
22250 }
22251
22252 jboolean  __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
22253         LDKPayeePubKey a_conv;
22254         a_conv.inner = (void*)(a & (~1));
22255         a_conv.is_owned = false;
22256         LDKPayeePubKey b_conv;
22257         b_conv.inner = (void*)(b & (~1));
22258         b_conv.is_owned = false;
22259         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
22260         return ret_val;
22261 }
22262
22263 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) {
22264         LDKPayeePubKey orig_conv;
22265         orig_conv.inner = (void*)(orig & (~1));
22266         orig_conv.is_owned = false;
22267         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
22268         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22269         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22270         uint64_t ret_ref = (uint64_t)ret_var.inner;
22271         if (ret_var.is_owned) {
22272                 ret_ref |= 1;
22273         }
22274         return ret_ref;
22275 }
22276
22277 void  __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) {
22278         LDKExpiryTime this_obj_conv;
22279         this_obj_conv.inner = (void*)(this_obj & (~1));
22280         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22281         ExpiryTime_free(this_obj_conv);
22282 }
22283
22284 jboolean  __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
22285         LDKExpiryTime a_conv;
22286         a_conv.inner = (void*)(a & (~1));
22287         a_conv.is_owned = false;
22288         LDKExpiryTime b_conv;
22289         b_conv.inner = (void*)(b & (~1));
22290         b_conv.is_owned = false;
22291         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
22292         return ret_val;
22293 }
22294
22295 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) {
22296         LDKExpiryTime orig_conv;
22297         orig_conv.inner = (void*)(orig & (~1));
22298         orig_conv.is_owned = false;
22299         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
22300         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22301         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22302         uint64_t ret_ref = (uint64_t)ret_var.inner;
22303         if (ret_var.is_owned) {
22304                 ret_ref |= 1;
22305         }
22306         return ret_ref;
22307 }
22308
22309 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
22310         LDKMinFinalCltvExpiry this_obj_conv;
22311         this_obj_conv.inner = (void*)(this_obj & (~1));
22312         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22313         MinFinalCltvExpiry_free(this_obj_conv);
22314 }
22315
22316 jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
22317         LDKMinFinalCltvExpiry a_conv;
22318         a_conv.inner = (void*)(a & (~1));
22319         a_conv.is_owned = false;
22320         LDKMinFinalCltvExpiry b_conv;
22321         b_conv.inner = (void*)(b & (~1));
22322         b_conv.is_owned = false;
22323         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
22324         return ret_val;
22325 }
22326
22327 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
22328         LDKMinFinalCltvExpiry orig_conv;
22329         orig_conv.inner = (void*)(orig & (~1));
22330         orig_conv.is_owned = false;
22331         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
22332         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22333         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22334         uint64_t ret_ref = (uint64_t)ret_var.inner;
22335         if (ret_var.is_owned) {
22336                 ret_ref |= 1;
22337         }
22338         return ret_ref;
22339 }
22340
22341 void  __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) {
22342         if ((this_ptr & 1) != 0) return;
22343         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
22344         FREE((void*)this_ptr);
22345         Fallback_free(this_ptr_conv);
22346 }
22347
22348 uint32_t  __attribute__((visibility("default"))) TS_Fallback_clone(uint32_t orig) {
22349         LDKFallback* orig_conv = (LDKFallback*)orig;
22350         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
22351         *ret_copy = Fallback_clone(orig_conv);
22352         uint64_t ret_ref = (uint64_t)ret_copy;
22353         return ret_ref;
22354 }
22355
22356 jboolean  __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
22357         LDKFallback* a_conv = (LDKFallback*)a;
22358         LDKFallback* b_conv = (LDKFallback*)b;
22359         jboolean ret_val = Fallback_eq(a_conv, b_conv);
22360         return ret_val;
22361 }
22362
22363 void  __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t this_obj) {
22364         LDKInvoiceSignature this_obj_conv;
22365         this_obj_conv.inner = (void*)(this_obj & (~1));
22366         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22367         InvoiceSignature_free(this_obj_conv);
22368 }
22369
22370 jboolean  __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
22371         LDKInvoiceSignature a_conv;
22372         a_conv.inner = (void*)(a & (~1));
22373         a_conv.is_owned = false;
22374         LDKInvoiceSignature b_conv;
22375         b_conv.inner = (void*)(b & (~1));
22376         b_conv.is_owned = false;
22377         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
22378         return ret_val;
22379 }
22380
22381 uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) {
22382         LDKInvoiceSignature orig_conv;
22383         orig_conv.inner = (void*)(orig & (~1));
22384         orig_conv.is_owned = false;
22385         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
22386         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22387         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22388         uint64_t ret_ref = (uint64_t)ret_var.inner;
22389         if (ret_var.is_owned) {
22390                 ret_ref |= 1;
22391         }
22392         return ret_ref;
22393 }
22394
22395 void  __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) {
22396         LDKPrivateRoute this_obj_conv;
22397         this_obj_conv.inner = (void*)(this_obj & (~1));
22398         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22399         PrivateRoute_free(this_obj_conv);
22400 }
22401
22402 jboolean  __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
22403         LDKPrivateRoute a_conv;
22404         a_conv.inner = (void*)(a & (~1));
22405         a_conv.is_owned = false;
22406         LDKPrivateRoute b_conv;
22407         b_conv.inner = (void*)(b & (~1));
22408         b_conv.is_owned = false;
22409         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
22410         return ret_val;
22411 }
22412
22413 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) {
22414         LDKPrivateRoute orig_conv;
22415         orig_conv.inner = (void*)(orig & (~1));
22416         orig_conv.is_owned = false;
22417         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
22418         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22419         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22420         uint64_t ret_ref = (uint64_t)ret_var.inner;
22421         if (ret_var.is_owned) {
22422                 ret_ref |= 1;
22423         }
22424         return ret_ref;
22425 }
22426
22427 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
22428         LDKSignedRawInvoice this_arg_conv;
22429         this_arg_conv.inner = (void*)(this_arg & (~1));
22430         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22431         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
22432         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
22433         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
22434         return (uint64_t)ret_ref;
22435 }
22436
22437 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
22438         LDKSignedRawInvoice this_arg_conv;
22439         this_arg_conv.inner = (void*)(this_arg & (~1));
22440         this_arg_conv.is_owned = false;
22441         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
22442         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22443         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22444         uint64_t ret_ref = (uint64_t)ret_var.inner;
22445         if (ret_var.is_owned) {
22446                 ret_ref |= 1;
22447         }
22448         return ret_ref;
22449 }
22450
22451 int8_tArray  __attribute__((visibility("default"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
22452         LDKSignedRawInvoice this_arg_conv;
22453         this_arg_conv.inner = (void*)(this_arg & (~1));
22454         this_arg_conv.is_owned = false;
22455         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22456         memcpy((uint8_t*)(ret_arr + 4), *SignedRawInvoice_hash(&this_arg_conv), 32);
22457         return ret_arr;
22458 }
22459
22460 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
22461         LDKSignedRawInvoice this_arg_conv;
22462         this_arg_conv.inner = (void*)(this_arg & (~1));
22463         this_arg_conv.is_owned = false;
22464         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
22465         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22466         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22467         uint64_t ret_ref = (uint64_t)ret_var.inner;
22468         if (ret_var.is_owned) {
22469                 ret_ref |= 1;
22470         }
22471         return ret_ref;
22472 }
22473
22474 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
22475         LDKSignedRawInvoice this_arg_conv;
22476         this_arg_conv.inner = (void*)(this_arg & (~1));
22477         this_arg_conv.is_owned = false;
22478         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
22479         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
22480         return (uint64_t)ret_conv;
22481 }
22482
22483 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
22484         LDKSignedRawInvoice this_arg_conv;
22485         this_arg_conv.inner = (void*)(this_arg & (~1));
22486         this_arg_conv.is_owned = false;
22487         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
22488         return ret_val;
22489 }
22490
22491 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_hash(uint32_t this_arg) {
22492         LDKRawInvoice this_arg_conv;
22493         this_arg_conv.inner = (void*)(this_arg & (~1));
22494         this_arg_conv.is_owned = false;
22495         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22496         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_hash(&this_arg_conv).data, 32);
22497         return ret_arr;
22498 }
22499
22500 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
22501         LDKRawInvoice this_arg_conv;
22502         this_arg_conv.inner = (void*)(this_arg & (~1));
22503         this_arg_conv.is_owned = false;
22504         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
22505         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22506         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22507         uint64_t ret_ref = (uint64_t)ret_var.inner;
22508         if (ret_var.is_owned) {
22509                 ret_ref |= 1;
22510         }
22511         return ret_ref;
22512 }
22513
22514 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint32_t this_arg) {
22515         LDKRawInvoice this_arg_conv;
22516         this_arg_conv.inner = (void*)(this_arg & (~1));
22517         this_arg_conv.is_owned = false;
22518         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
22519         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22520         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22521         uint64_t ret_ref = (uint64_t)ret_var.inner;
22522         if (ret_var.is_owned) {
22523                 ret_ref |= 1;
22524         }
22525         return ret_ref;
22526 }
22527
22528 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
22529         LDKRawInvoice this_arg_conv;
22530         this_arg_conv.inner = (void*)(this_arg & (~1));
22531         this_arg_conv.is_owned = false;
22532         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
22533         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22534         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22535         uint64_t ret_ref = (uint64_t)ret_var.inner;
22536         if (ret_var.is_owned) {
22537                 ret_ref |= 1;
22538         }
22539         return ret_ref;
22540 }
22541
22542 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
22543         LDKRawInvoice this_arg_conv;
22544         this_arg_conv.inner = (void*)(this_arg & (~1));
22545         this_arg_conv.is_owned = false;
22546         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
22547         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22548         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22549         uint64_t ret_ref = (uint64_t)ret_var.inner;
22550         if (ret_var.is_owned) {
22551                 ret_ref |= 1;
22552         }
22553         return ret_ref;
22554 }
22555
22556 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
22557         LDKRawInvoice this_arg_conv;
22558         this_arg_conv.inner = (void*)(this_arg & (~1));
22559         this_arg_conv.is_owned = false;
22560         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
22561         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22562         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22563         uint64_t ret_ref = (uint64_t)ret_var.inner;
22564         if (ret_var.is_owned) {
22565                 ret_ref |= 1;
22566         }
22567         return ret_ref;
22568 }
22569
22570 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
22571         LDKRawInvoice this_arg_conv;
22572         this_arg_conv.inner = (void*)(this_arg & (~1));
22573         this_arg_conv.is_owned = false;
22574         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
22575         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22576         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22577         uint64_t ret_ref = (uint64_t)ret_var.inner;
22578         if (ret_var.is_owned) {
22579                 ret_ref |= 1;
22580         }
22581         return ret_ref;
22582 }
22583
22584 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
22585         LDKRawInvoice this_arg_conv;
22586         this_arg_conv.inner = (void*)(this_arg & (~1));
22587         this_arg_conv.is_owned = false;
22588         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22589         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_payment_secret(&this_arg_conv).data, 32);
22590         return ret_arr;
22591 }
22592
22593 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t this_arg) {
22594         LDKRawInvoice this_arg_conv;
22595         this_arg_conv.inner = (void*)(this_arg & (~1));
22596         this_arg_conv.is_owned = false;
22597         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
22598         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22599         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22600         uint64_t ret_ref = (uint64_t)ret_var.inner;
22601         if (ret_var.is_owned) {
22602                 ret_ref |= 1;
22603         }
22604         return ret_ref;
22605 }
22606
22607 uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
22608         LDKRawInvoice this_arg_conv;
22609         this_arg_conv.inner = (void*)(this_arg & (~1));
22610         this_arg_conv.is_owned = false;
22611         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
22612         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
22613         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
22614         for (size_t o = 0; o < ret_var.datalen; o++) {
22615                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
22616                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22617                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22618                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
22619                 if (ret_conv_14_var.is_owned) {
22620                         ret_conv_14_ref |= 1;
22621                 }
22622                 ret_arr_ptr[o] = ret_conv_14_ref;
22623         }
22624         FREE(ret_var.data);
22625         return ret_arr;
22626 }
22627
22628 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
22629         LDKRawInvoice this_arg_conv;
22630         this_arg_conv.inner = (void*)(this_arg & (~1));
22631         this_arg_conv.is_owned = false;
22632         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
22633         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
22634         uint64_t ret_ref = (uint64_t)ret_copy;
22635         return ret_ref;
22636 }
22637
22638 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_currency(uint32_t this_arg) {
22639         LDKRawInvoice this_arg_conv;
22640         this_arg_conv.inner = (void*)(this_arg & (~1));
22641         this_arg_conv.is_owned = false;
22642         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
22643         return ret_conv;
22644 }
22645
22646 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
22647         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
22648         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
22649         return (uint64_t)ret_conv;
22650 }
22651
22652 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_system_time(int64_t time) {
22653         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
22654         *ret_conv = PositiveTimestamp_from_system_time(time);
22655         return (uint64_t)ret_conv;
22656 }
22657
22658 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
22659         LDKPositiveTimestamp this_arg_conv;
22660         this_arg_conv.inner = (void*)(this_arg & (~1));
22661         this_arg_conv.is_owned = false;
22662         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
22663         return ret_val;
22664 }
22665
22666 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_time(uint32_t this_arg) {
22667         LDKPositiveTimestamp this_arg_conv;
22668         this_arg_conv.inner = (void*)(this_arg & (~1));
22669         this_arg_conv.is_owned = false;
22670         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
22671         return ret_val;
22672 }
22673
22674 uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
22675         LDKInvoice this_arg_conv;
22676         this_arg_conv.inner = (void*)(this_arg & (~1));
22677         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22678         this_arg_conv = Invoice_clone(&this_arg_conv);
22679         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
22680         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22681         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22682         uint64_t ret_ref = (uint64_t)ret_var.inner;
22683         if (ret_var.is_owned) {
22684                 ret_ref |= 1;
22685         }
22686         return ret_ref;
22687 }
22688
22689 uint32_t  __attribute__((visibility("default"))) TS_Invoice_check_signature(uint32_t this_arg) {
22690         LDKInvoice this_arg_conv;
22691         this_arg_conv.inner = (void*)(this_arg & (~1));
22692         this_arg_conv.is_owned = false;
22693         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
22694         *ret_conv = Invoice_check_signature(&this_arg_conv);
22695         return (uint64_t)ret_conv;
22696 }
22697
22698 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
22699         LDKSignedRawInvoice signed_invoice_conv;
22700         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
22701         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
22702         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
22703         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
22704         *ret_conv = Invoice_from_signed(signed_invoice_conv);
22705         return (uint64_t)ret_conv;
22706 }
22707
22708 int64_t  __attribute__((visibility("default"))) TS_Invoice_timestamp(uint32_t this_arg) {
22709         LDKInvoice this_arg_conv;
22710         this_arg_conv.inner = (void*)(this_arg & (~1));
22711         this_arg_conv.is_owned = false;
22712         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
22713         return ret_val;
22714 }
22715
22716 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_hash(uint32_t this_arg) {
22717         LDKInvoice this_arg_conv;
22718         this_arg_conv.inner = (void*)(this_arg & (~1));
22719         this_arg_conv.is_owned = false;
22720         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22721         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_hash(&this_arg_conv), 32);
22722         return ret_arr;
22723 }
22724
22725 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
22726         LDKInvoice this_arg_conv;
22727         this_arg_conv.inner = (void*)(this_arg & (~1));
22728         this_arg_conv.is_owned = false;
22729         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22730         memcpy((uint8_t*)(ret_arr + 4), Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
22731         return ret_arr;
22732 }
22733
22734 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(uint32_t this_arg) {
22735         LDKInvoice this_arg_conv;
22736         this_arg_conv.inner = (void*)(this_arg & (~1));
22737         this_arg_conv.is_owned = false;
22738         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22739         memcpy((uint8_t*)(ret_arr + 4), Invoice_payment_secret(&this_arg_conv).data, 32);
22740         return ret_arr;
22741 }
22742
22743 uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t this_arg) {
22744         LDKInvoice this_arg_conv;
22745         this_arg_conv.inner = (void*)(this_arg & (~1));
22746         this_arg_conv.is_owned = false;
22747         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
22748         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22749         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22750         uint64_t ret_ref = (uint64_t)ret_var.inner;
22751         if (ret_var.is_owned) {
22752                 ret_ref |= 1;
22753         }
22754         return ret_ref;
22755 }
22756
22757 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
22758         LDKInvoice this_arg_conv;
22759         this_arg_conv.inner = (void*)(this_arg & (~1));
22760         this_arg_conv.is_owned = false;
22761         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22762         memcpy((uint8_t*)(ret_arr + 4), Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
22763         return ret_arr;
22764 }
22765
22766 int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t this_arg) {
22767         LDKInvoice this_arg_conv;
22768         this_arg_conv.inner = (void*)(this_arg & (~1));
22769         this_arg_conv.is_owned = false;
22770         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
22771         return ret_val;
22772 }
22773
22774 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
22775         LDKInvoice this_arg_conv;
22776         this_arg_conv.inner = (void*)(this_arg & (~1));
22777         this_arg_conv.is_owned = false;
22778         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
22779         return ret_val;
22780 }
22781
22782 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(uint32_t this_arg) {
22783         LDKInvoice this_arg_conv;
22784         this_arg_conv.inner = (void*)(this_arg & (~1));
22785         this_arg_conv.is_owned = false;
22786         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
22787         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
22788         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
22789         for (size_t o = 0; o < ret_var.datalen; o++) {
22790                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
22791                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22792                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22793                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
22794                 if (ret_conv_14_var.is_owned) {
22795                         ret_conv_14_ref |= 1;
22796                 }
22797                 ret_arr_ptr[o] = ret_conv_14_ref;
22798         }
22799         FREE(ret_var.data);
22800         return ret_arr;
22801 }
22802
22803 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uint32_t this_arg) {
22804         LDKInvoice this_arg_conv;
22805         this_arg_conv.inner = (void*)(this_arg & (~1));
22806         this_arg_conv.is_owned = false;
22807         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
22808         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
22809         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
22810         for (size_t l = 0; l < ret_var.datalen; l++) {
22811                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
22812                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22813                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22814                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
22815                 if (ret_conv_11_var.is_owned) {
22816                         ret_conv_11_ref |= 1;
22817                 }
22818                 ret_arr_ptr[l] = ret_conv_11_ref;
22819         }
22820         FREE(ret_var.data);
22821         return ret_arr;
22822 }
22823
22824 uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t this_arg) {
22825         LDKInvoice this_arg_conv;
22826         this_arg_conv.inner = (void*)(this_arg & (~1));
22827         this_arg_conv.is_owned = false;
22828         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
22829         return ret_conv;
22830 }
22831
22832 uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_pico_btc(uint32_t this_arg) {
22833         LDKInvoice this_arg_conv;
22834         this_arg_conv.inner = (void*)(this_arg & (~1));
22835         this_arg_conv.is_owned = false;
22836         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
22837         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
22838         uint64_t ret_ref = (uint64_t)ret_copy;
22839         return ret_ref;
22840 }
22841
22842 uint32_t  __attribute__((visibility("default"))) TS_Description_new(jstring description) {
22843         LDKStr description_conv = str_ref_to_owned_c(description);
22844         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
22845         *ret_conv = Description_new(description_conv);
22846         return (uint64_t)ret_conv;
22847 }
22848
22849 jstring  __attribute__((visibility("default"))) TS_Description_into_inner(uint32_t this_arg) {
22850         LDKDescription this_arg_conv;
22851         this_arg_conv.inner = (void*)(this_arg & (~1));
22852         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22853         this_arg_conv = Description_clone(&this_arg_conv);
22854         LDKStr ret_str = Description_into_inner(this_arg_conv);
22855         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22856         return ret_conv;
22857 }
22858
22859 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
22860         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
22861         *ret_conv = ExpiryTime_from_seconds(seconds);
22862         return (uint64_t)ret_conv;
22863 }
22864
22865 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_duration(int64_t duration) {
22866         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
22867         *ret_conv = ExpiryTime_from_duration(duration);
22868         return (uint64_t)ret_conv;
22869 }
22870
22871 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
22872         LDKExpiryTime this_arg_conv;
22873         this_arg_conv.inner = (void*)(this_arg & (~1));
22874         this_arg_conv.is_owned = false;
22875         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
22876         return ret_val;
22877 }
22878
22879 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
22880         LDKExpiryTime this_arg_conv;
22881         this_arg_conv.inner = (void*)(this_arg & (~1));
22882         this_arg_conv.is_owned = false;
22883         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
22884         return ret_val;
22885 }
22886
22887 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_new(uint32_t hops) {
22888         LDKRouteHint hops_conv;
22889         hops_conv.inner = (void*)(hops & (~1));
22890         hops_conv.is_owned = (hops & 1) || (hops == 0);
22891         hops_conv = RouteHint_clone(&hops_conv);
22892         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
22893         *ret_conv = PrivateRoute_new(hops_conv);
22894         return (uint64_t)ret_conv;
22895 }
22896
22897 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
22898         LDKPrivateRoute this_arg_conv;
22899         this_arg_conv.inner = (void*)(this_arg & (~1));
22900         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22901         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
22902         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
22903         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22904         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22905         uint64_t ret_ref = (uint64_t)ret_var.inner;
22906         if (ret_var.is_owned) {
22907                 ret_ref |= 1;
22908         }
22909         return ret_ref;
22910 }
22911
22912 uint32_t  __attribute__((visibility("default"))) TS_CreationError_clone(uint32_t orig) {
22913         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
22914         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
22915         return ret_conv;
22916 }
22917
22918 jboolean  __attribute__((visibility("default"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
22919         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
22920         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
22921         jboolean ret_val = CreationError_eq(a_conv, b_conv);
22922         return ret_val;
22923 }
22924
22925 jstring  __attribute__((visibility("default"))) TS_CreationError_to_str(uint32_t o) {
22926         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
22927         LDKStr ret_str = CreationError_to_str(o_conv);
22928         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22929         return ret_conv;
22930 }
22931
22932 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_clone(uint32_t orig) {
22933         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
22934         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
22935         return ret_conv;
22936 }
22937
22938 jboolean  __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
22939         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
22940         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
22941         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
22942         return ret_val;
22943 }
22944
22945 jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t o) {
22946         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
22947         LDKStr ret_str = SemanticError_to_str(o_conv);
22948         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22949         return ret_conv;
22950 }
22951
22952 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
22953         if ((this_ptr & 1) != 0) return;
22954         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
22955         FREE((void*)this_ptr);
22956         SignOrCreationError_free(this_ptr_conv);
22957 }
22958
22959 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone(uint32_t orig) {
22960         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
22961         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
22962         *ret_copy = SignOrCreationError_clone(orig_conv);
22963         uint64_t ret_ref = (uint64_t)ret_copy;
22964         return ret_ref;
22965 }
22966
22967 jboolean  __attribute__((visibility("default"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
22968         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
22969         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
22970         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
22971         return ret_val;
22972 }
22973
22974 jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(uint32_t o) {
22975         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
22976         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
22977         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22978         return ret_conv;
22979 }
22980
22981 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) {
22982         LDKChannelManager channelmanager_conv;
22983         channelmanager_conv.inner = (void*)(channelmanager & (~1));
22984         channelmanager_conv.is_owned = false;
22985         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
22986         LDKCurrency network_conv = LDKCurrency_from_js(network);
22987         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
22988         LDKStr description_conv = str_ref_to_owned_c(description);
22989         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22990         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
22991         return (uint64_t)ret_conv;
22992 }
22993
22994 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
22995         LDKStr s_conv = str_ref_to_owned_c(s);
22996         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
22997         *ret_conv = SiPrefix_from_str(s_conv);
22998         return (uint64_t)ret_conv;
22999 }
23000
23001 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_str(jstring s) {
23002         LDKStr s_conv = str_ref_to_owned_c(s);
23003         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
23004         *ret_conv = Invoice_from_str(s_conv);
23005         return (uint64_t)ret_conv;
23006 }
23007
23008 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_from_str(jstring s) {
23009         LDKStr s_conv = str_ref_to_owned_c(s);
23010         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
23011         *ret_conv = SignedRawInvoice_from_str(s_conv);
23012         return (uint64_t)ret_conv;
23013 }
23014
23015 jstring  __attribute__((visibility("default"))) TS_Invoice_to_str(uint32_t o) {
23016         LDKInvoice o_conv;
23017         o_conv.inner = (void*)(o & (~1));
23018         o_conv.is_owned = false;
23019         LDKStr ret_str = Invoice_to_str(&o_conv);
23020         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23021         return ret_conv;
23022 }
23023
23024 jstring  __attribute__((visibility("default"))) TS_SignedRawInvoice_to_str(uint32_t o) {
23025         LDKSignedRawInvoice o_conv;
23026         o_conv.inner = (void*)(o & (~1));
23027         o_conv.is_owned = false;
23028         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
23029         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23030         return ret_conv;
23031 }
23032
23033 jstring  __attribute__((visibility("default"))) TS_Currency_to_str(uint32_t o) {
23034         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
23035         LDKStr ret_str = Currency_to_str(o_conv);
23036         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23037         return ret_conv;
23038 }
23039
23040 jstring  __attribute__((visibility("default"))) TS_SiPrefix_to_str(uint32_t o) {
23041         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
23042         LDKStr ret_str = SiPrefix_to_str(o_conv);
23043         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23044         return ret_conv;
23045 }
23046